feat: Add action which determines if the merge queue can be safely skipped#191
feat: Add action which determines if the merge queue can be safely skipped#191
Conversation
| shell: bash | ||
| # If any previous step failed for any reason, instead of failing the | ||
| # entire action, we catch the failure here and set the output to false. | ||
| run: echo "up-to-date=false" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
Bug: Failure handler output not captured by action
The failure handler step writes up-to-date=false to $GITHUB_OUTPUT, but it doesn't have an id. The action's output is defined to reference steps.up-to-date.outputs.up-to-date, which only captures output from the step with id: up-to-date. When previous steps fail, the failure handler's output goes nowhere, leaving the action's output empty instead of "false".
Additional Locations (1)
| const position = result.repository.pullRequest.mergeQueueEntry?.position; | ||
| if (!position) { | ||
| return core.setFailed(`Pull request #${number} is not in the merge queue.`); | ||
| } |
There was a problem hiding this comment.
Bug: Position zero incorrectly treated as not in queue
GitHub's merge queue positions are 0-indexed (first entry has position 0). The check if (!position) will be truthy when position === 0, causing the action to incorrectly fail with "not in the merge queue" for the PR that's actually first in the queue. Similarly, the bash check MERGE_QUEUE_POSITION -eq 1 won't match position 0. The !position check is a common anti-pattern when handling integers that could legitimately be zero.
This adds a new action named
check-skip-merge-queue, which can be used to determine if a pull request can safely skip the merge queue. This is based on the action inMetaMask/core.Note
Adds a composite GitHub Action that outputs whether a PR can skip the merge queue by being up-to-date with the base and first in the queue.
/.github/actions/check-skip-merge-queue/action.ymlto determine if a PR can skip the merge queue.head-ref,base-ref(defaultmain),github-token.actions/github-script@v8to:head-ref.headRefNameandmergeQueueEntry.position.pr-number,pr-branch,merge-queue-position.origin/<base-ref>is an ancestor of PR branch andmerge-queue-position == 1; sets outputup-to-date=true|false.up-to-date=falsewithout failing the action.Written by Cursor Bugbot for commit 3803243. This will update automatically on new commits. Configure here.