-
Notifications
You must be signed in to change notification settings - Fork 646
Add merge_group trigger support to status-checks workflow #7163
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
base: main
Are you sure you want to change the base?
Conversation
|
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
…epository Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
joshblack
left a comment
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.
@copilot can you split this logic into two jobs, one that runs if it's merge queue and one that runs if it's a pull request, instead of combining into a single job
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Done! Split into two separate jobs: |
joshblack
left a comment
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.
@copilot instead of two separate jobs actually can you split these into two separate steps under the github-ui job that run conditionally based on if they are a pull request or merge queue
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Done! Refactored to a single |
.github/workflows/status-checks.yml
Outdated
| run: | | ||
| # Get the timeline event ID for the label being added | ||
| EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ | ||
| EVENT_ID=$(gh api "/repos/primer/react/issues/${{ github.event.pull_request.number }}/timeline" \ |
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.
@copilot refactor this to use $PR_NUMBER as an env variable set to this value
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.
Done! Refactored to use $PR_NUMBER as an environment variable. Commit: f71e44b
.github/workflows/status-checks.yml
Outdated
| fi | ||
| gh api -X POST "/repos/primer/react/statuses/$SHA" \ | ||
| gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ |
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.
@copilot refactor this to use $SHA as an env variable set to this value
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.
Done! Refactored to use $SHA as an environment variable. Commit: f71e44b
.github/workflows/status-checks.yml
Outdated
| -f target_url="$TARGET_URL" | ||
| gh api -X POST "/repos/primer/react/statuses/$SHA" \ | ||
| gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ |
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.
@copilot refactor this to use $SHA as an env variable set to this value
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.
Done! Refactored to use $SHA as an environment variable. Commit: f71e44b
.github/workflows/status-checks.yml
Outdated
| # Extract PR number from head_ref | ||
| # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 | ||
| PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/^refs\/heads\/gh-readonly-queue\/[^\/]*\/pr-\([0-9]*\)-.*/\1/p') | ||
| # Validate PR_NUMBER extraction | ||
| if [ -z "$PR_NUMBER" ]; then | ||
| echo "Error: Failed to extract PR number from head_ref: ${{ github.event.merge_group.head_ref }}" | ||
| exit 1 | ||
| fi | ||
| # Check if the PR has the required label | ||
| HAS_LABEL=$(gh api "/repos/primer/react/issues/$PR_NUMBER" \ | ||
| --jq '[.labels[].name] | contains(["integration-tests: skipped manually"])') | ||
| if [ "$HAS_LABEL" != "true" ]; then | ||
| echo "PR #$PR_NUMBER does not have the required label. Skipping status override." | ||
| exit 0 | ||
| fi | ||
| # Use the PR URL as the target URL | ||
| TARGET_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" |
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.
@copilot remove this, we always want this check to pass when in merge queue
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.
Done! Removed the label check for merge queue - the workflow now always passes status checks when triggered by merge_group events. Commit: f71e44b
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
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.
Pull Request Overview
This PR adds support for the merge queue feature to the status-checks workflow. When a PR with the label "integration-tests: skipped manually" enters the merge queue, this workflow will automatically override the required status checks.
Key Changes
- Added
merge_groupevent trigger to allow the workflow to run during merge queue operations - Updated job-level conditional to run for both labeled pull requests and all merge queue events
- Split the status check override logic into separate steps for pull requests and merge queue with appropriate conditionals
| merge_group: | ||
| branches: | ||
| - main | ||
| types: [checks_requested] |
Copilot
AI
Nov 10, 2025
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.
[nitpick] The types array uses bracket notation [checks_requested] while other workflows in the repository (ci.yml and reports.yml) use flow sequence notation - checks_requested for consistency. Consider changing to flow sequence notation to match the project's style.
| types: [checks_requested] | |
| types: | |
| - checks_requested |
siddharthkp
left a comment
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.
I don't fully understand this, but happy to follow your lead on this!
Closes #
The
status-checksworkflow only ran on pull request events, preventing it from overriding integration test statuses when PRs enter the merge queue.Changelog
Changed
status-checks.ymlnow triggers onmerge_groupevents (scoped tomainbranch)github-uijob with conditional steps:pull_requestmerge_group$PR_NUMBERand$SHA) for cleaner code and gets timeline event ID for the labelhead_ref(format:refs/heads/gh-readonly-queue/main/pr-{number}-{sha}), validates extraction, and always passes status checks without label verificationgithub.repositorycontext variable instead of hardcoded valueRollout strategy
Testing & Reviewing
The workflow will trigger in two scenarios:
integration-tests: skipped manuallylabel, it overrides status checksThe single job structure with conditional steps allows for shared token generation while maintaining clean separation of logic between pull request and merge queue events. Environment variables are used for better code readability and maintainability.
Merge checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.