Enforce milestone requirement for PRs targeting the 2.x branch#4223
Closed
ramanathan1504 wants to merge 2 commits into
Closed
Enforce milestone requirement for PRs targeting the 2.x branch#4223ramanathan1504 wants to merge 2 commits into
ramanathan1504 wants to merge 2 commits into
Conversation
Comment on lines
+27
to
+63
| name: Require Milestone | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Strictly Enforce Open 2.x Milestone | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| PR_MILESTONE="${{ github.event.pull_request.milestone.title }}" | ||
|
|
||
| # 1. VIOLENTLY BLOCK if no milestone is attached to the PR | ||
| if [ -z "$PR_MILESTONE" ]; then | ||
| echo "❌ ERROR: No milestone is attached to this PR!" | ||
| echo "You cannot merge until a milestone is assigned." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 2. VIOLENTLY BLOCK if they attached a 3.x or 1.x milestone on the 2.x branch | ||
| if [[ ! "$PR_MILESTONE" =~ ^2\. ]]; then | ||
| echo "❌ ERROR: You are merging into the '2.x' branch, but using milestone '$PR_MILESTONE'." | ||
| echo "Please use a 2.x milestone (e.g., 2.25.0)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 3. Fetch all currently OPEN milestones in the repository | ||
| OPEN_MILESTONES=$(gh api repos/${{ github.repository }}/milestones -f state=open -q '.[].title') | ||
|
|
||
| # 4. VIOLENTLY BLOCK if the milestone hasn't been created yet by a PMC member (or is closed) | ||
| if echo "$OPEN_MILESTONES" | grep -Fxq "$PR_MILESTONE"; then | ||
| echo "✅ SUCCESS: Milestone '$PR_MILESTONE' is attached and currently open." | ||
| exit 0 | ||
| else | ||
| echo "❌ ERROR: The milestone '$PR_MILESTONE' DOES NOT EXIST or is CLOSED." | ||
| echo "Merge is blocked. A PMC member must create this milestone in GitHub before you can merge." | ||
| echo "Currently open milestones are:" | ||
| echo "$OPEN_MILESTONES" | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR blocks Pull Requests from being merged into the
2.xbranch unless they have a valid milestone assigned. This ensures proper release tracking.What this does:
2., and it is currently open in the repository..asf.yaml: Makes this check mandatory and locks the merge button for everyone (including Committers and PMC members) if it fails.How to merge after this PR:
The merge button will be disabled by default. A Committer just needs to attach an open 2.x milestone (like
2.25.5or2.x) to the PR. The check will instantly turn green and unlock the merge button.