Skip to content

Commit 19e3a98

Browse files
committed
chore(ci): use github app for tokens
1 parent ccdfa90 commit 19e3a98

File tree

5 files changed

+45
-58
lines changed

5 files changed

+45
-58
lines changed

.github/workflows/authors-and-third-party-notices.yaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ jobs:
1616
HADRON_DISTRIBUTION: compass
1717
steps:
1818
- name: Create Github App Token
19-
uses: actions/create-github-app-token@v1
19+
uses: mongodb-js/devtools-shared/actions/setup-bot-token@ni/github-app-action
2020
id: app-token
2121
with:
2222
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
2323
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
2424

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

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

.github/workflows/bump-packages.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ jobs:
1010
name: Bump packages
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- name: Create Github App Token
14+
uses: mongodb-js/devtools-shared/actions/setup-bot-token@ni/github-app-action
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
18+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
19+
20+
- uses: actions/checkout@v4
1421
with:
1522
# don't checkout a detatched HEAD
1623
ref: ${{ github.head_ref }}
1724

18-
# this is important so git log can pick up on
19-
# the whole history to generate the list of AUTHORS
20-
fetch-depth: '0'
21-
22-
- name: Setup git
23-
run: |
24-
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
25-
git config --local user.name "github-actions[bot]"
26-
27-
- uses: actions/setup-node@v3
25+
- uses: actions/setup-node@v4
2826
with:
2927
node-version: 20.16.0
30-
cache: 'npm'
28+
cache: "npm"
3129

3230
- name: Install [email protected]
3331
run: |
@@ -40,21 +38,20 @@ jobs:
4038
4139
- name: Bump packages
4240
env:
43-
LAST_BUMP_COMMIT_MESSAGE: 'chore(release): bump package versions'
44-
SKIP_BUMP_PACKAGES: 'mongodb-compass'
41+
LAST_BUMP_COMMIT_MESSAGE: "chore(release): bump package versions"
42+
SKIP_BUMP_PACKAGES: "mongodb-compass"
4543
run: |
4644
npm run bump-packages
4745
git add .
4846
git commit --no-allow-empty -m "$LAST_BUMP_COMMIT_MESSAGE" || true
4947
5048
- name: Create Pull Request
51-
id: cpr
52-
uses: peter-evans/create-pull-request@v6
49+
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
5350
with:
54-
token: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
55-
commit-message: 'chore(release): bump package versions'
51+
token: ${{ steps.app-token.outputs.token }}
52+
commit-message: "chore(release): bump package versions"
5653
branch: ci/bump-packages
57-
title: 'chore(release): bump package versions'
54+
title: "chore(release): bump package versions"
5855
labels: no-title-validation
5956
body: |
6057
- Bump package versions

.github/workflows/merge-bump-packages-pr.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ on:
33
workflow_dispatch:
44
schedule:
55
# Each Tuesday at 5 AM UTC
6-
- cron: '0 5 * * 2'
6+
- cron: "0 5 * * 2"
77

88
jobs:
99
merge_bump_packages_pr:
1010
name: Merge bump packages PR
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- name: Create Github App Token
14+
uses: actions/create-github-app-token@v1
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
18+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
1419

1520
- name: Merge PR
1621
env:
17-
GITHUB_TOKEN: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
22+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
1823
run: |
1924
set -e
2025
PR_NUMBER=$(gh pr list -s open --head=ci/bump-packages --limit=1 --json number | jq '.[0].number')

.github/workflows/update-electron.yaml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,40 @@ jobs:
1111
name: Update Electron
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- name: Create Github App Token
15+
uses: mongodb-js/devtools-shared/actions/setup-bot-token@ni/github-app-action
16+
id: app-token
17+
with:
18+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
19+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
20+
21+
- uses: actions/checkout@v4
1522
with:
1623
# don't checkout a detatched HEAD
1724
ref: ${{ github.head_ref }}
1825

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 "41898282+github-actions[bot]@users.noreply.github.com"
26-
git config --local user.name "github-actions[bot]"
27-
- uses: actions/setup-node@v3
26+
- uses: actions/setup-node@v4
2827
with:
2928
node-version: 20.16.0
30-
cache: 'npm'
29+
cache: "npm"
3130

3231
- name: Install [email protected]
3332
run: |
3433
npm install -g [email protected]
34+
3535
- name: Install Dependencies
36-
run: |
37-
npm -v
38-
npm ci
36+
run: npm ci
37+
3938
- name: Bump packages
40-
run: |
41-
node scripts/update-electron.js
42-
git add .
43-
git commit --no-allow-empty -m "chore(deps): update electron" || true
39+
run: node scripts/update-electron.js
40+
4441
- name: Create Pull Request
45-
id: cpr
46-
uses: peter-evans/create-pull-request@v6
42+
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
4743
with:
48-
token: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
49-
commit-message: 'chore(deps): update electron'
44+
token: ${{ steps.app-token.outputs.token }}
45+
commit-message: "chore(deps): update electron"
5046
branch: ci/update-electron
51-
title: 'chore(deps): update electron'
47+
title: "chore(deps): update electron"
5248
labels: no-title-validation
5349
body: |
5450
- Update electron

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ In particular each change to the `main` branch is analyzed to calculate a new ve
9797

9898
Merging that PR will trigger another CI job that will publish to NPM any package which version is not yet present on the registry.
9999

100-
The version of packages is calculated following conventional bumps: See https://github.com/mongodb-js/devtools-shared/tree/main/packages/bump-monorepo-packages for details.
100+
The version of packages is calculated following conventional bumps: See https://github.com/mongodb-js/devtools-shared/tree/main/packages/monorepo-tools for details.
101101

102102
## Add / Update / Remove Dependencies in Packages
103103

0 commit comments

Comments
 (0)