Skip to content

Commit 7ab941a

Browse files
committed
Docs: update readme
1 parent 5b3c68d commit 7ab941a

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

.github/workflows/test-release.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ jobs:
7171
continue-on-error: true
7272
run: |
7373
npm ci
74+
echo "::add-mask::${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}"
75+
echo "::add-mask::${{ secrets.GHA_APPLICATION_ID }}"
76+
GITHUB_APPLICATION_PRIVATE_KEY="${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}"
77+
GITHUB_APPLICATION_ID="${{ secrets.GHA_APPLICATION_ID }}"
78+
GITHUB_REPOSITORY_OWNER=sammcj
7479
npm run test
7580
7681
test-installed-limited:
@@ -113,31 +118,28 @@ jobs:
113118
- name: Check permissions
114119
shell: bash
115120
run: |
116-
set -e
117121
EXPIRES_AT="${{ steps.use_action.outputs.expires_at }}"
118122
PERMISSIONS_REQUESTED="${{ steps.use_action.outputs.permissions_requested }}"
119123
PERMISSIONS_GRANTED="${{ steps.use_action.outputs.permissions_granted }}"
120124
if [[ -z "$EXPIRES_AT" ]]; then
121-
echo "No token was generated" >> "$GITHUB_STEP_SUMMARY"
125+
echo "🚨 No token was generated! 🚨" >> "$GITHUB_STEP_SUMMARY"
122126
exit 1
123127
fi
124128
if [[ -z "$PERMISSIONS_REQUESTED" ]]; then
125-
echo "No permissions were requested" >> "$GITHUB_STEP_SUMMARY"
129+
echo "🚨 No permissions were requested! 🚨" >> "$GITHUB_STEP_SUMMARY"
126130
exit 1
127131
fi
128132
if [[ -z "$PERMISSIONS_GRANTED" ]]; then
129-
echo "No permissions were granted" >> "$GITHUB_STEP_SUMMARY"
133+
echo "🚨 No permissions were granted! 🚨" >> "$GITHUB_STEP_SUMMARY"
130134
exit 1
131135
fi
132136
if [[ "$PERMISSIONS_REQUESTED" != "$PERMISSIONS_GRANTED" ]]; then
133-
echo "Permissions requested and granted do not match" >> "$GITHUB_STEP_SUMMARY"
137+
echo "🚨 Permissions requested and granted do not match! 🚨" >> "$GITHUB_STEP_SUMMARY"
134138
exit 1
135139
fi
136-
echo "---" >> "$GITHUB_STEP_SUMMARY"
137-
echo "Permissions requested and granted match" >> "$GITHUB_STEP_SUMMARY"
138-
echo "Permissions requested: $PERMISSIONS_REQUESTED" >> "$GITHUB_STEP_SUMMARY"
139-
echo "Permissions granted: $PERMISSIONS_GRANTED" >> "$GITHUB_STEP_SUMMARY"
140-
echo "---" >> "$GITHUB_STEP_SUMMARY"
140+
echo "Permissions requested and granted match 🎉" >> "$GITHUB_STEP_SUMMARY"
141+
echo "Permissions requested: `$PERMISSIONS_REQUESTED`" >> "$GITHUB_STEP_SUMMARY"
142+
echo "Permissions granted: `$PERMISSIONS_GRANTED`" >> "$GITHUB_STEP_SUMMARY"
141143
142144
- name: Use token to checkout repository
143145
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
@@ -217,6 +219,8 @@ jobs:
217219
github_token: ${{ secrets.GITHUB_TOKEN }}
218220
release_branches: main
219221
pre_release_branches: dev
222+
fetch_all_tags: true
223+
default_bump: minor
220224
- name: Create a GitHub release
221225
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1
222226
if: github.ref == 'refs/heads/main'
@@ -226,5 +230,6 @@ jobs:
226230
body: ${{ steps.tag_version.outputs.changelog }}
227231
generateReleaseNotes: true
228232
allowUpdates: true
233+
makeLatest: true
229234
env:
230235
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
This [JavaScript GitHub Action](https://help.github.com/en/actions/building-actions/about-actions#javascript-actions) can be used to act as a GitHub App that with a private key and installation ID to generate a short lived (and optionally de-scoped) token that can be used to authenticate with the GitHub API.
88

9+
![](https://github.com/sammcj/github-app-installation-token/assets/862951/7f8011e2-ed98-4453-a007-eeabecfc84ed)
10+
911
- [GitHub App Token Authoriser](#github-app-token-authoriser)
1012
- [Use Cases](#use-cases)
1113
- [Example Workflows](#example-workflows)
@@ -22,22 +24,23 @@ This [JavaScript GitHub Action](https://help.github.com/en/actions/building-acti
2224

2325
This is useful for when `secrets.GITHUB_TOKEN`'s limitations are too restrictive and a personal access token is not suitable.
2426

25-
The repo scoped [`secrets.GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) has limitations such as:
27+
The repo scoped [`secrets.GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
28+
has limitations such as:
2629

2730
- Cannot be used to checkout other private or internal repositories.
2831
- Have their permissions scoped at the workflow level - not by admins.
2932
- Cannot trigger a workflow run from another workflow.
3033

3134
A common workaround for individual use is to use a [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) but this has significant security, maintenance and auditability issues.
3235

33-
Github recommends using [GitHub Apps](https://developer.github.com/apps/differences-between-apps/#machine-vs-bot-accounts) as a workaround to automate authentication to Github Services that isn't provided out of the box by Github / Actions.
36+
Github recommends using [GitHub Apps](https://developer.github.com/apps/differences-between-apps/#machine-vs-bot-accounts) as a
37+
workaround to automate authentication to Github Services that isn't provided out of the box by Github / Actions.
3438

3539
## Example Workflows
3640

3741
Get a token with all the permissions of the GitHub Application
3842

3943
```yaml
40-
4144
jobs:
4245
get-temp-token:
4346
runs-on: ubuntu-latest
@@ -46,8 +49,8 @@ jobs:
4649
id: get_workflow_token
4750
uses: sammcj/github-app-installation-token@main # or a specific version
4851
with:
49-
application_id: ${{ secrets.GHA_APPLICATION_ID }}
50-
application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}
52+
application_id: ${{ secrets.AUTHENTICATOR_APPLICATION_ID }}
53+
application_private_key: ${{ secrets.AUTHENTICATOR_APPLICATION_PRIVATE_KEY }}
5154

5255
- name: Use Application Token to checkout a repository
5356
uses: actions/checkout@v3
@@ -56,7 +59,8 @@ jobs:
5659
....
5760
```
5861

59-
Get a token with a limited subset of the permissions of the Github Application, in this case adding the `actions:write` and `issues:read` permissions.
62+
Get a token with a limited subset of the permissions of the Github Application, in this case adding the
63+
`actions:write` and `issues:read` permissions.
6064

6165
```yaml
6266
jobs:
@@ -67,8 +71,8 @@ jobs:
6771
id: get_workflow_token
6872
sammcj/github-app-installation-token@main # or a specific version
6973
with:
70-
application_id: ${{ secrets.GHA_APPLICATION_ID }}
71-
application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}
74+
application_id: ${{ secrets.AUTHENTICATOR_APPLICATION_ID }}
75+
application_private_key: ${{ secrets.AUTHENTICATOR_APPLICATION_PRIVATE_KEY }}
7276
permissions: "actions:write,issues:read"
7377

7478
- name: Use Application Token to checkout a repository
@@ -90,8 +94,8 @@ jobs:
9094
id: get_workflow_token
9195
uses: sammcj/github-app-installation-token@main # or a specific version
9296
with:
93-
application_id: ${{ secrets.GHA_APPLICATION_ID }}
94-
application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}
97+
application_id: ${{ secrets.AUTHENTICATOR_APPLICATION_ID }}
98+
application_private_key: ${{ secrets.AUTHENTICATOR_APPLICATION_PRIVATE_KEY }}
9599
organization: CattleDip
96100

97101
- name: Use Application Token to checkout a repository
@@ -157,7 +161,7 @@ The important configuration details for the application are:
157161
- `Homepage URL` needs to be set to something as long as it is a URL
158162
- `Expire user authorization tokens` should be checked so as to expire any tokens that are issued
159163
- `Webhook` `Active` checkbox should be unchecked
160-
- `Repository permissions`, `Organization permissions` and/or `User permissions` should be set to allow the access required for the token that will be issued
164+
- `Repository permissions`, `Organization permissions` and/or `User permissions` allows the access required for the token that will be issued
161165
- `Where can this GitHub App be installed?` should be scoped to your desired audience (the current account, or any account)
162166

163167
Once the application has been created you will be taken to the `General` settings page for the new application.
@@ -194,7 +198,7 @@ and either:
194198

195199
- `GITHUB_ORGANIZATION` - The GitHub Organisation to get the application installation for, if not specified will use the current repository instead
196200
or
197-
- `GITHUB_REPOSITORY_OWNER=<user>` - The GitHub Repository Owner to get the application installation for, if not specified will use the current repository instead
201+
- `GITHUB_REPOSITORY_OWNER` - The GitHub Repository Owner to get the application installation for, if not specified will use the current repository instead
198202

199203
e.g:
200204

0 commit comments

Comments
 (0)