Conversation
…pproval Two root causes prevented dependabot PRs from auto-merging: 1. Used `pull_request` event which gives dependabot a read-only GITHUB_TOKEN, so `gh pr merge --auto` silently failed (no write permissions). Fix: switch to `pull_request_target` which runs in base branch context with full token permissions. 2. No branch protection rules on main. `gh pr merge --auto` requires at least one required status check to enable auto-merge on individual PRs. Fix: added branch protection requiring "All Checks Pass" status check. Also added an explicit PR approval step before enabling auto-merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #189 +/- ##
=======================================
Coverage 94.93% 94.93%
=======================================
Files 25 25
Lines 10183 10183
=======================================
Hits 9667 9667
Misses 516 516 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Dependabot auto-merge GitHub Actions workflow to reliably enable auto-merge for Dependabot PRs by using an event context that can access write-scoped GITHUB_TOKEN, and adds an explicit approval step prior to enabling auto-merge.
Changes:
- Switch workflow trigger from
pull_requesttopull_request_target. - Add an explicit
gh pr review --approvestep for patch/minor updates. - Enable auto-merge via
gh pr merge --auto --squashfor patch/minor updates.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -14,14 +14,26 @@ jobs: | |||
| name: Auto-merge Dependabot PRs | |||
| runs-on: ubuntu-latest | |||
| if: github.actor == 'dependabot[bot]' | |||
Comment on lines
+24
to
+31
| - name: Approve PR | ||
| if: >- | ||
| steps.metadata.outputs.update-type == 'version-update:semver-patch' || | ||
| steps.metadata.outputs.update-type == 'version-update:semver-minor' | ||
| run: gh pr review --approve "$PR_URL" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Comment on lines
+25
to
37
| if: >- | ||
| steps.metadata.outputs.update-type == 'version-update:semver-patch' || | ||
| steps.metadata.outputs.update-type == 'version-update:semver-minor' | ||
| run: gh pr review --approve "$PR_URL" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Auto-merge patch and minor updates | ||
| if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' | ||
| - name: Enable auto-merge | ||
| if: >- | ||
| steps.metadata.outputs.update-type == 'version-update:semver-patch' || | ||
| steps.metadata.outputs.update-type == 'version-update:semver-minor' | ||
| run: gh pr merge --auto --squash "$PR_URL" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pull_requesttopull_request_targetevent — dependabot PRs get read-only tokens withpull_request, causinggh pr merge --autoto silently failmainrequiring "All Checks Pass" status check —--automerge requires at least one required status check to functionAll 10 pending dependabot PRs have passing CI and
autoMergeRequest: null(auto-merge was never enabled on them). After this merges, re-triggering those PRs (close/reopen or push) will activate the fixed workflow.Test plan
pull_request_targetevent