Skip to content

Commit 72257cb

Browse files
authored
fix(ci): merge with the App token so main gets its CI run (#46)
An auto-merge enabled with GITHUB_TOKEN merges as github-actions, and a push made that way starts no workflow, so the default branch got no CI run after it. Enable it with the App token instead, and fall back to github.token where the App token cannot be made, such as a Dependabot-triggered run in an org without the Dependabot secret.
1 parent 44ad84c commit 72257cb

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎.github/workflows/merge.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12+
# Auto-merge waits for the checks the main ruleset requires. It is enabled
13+
# with the App token because merges made with GITHUB_TOKEN do not trigger
14+
# workflows, so CI and release-please would not run on main. Where the App
15+
# token cannot be made, for example a Dependabot-triggered run in an org
16+
# without the Dependabot secret, it falls back to github.token and merges as
17+
# before.
1218
merge:
1319
if: contains(github.event.pull_request.labels.*.name, 'auto-merge')
1420
runs-on: ubuntu-latest
@@ -17,9 +23,17 @@ jobs:
1723
pull-requests: write
1824
timeout-minutes: 5
1925
steps:
26+
- name: Generate App token
27+
id: app-token
28+
continue-on-error: true
29+
uses: actions/create-github-app-token@v3
30+
with:
31+
client-id: ${{ vars.APP_CLIENT_ID }}
32+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
33+
2034
- name: Enable auto-merge
2135
env:
22-
GH_TOKEN: ${{ github.token }}
36+
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
2337
PR_URL: ${{ github.event.pull_request.html_url }}
2438
run: |
2539
gh pr review --approve "$PR_URL" || echo "PR approval skipped or failed."

0 commit comments

Comments
 (0)