Skip to content

Commit

Permalink
README: Update for Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeken committed Nov 2, 2020
1 parent 20a3f9a commit 8f76970
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

When you want to call Github APIs from machines, you would want an access token which independs of a real account.
Github provides several ways to issue tokens, for example:
- Issue Personal Access Token via machine-user: Before Github Apps exists, this is typical method to issue a token but it consumes one user seats.
- Create Github Apps and issue a token for the app: This is a new way and recommended way. The problem is [it's not that easy to issue a token](https://docs.github.com/en/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app) just to automate small stuff.
- **Personal Access Token via machine-user**: Before Github Apps exists, this is typical method to issue a token but it consumes one user seats.
- **Github Apps**: This is a new and recommended way. The problem is [it's not that easy to issue a token](https://docs.github.com/en/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app) just to automate small stuff.

This command-line tool allows you to get a token with just providing `App ID`, `Installation ID` and the private key.

Expand Down Expand Up @@ -43,6 +43,25 @@ curl -sSLf https://raw.githubusercontent.com/nabeken/go-github-apps/master/insta
sudo cp go-github-apps /usr/local/bin
```

## Github Actions

You can automate issuing a token with Github Actions.

Example:
```yml
- name: Get GITHUB_TOKEN for Github Apps
uses: nabeken/go-github-apps@v0
id: go-github-apps
with:
installation_id: ${{ secrets.installation_id }}
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.private_key }}

- name: Test Github API call
run: |
curl --fail -H 'Authorization: token ${{ steps.go-github-apps.outputs.app_github_token }}' https://api.github.com/
```
## AppID and Installation ID
You can find how to get those ID at https://github.com/bradleyfalzon/ghinstallation#what-is-app-id-and-installation-id

0 comments on commit 8f76970

Please sign in to comment.