How to Use the merge_group Trigger in GitHub Actions
The merge_group event fires when the queue creates a temporary branch combining the base and the queued pull requests, and your required checks must listen for it.
Add merge_group to the workflow on: list so the same checks run against gh-readonly-queue/<base>/.... Without it, the queue waits forever for a check that never starts.
Steps
- Add
merge_group:to theon:block of the workflow that emits required checks. - Keep
pull_request:so PRs still get feedback before entering the queue. - Check
github.event_name == 'merge_group'if a step should behave differently in the queue.
Workflow
.github/workflows/ci.yml
on:
merge_group:
types: [checks_requested]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run test:ciRead the queue ref
Terminal
# github.ref on a merge_group run looks like:
refs/heads/gh-readonly-queue/main/pr-42-a1b2c3dGotchas
- If a required check runs only on
pull_request, the queue entry sits pending because that check is never requested for the merge group. - The merge_group ref is read-only; do not push to it from the workflow.
Related guides
How to Enable the GitHub Merge QueueTurn on the GitHub merge queue for a branch so pull requests are merged in a serialized, tested order, and wi…
How to Configure Required Status Checks With the Merge QueueSelect which status checks the GitHub merge queue must pass, and make sure every required check runs on the m…
How to Fix a Merge Queue Stuck on an Expected CheckResolve a merge queue entry that sits pending forever because a required check is listed as expected but neve…