Skip to content

Commit 60561e8

Browse files
committed
chore(ci): use github app instead of bot user
1 parent d9db8b5 commit 60561e8

File tree

4 files changed

+85
-99
lines changed

4 files changed

+85
-99
lines changed

.github/workflows/bump-packages.yaml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,39 @@ jobs:
1010
name: Bump packages
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/create-github-app-token@v1
14+
id: app-token
15+
with:
16+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
17+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
18+
19+
- name: Get GitHub App User ID
20+
id: get-user-id
21+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
22+
shell: bash
23+
env:
24+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
25+
26+
- name: Set up Git
27+
run: |
28+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
29+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
30+
shell: bash
31+
32+
- uses: actions/checkout@v4
1433
with:
1534
# don't checkout a detatched HEAD
1635
ref: ${{ github.head_ref }}
1736

1837
# this is important so git log can pick up on
1938
# 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]"
39+
fetch-depth: "0"
2640

2741
- name: Setup Node.js
28-
uses: actions/setup-node@v3
42+
uses: actions/setup-node@v4
2943
with:
3044
node-version: 20.x
31-
cache: 'npm'
45+
cache: "npm"
3246

3347
- name: Install npm
3448
run: npm install -g npm@8
@@ -46,21 +60,4 @@ jobs:
4660
npm run bump-packages
4761
git add .
4862
git commit --no-allow-empty -m "chore(ci): bump packages" || true
49-
50-
- name: Create Pull Request
51-
id: cpr
52-
uses: peter-evans/create-pull-request@v6
53-
with:
54-
commit-message: 'chore(ci): bump packages'
55-
branch: ci/bump-packages
56-
title: 'chore(ci): bump packages'
57-
body: |
58-
- Bump package versions
59-
60-
- name: Merge PR
61-
if: ${{steps.cpr.outputs.pull-request-operation == 'created'}}
62-
env:
63-
PULL_REQUEST_NUMBER: ${{steps.cpr.outputs.pull-request-number}}
64-
GITHUB_TOKEN: ${{secrets.PAT}}
65-
run: |
66-
gh pr merge $PULL_REQUEST_NUMBER --squash --delete-branch
63+
git push

.github/workflows/check-test.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ jobs:
4646

4747
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
4848
- name: Checkout
49-
uses: actions/checkout@v2
49+
uses: actions/checkout@v4
5050
with:
5151
fetch-depth: 0
5252

5353
- name: Setup Node.js
54-
uses: actions/setup-node@v3
54+
uses: actions/setup-node@v4
5555
with:
5656
node-version: 20.x
57-
cache: 'npm'
57+
cache: "npm"
5858

5959
- name: Install npm
6060
run: npm install -g npm@8
6161

6262
- name: Use [email protected]
6363
# Default Python (3.12) doesn't have support for distutils
6464
# https://github.com/nodejs/node-gyp/issues/2869
65-
uses: actions/setup-python@v4
65+
uses: actions/setup-python@v5
6666
with:
67-
python-version: '3.11'
67+
python-version: "3.11"
6868

6969
- name: Install Dependencies
7070
run: |

.github/workflows/publish-packages.yaml

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

2020
steps:
21-
- uses: actions/checkout@v3
22-
with:
23-
# don't checkout a detatched HEAD
24-
ref: ${{ github.head_ref }}
25-
26-
# this is important so git log has the whole history
27-
fetch-depth: '0'
28-
29-
- name: Setup git
30-
run: |
31-
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
32-
git config --local user.name "github-actions[bot]"
33-
34-
- name: Setup Node.js
35-
uses: actions/setup-node@v3
36-
with:
37-
node-version: 20.x
38-
cache: 'npm'
39-
40-
- name: Install npm
41-
run: npm install -g npm@8
42-
43-
- name: Install Dependencies
44-
run: |
45-
npm run bootstrap-ci
46-
shell: bash
47-
48-
- name: "Publish what is not already in NPM"
49-
env:
50-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
51-
run: |
52-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
53-
git update-index --assume-unchanged .npmrc
54-
npm run publish-packages
55-
56-
- name: "Publish tags"
57-
run: |
58-
npx lerna list -a --json | \
59-
jq -r '.[] | .name + "@" + .version' | \
60-
xargs -i sh -c "git tag -a {} -m {} || true"
61-
git push --follow-tags
62-
21+
- uses: actions/create-github-app-token@v1
22+
id: app-token
23+
with:
24+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
25+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
# don't checkout a detatched HEAD
30+
ref: ${{ github.head_ref }}
31+
32+
# this is important so git log has the whole history
33+
fetch-depth: "0"
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 20.x
39+
cache: "npm"
40+
41+
- name: Install npm
42+
run: npm install -g npm@8
43+
44+
- name: Install Dependencies
45+
run: |
46+
npm run bootstrap-ci
47+
shell: bash
48+
49+
- name: "Publish what is not already in NPM"
50+
env:
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
run: |
53+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
54+
git update-index --assume-unchanged .npmrc
55+
npm run publish-packages
56+
57+
- name: "Publish tags"
58+
run: |
59+
npx lerna list -a --json | \
60+
jq -r '.[] | .name + "@" + .version' | \
61+
xargs -i sh -c "git tag -a {} -m {} || true"
62+
git push --follow-tags

.github/workflows/update-cidrs.yaml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ jobs:
1111
name: Update automatically generated files
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
14+
- uses: actions/create-github-app-token@v1
15+
id: app-token
1616
with:
17-
node-version: ^18.x
18-
cache: 'npm'
17+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
18+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
1919

20-
- name: Install npm@8
21-
run: |
22-
npm install -g npm@8
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: ^20.x
25+
cache: "npm"
2326

2427
- name: Install Dependencies
2528
run: |
@@ -31,22 +34,8 @@ jobs:
3134
- name: Update cidrs.json
3235
run: npm run -w packages/mongodb-cloud-info update-cidrs
3336

34-
- name: Create Pull Request
35-
id: cpr
36-
uses: peter-evans/create-pull-request@v6
37-
with:
38-
commit-message: Update report
39-
branch: ci/update-cidrs
40-
title: 'chore: update cidrs.json'
41-
add-paths: |
42-
resources/cidrs.json
43-
body: |
44-
- Update `cidrs.json`
45-
46-
- name: Merge PR
47-
env:
48-
PULL_REQUEST_NUMBER: ${{steps.cpr.outputs.pull-request-number}}
49-
# NOTE: we don't use a PAT so to not trigger further automation
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
- name: Commit and push
5138
run: |
52-
gh pr merge $PULL_REQUEST_NUMBER --squash --delete-branch
39+
git add resources/cidrs.json
40+
git commit --no-allow-empty -m "chore: update cidrs.json [skip ci]" || true
41+
git push

0 commit comments

Comments
 (0)