Skip to content

Enforce milestone requirement for PRs targeting the 2.x branch#4223

Closed
ramanathan1504 wants to merge 2 commits into
2.xfrom
require-milestone
Closed

Enforce milestone requirement for PRs targeting the 2.x branch#4223
ramanathan1504 wants to merge 2 commits into
2.xfrom
require-milestone

Conversation

@ramanathan1504

Copy link
Copy Markdown
Contributor

This PR blocks Pull Requests from being merged into the 2.x branch unless they have a valid milestone assigned. This ensures proper release tracking.

What this does:

  • Adds a GitHub Action: Checks that a milestone is attached, it starts with 2., and it is currently open in the repository.
  • Updates .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.5 or 2.x) to the PR. The check will instantly turn green and unlock the merge button.

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
@ramanathan1504
ramanathan1504 deleted the require-milestone branch July 26, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants