Skip to content

fix(ci): fix dependabot automerge#189

Merged
zircote merged 1 commit intomainfrom
fix/dependabot-automerge
Mar 19, 2026
Merged

fix(ci): fix dependabot automerge#189
zircote merged 1 commit intomainfrom
fix/dependabot-automerge

Conversation

@zircote
Copy link
Owner

@zircote zircote commented Mar 19, 2026

Summary

  • Switch from pull_request to pull_request_target event — dependabot PRs get read-only tokens with pull_request, causing gh pr merge --auto to silently fail
  • Added branch protection on main requiring "All Checks Pass" status check — --auto merge requires at least one required status check to function
  • Added explicit PR approval step before enabling auto-merge

All 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

  • Merge this PR
  • Close and reopen one dependabot PR to trigger pull_request_target event
  • Verify the automerge workflow runs and sets auto-merge on the PR
  • Verify PR merges automatically after CI passes

…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.
Copilot AI review requested due to automatic review settings March 19, 2026 02:43
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.93%. Comparing base (68d824b) to head (5ad9d4b).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_request to pull_request_target.
  • Add an explicit gh pr review --approve step for patch/minor updates.
  • Enable auto-merge via gh pr merge --auto --squash for 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"
@zircote zircote merged commit 9952c4d into main Mar 19, 2026
16 checks passed
@zircote zircote deleted the fix/dependabot-automerge branch March 19, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants