Skip to content

Commit d1defa4

Browse files
authored
Switch to using an app token instead of a PAT (#362)
The app token will persist even as users come/go from the :dependabot: team. It also allows us more finegrained access controls from the app settings page if we need to suddenly lockdown something, we don't have to rely on the person who created the PAT.
1 parent cb17c9e commit d1defa4

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.github/workflows/dependabot-auto-merge.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ jobs:
77

88
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
99
steps:
10+
- name: Generate token
11+
id: generate_token
12+
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
13+
with:
14+
app_id: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_APP_ID }}
15+
private_key: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_PRIVATE_KEY }}
16+
1017
- name: Check out code
1118
uses: actions/checkout@v3
1219

1320
- name: Auto-merge
1421
run: gh pr merge --auto --merge '${{ github.event.pull_request.html_url }}'
1522
env:
16-
GITHUB_TOKEN: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
23+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

.github/workflows/dependabot-build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ jobs:
3131
# We only need to build the dist/ folder if the PR relates a production NPM dependency, otherwise we don't expect changes.
3232
if: needs.fetch-dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' && needs.fetch-dependabot-metadata.outputs.dependency-type == 'direct:production'
3333
steps:
34-
# Check out using a PAT so any pushed changes will trigger checkruns
34+
- name: Generate token
35+
id: generate_token
36+
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
37+
with:
38+
app_id: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_APP_ID }}
39+
private_key: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_PRIVATE_KEY }}
40+
3541
- uses: actions/checkout@v3
3642
with:
3743
ref: ${{ github.event.pull_request.head.ref }}
38-
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
44+
# Check out using an app token so any pushed changes will trigger checkruns
45+
token: ${{ steps.generate_token.outputs.token }}
3946

4047
- name: Setup Node.js
4148
uses: actions/setup-node@v3

.github/workflows/release-bump-version.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21+
- name: Generate token
22+
id: generate_token
23+
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
24+
with:
25+
app_id: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_APP_ID }}
26+
private_key: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_PRIVATE_KEY }}
27+
2128
- uses: actions/checkout@v3
2229
with:
2330
# Ensure we start from main in case the workflow is run from a branch
2431
ref: "main"
25-
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
32+
token: ${{ steps.generate_token.outputs.token }}
2633

2734
- uses: actions/setup-node@v3 # bin/bump-version needs npm
2835
with:
@@ -66,7 +73,7 @@ jobs:
6673
echo "PR created at URL: $PR_URL"
6774
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
6875
env:
69-
GH_TOKEN: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
76+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
7077

7178
- name: Set summary
7279
run: |

.github/workflows/release-move-tracking-tag.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ jobs:
2828
# the road we increase the robustness of this.
2929

3030
steps:
31+
- name: Generate token
32+
id: generate_token
33+
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
34+
with:
35+
app_id: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_APP_ID }}
36+
private_key: ${{ secrets.FETCH_METADATA_ACTION_AUTOMATION_PRIVATE_KEY }}
37+
3138
- uses: actions/checkout@v3
3239
with:
33-
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
40+
token: ${{ steps.generate_token.outputs.token }}
3441

3542
- name: Move the tracking tag
3643
run: git tag -f v1

0 commit comments

Comments
 (0)