Skip to content

Commit 3c11c23

Browse files
authored
chore(ci): use a github app for the generated files credentials MONGOSH-1927 (#2280)
1 parent ce418fa commit 3c11c23

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/cron-tasks.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- main
10+
workflow_dispatch: # This should be removed once the workflow is tested and working
1011

1112
jobs:
1213
update_generated_files:
@@ -17,6 +18,18 @@ jobs:
1718
npm_config_foreground_scripts: "true"
1819
PUPPETEER_SKIP_DOWNLOAD: "true"
1920
steps:
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+
- name: Get GitHub App User ID
28+
id: get-user-id
29+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
30+
env:
31+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
32+
2033
- uses: actions/checkout@v4
2134
with:
2235
# don't checkout a detatched HEAD
@@ -25,12 +38,13 @@ jobs:
2538
# this is important so git log can pick up on
2639
# the whole history to generate the list of AUTHORS
2740
fetch-depth: "0"
28-
token: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
41+
token: ${{ steps.app-token.outputs.token }}
42+
persist-credentials: false
2943

3044
- name: Set up Git
3145
run: |
32-
git config --local user.email "[email protected]"
33-
git config --local user.name "devtoolsbot"
46+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
47+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
3448
3549
- uses: actions/setup-node@v4
3650
with:
@@ -59,8 +73,6 @@ jobs:
5973
- name: Generate Error Documentation
6074
run: |
6175
npm run generate-error-overview
62-
mv error-overview.md error-overview.rst packages/errors/generated/
63-
npm run reformat
6476
git add packages/errors/generated
6577
6678
- name: Regenerate Evergreen Config

packages/errors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"depcheck": "depcheck",
2828
"compile": "tsc -p tsconfig.json",
2929
"prepublish": "npm run compile",
30-
"generate-error-overview": "ts-node scripts/extract-errors.ts .. ../../error-overview.md ../../error-overview.rst",
30+
"generate-error-overview": "ts-node scripts/extract-errors.ts .. generated/error-overview.md generated/error-overview.rst && npm run reformat",
3131
"prettier": "prettier",
3232
"reformat": "npm run prettier -- --write . && npm run eslint --fix"
3333
},

0 commit comments

Comments
 (0)