Skip to content

Commit 3f2a35f

Browse files
authored
chore(ci): use github app tokens instead of bot user (#2282)
1 parent 41a1865 commit 3f2a35f

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

.github/workflows/cron-tasks.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,12 @@ jobs:
1717
npm_config_foreground_scripts: "true"
1818
PUPPETEER_SKIP_DOWNLOAD: "true"
1919
steps:
20-
- uses: actions/create-github-app-token@v1
20+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
2121
id: app-token
2222
with:
2323
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
2424
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
2525

26-
- name: Get GitHub App User ID
27-
id: get-user-id
28-
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
29-
env:
30-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
31-
3226
- uses: actions/checkout@v4
3327
with:
3428
# don't checkout a detatched HEAD
@@ -39,11 +33,6 @@ jobs:
3933
fetch-depth: "0"
4034
token: ${{ steps.app-token.outputs.token }}
4135

42-
- name: Set up Git
43-
run: |
44-
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
45-
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
46-
4736
- uses: actions/setup-node@v4
4837
with:
4938
node-version: ^16.x

.github/workflows/update-node-js.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ jobs:
1111
name: Update Node.js versions
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
18+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
19+
1420
- uses: actions/checkout@v4
1521
with:
1622
# don't checkout a detatched HEAD
1723
ref: ${{ github.head_ref }}
1824

19-
# this is important so git log can pick up on
20-
# the whole history to generate the list of AUTHORS
21-
fetch-depth: "0"
22-
23-
- name: Setup git
24-
run: |
25-
git config --local user.email "[email protected]"
26-
git config --local user.name "devtoolsbot"
27-
2825
- uses: actions/setup-node@v4
2926
with:
3027
node-version: 20.x
@@ -42,7 +39,7 @@ jobs:
4239
- name: Create Pull Request
4340
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
4441
with:
45-
token: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
42+
token: ${{ steps.app-token.outputs.token }}
4643
commit-message: "chore: update node.js version"
4744
branch: ci/update-node-js-versions
4845
title: "chore: update node.js"

0 commit comments

Comments
 (0)