Skip to content

Commit 902f2f6

Browse files
jpayne3506Copilot
andauthored
[backport v1.6] ci: Add merge queue enforcement workflow (#4335)
* Add merge queue enforcement workflow Agent-Logs-Url: https://github.com/Azure/azure-container-networking/sessions/ea33035b-0e79-4882-918b-7414023e1e13 Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com> * ci: correct ai work * ci: update regex and trigger --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 4a567d4 commit 902f2f6

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'Merge Queue Enforcement'
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- synchronize
8+
- ready_for_review
9+
branches:
10+
- master
11+
- release/v[0-9]*.[0-9]*
12+
merge_group:
13+
types:
14+
- checks_requested
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
merge-queue-gate:
21+
name: Merge Queue Gate
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Verify merge queue rule is active on target branch
25+
if: github.event_name == 'pull_request'
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
29+
BRANCH: ${{ github.base_ref }}
30+
run: |
31+
if [[ ! "$BRANCH" =~ ^(master|release/v[0-9]+\.[0-9]+)$ ]]; then
32+
echo "::error::Unexpected base branch name: '$BRANCH'. Expected 'master' or 'release/vX.Y'."
33+
exit 1
34+
fi
35+
RULES=$(gh api "/repos/$REPO/rules/branches/$BRANCH" \
36+
--jq '[.[] | select(.type == "merge_queue")] | length')
37+
if [[ "$RULES" -eq 0 ]]; then
38+
echo "::error::No active merge queue rule found for branch '$BRANCH'."
39+
echo "A branch ruleset with the 'merge_queue' rule must be configured."
40+
echo "Until this is fixed, direct merges into '$BRANCH' are possible."
41+
exit 1
42+
fi
43+
echo "Merge queue rule is active on '$BRANCH' – check passed."
44+
45+
- name: Confirm merge queue context
46+
if: github.event_name == 'merge_group'
47+
run: echo "Running in merge queue context – check passed."

0 commit comments

Comments
 (0)