This GitHub Action retrieves a GitHub App installation token for use in workflows.
-
Create a GitHub Application in your organization, scoped to whichever permissions you need your token to have.
-
After you've created the application, make note of the App ID.
-
Locate the Private keys section. Generate and download a private key.
Install the app, granting access to the repository where you want to use this action.
In the repository where you want to use this action, create two encrypted secrets as follows.
Secret name | Value |
---|---|
APPLICATION_ID |
The App ID of your GitHub Application |
APPLICATION_PRIVATE_KEY |
The contents of the private key you generated and downloaded. You can open the file in a text editor and copy/paste. |
This action has the following inputs and outputs
Input | Description |
---|---|
application-id |
The GitHub App ID |
application-private-key |
The GitHub App private key |
Output | Description |
---|---|
app-token |
The token retrieved from GitHub |
name: Test action
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get token
id: get_token
uses: microsoftgraph/get-app-token@main
with:
application-id: ${{ secrets.APPLICATION_ID }}
application-private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
- name: Use token
uses: actions/github-script@v5
with:
github-token: ${{ steps.get_token.outputs.app-token }}
script: |
const repo = await github.rest.repos.get(context.repo);
console.log(JSON.stringify(repo, null, 2));