-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add auto-merge workflow quality checkpoints and troubleshooting guide #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,6 +132,41 @@ mechanical: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| severity: warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc: "Should migrate from slsa-github-generator to actions/attest-build-provenance (cannot be SHA-pinned)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # === AUTO-MERGE WORKFLOW CHECKS === | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - id: GH-23 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: "test -f .github/workflows/auto-merge-deps.yml || test -f .github/workflows/auto-merge.yml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| severity: warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc: "Auto-merge workflow should exist for Dependabot/Renovate PRs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
CybotTM marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - id: GH-24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: .github/workflows/auto-merge-deps.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: 'on:\s*\n\s*pull_request_target:' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| severity: error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc: "Auto-merge workflow must use pull_request_target trigger (not pull_request) for bot PR write permissions" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - id: GH-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: .github/workflows/auto-merge-deps.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: 'github\.event\.pull_request\.user\.login' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| severity: warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc: "Auto-merge should check github.event.pull_request.user.login (not github.actor which changes on reruns)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - id: GH-26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: .github/workflows/auto-merge-deps.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: '--auto' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| severity: warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| desc: "Auto-merge should use gh pr merge --auto (not direct merge) to respect branch protection and merge queues" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - id: GH-27 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: .github/workflows/auto-merge-deps.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+144
to
+165
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: .github/workflows/auto-merge-deps.yml | |
| pattern: 'on:\s*\n\s*pull_request_target:' | |
| severity: error | |
| desc: "Auto-merge workflow must use pull_request_target trigger (not pull_request) for bot PR write permissions" | |
| - id: GH-25 | |
| type: regex | |
| target: .github/workflows/auto-merge-deps.yml | |
| pattern: 'github\.event\.pull_request\.user\.login' | |
| severity: warning | |
| desc: "Auto-merge should check github.event.pull_request.user.login (not github.actor which changes on reruns)" | |
| - id: GH-26 | |
| type: regex | |
| target: .github/workflows/auto-merge-deps.yml | |
| pattern: '--auto' | |
| severity: warning | |
| desc: "Auto-merge should use gh pr merge --auto (not direct merge) to respect branch protection and merge queues" | |
| - id: GH-27 | |
| type: regex | |
| target: .github/workflows/auto-merge-deps.yml | |
| target: .github/workflows/auto-merge*.yml | |
| pattern: 'on:\s*\n\s*pull_request_target:' | |
| severity: error | |
| desc: "Auto-merge workflow must use pull_request_target trigger (not pull_request) for bot PR write permissions" | |
| - id: GH-25 | |
| type: regex | |
| target: .github/workflows/auto-merge*.yml | |
| pattern: 'github\.event\.pull_request\.user\.login' | |
| severity: warning | |
| desc: "Auto-merge should check github.event.pull_request.user.login (not github.actor which changes on reruns)" | |
| - id: GH-26 | |
| type: regex | |
| target: .github/workflows/auto-merge*.yml | |
| pattern: '--auto' | |
| severity: warning | |
| desc: "Auto-merge should use gh pr merge --auto (not direct merge) to respect branch protection and merge queues" | |
| - id: GH-27 | |
| type: regex | |
| target: .github/workflows/auto-merge*.yml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,6 +236,53 @@ gh pr merge NUMBER --repo OWNER/REPO --auto --merge | |
| - `platformAutomerge: true` - Renovate enables auto-merge (uses bypass permissions) | ||
| - `lockFileMaintenance` - Handles lock file updates via PR (not direct push) | ||
|
|
||
| ## Canonical Auto-merge Workflow Template | ||
|
|
||
| ```yaml | ||
| name: Auto-merge dependency PRs | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| auto-merge: | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| github.event.pull_request.user.login == 'dependabot[bot]' || | ||
| github.event.pull_request.user.login == 'renovate[bot]' | ||
|
CybotTM marked this conversation as resolved.
|
||
| steps: | ||
| - name: Approve PR | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: gh pr review --approve "$PR_URL" | ||
|
|
||
| - name: Enable auto-merge | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REPO: ${{ github.repository }} | ||
| run: | | ||
| STRATEGY=$(gh api "repos/$REPO" --jq ' | ||
| if .allow_squash_merge then "--squash" | ||
| elif .allow_merge_commit then "--merge" | ||
| elif .allow_rebase_merge then "--rebase" | ||
| else "--merge" end') | ||
| gh pr merge --auto "$STRATEGY" "$PR_URL" | ||
|
CybotTM marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| ### Key Design Decisions | ||
|
|
||
| - **`pull_request_target`**: Required for bot PRs — `pull_request` runs with read-only tokens for fork-like contexts | ||
| - **`user.login`**: Immutable PR author field — `github.actor` changes when humans re-run workflows | ||
| - **`--auto`**: Respects branch protection, merge queues, and required checks — direct merge bypasses these | ||
| - **Dynamic strategy**: Repos may only allow specific merge methods — hardcoding breaks when config changes | ||
|
Comment on lines
+239
to
+284
|
||
|
|
||
| ## Branch Protection for Auto-merge | ||
|
|
||
| ```bash | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change adds an “Auto-merge Setup for New Repos” section, but the PR description says to add an “Auto-merge Checklist for New Repos” plus a “Common Auto-merge Pitfalls” table placed after the existing “Auto-merge Not Working” section. Either update the PR description or add the missing/relocated content so the documentation matches what the PR claims.