Skip to content

Commit aad7989

Browse files
authored
chore(ci): use a github app to commit to main directly COMPASS-8573 (#6530)
1 parent c7bbad3 commit aad7989

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

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

+35-29
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,38 @@ jobs:
1515
env:
1616
HADRON_DISTRIBUTION: compass
1717
steps:
18-
- uses: actions/checkout@v3
18+
- name: Create Github App Token
19+
uses: actions/create-github-app-token@v1
20+
id: app-token
21+
with:
22+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
23+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
24+
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+
31+
- uses: actions/checkout@v4
1932
with:
2033
# don't checkout a detatched HEAD
2134
ref: ${{ github.head_ref }}
2235

2336
# this is important so git log can pick up on
2437
# the whole history to generate the list of AUTHORS
25-
fetch-depth: '0'
38+
fetch-depth: "0"
39+
token: ${{ steps.app-token.outputs.token }}
2640

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>'
2745
28-
- uses: actions/setup-node@v3
46+
- uses: actions/setup-node@v4
2947
with:
3048
node-version: 20.16.0
31-
cache: 'npm'
49+
cache: "npm"
3250

3351
- name: Install [email protected]
3452
run: |
@@ -40,38 +58,26 @@ jobs:
4058
npm run bootstrap-ci
4159
4260
- name: Update AUTHORS
43-
run: npm run update-authors
61+
run: |
62+
npm run update-authors
63+
git add AUTHORS \*/AUTHORS
4464
4565
- name: Update THIRD-PARTY-NOTICES.md
46-
run: npm run update-third-party-notices
66+
run: |
67+
npm run update-third-party-notices
68+
git add THIRD-PARTY-NOTICES.md
4769
4870
- name: Update Security Test Summary
4971
run: |
5072
npm run update-security-test-summary
73+
git add docs/security-test-summary.md
5174
5275
- name: Update tracking-plan.md
53-
run: npm run update-tracking-plan
54-
55-
- name: Create Pull Request
56-
id: cpr
57-
uses: peter-evans/create-pull-request@v6
58-
with:
59-
commit-message: Update report
60-
branch: ci/update-3rd-party-notices-and-authors
61-
title: 'chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary'
62-
add-paths: |
63-
THIRD-PARTY-NOTICES.md
64-
AUTHORS
65-
docs/security-test-summary.md
66-
docs/tracking-plan.md
67-
body: |
68-
- Update `AUTHORS`, `THIRD-PARTY-NOTICES`, docs/tracking-plan.md and `docs/security-test-summary.md`
76+
run: |
77+
npm run update-tracking-plan
78+
git add docs/tracking-plan.md
6979
70-
- name: Merge PR
71-
env:
72-
PULL_REQUEST_NUMBER: ${{steps.cpr.outputs.pull-request-number}}
73-
# NOTE: we don't use a PAT so to not trigger further automation
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
- name: Commit and push
7581
run: |
76-
gh pr merge $PULL_REQUEST_NUMBER --squash --delete-branch
77-
gh workflow run codeql.yml -r main
82+
git commit --no-allow-empty -m "chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary [skip actions]" || true
83+
git push

0 commit comments

Comments
 (0)