Skip to content

Commit 027970e

Browse files
rparolinclaude
andcommitted
Add CI check to enforce labels and milestone on PRs
Adds a GitHub Actions workflow that blocks PRs from merging unless they have at least one label and a milestone assigned. Bot and draft PRs are exempted. This replaces the manual process of tagging PRs. Closes #1025 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 992856b commit 027970e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: "CI: Enforce label/milestone on PRs"
6+
7+
on:
8+
pull_request_target:
9+
types:
10+
- opened
11+
- edited
12+
- synchronize
13+
- labeled
14+
- unlabeled
15+
- milestoned
16+
- demilestoned
17+
18+
jobs:
19+
check-metadata:
20+
name: PR has labels and milestone
21+
if: github.repository_owner == 'nvidia'
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check for labels and milestone
25+
env:
26+
LABELS: ${{ toJson(github.event.pull_request.labels) }}
27+
MILESTONE: ${{ github.event.pull_request.milestone && github.event.pull_request.milestone.title || '' }}
28+
PR_URL: ${{ github.event.pull_request.html_url }}
29+
IS_BOT: ${{ github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]' || github.actor == 'copy-pr-bot[bot]' }}
30+
IS_DRAFT: ${{ github.event.pull_request.draft }}
31+
run: |
32+
if [ "$IS_BOT" = "true" ] || [ "$IS_DRAFT" = "true" ]; then
33+
echo "Skipping check for bot or draft PR."
34+
exit 0
35+
fi
36+
37+
LABEL_COUNT=$(echo "$LABELS" | jq 'length')
38+
ERRORS=""
39+
40+
if [ "$LABEL_COUNT" -eq 0 ]; then
41+
ERRORS="${ERRORS} - Missing labels: add at least one label to categorize this PR.\n"
42+
fi
43+
44+
if [ -z "$MILESTONE" ]; then
45+
ERRORS="${ERRORS} - Missing milestone: assign a milestone to this PR.\n"
46+
fi
47+
48+
if [ -n "$ERRORS" ]; then
49+
echo "::error::This PR is missing required metadata:"
50+
printf "$ERRORS"
51+
echo ""
52+
echo "Please update the PR at: $PR_URL"
53+
exit 1
54+
fi
55+
56+
echo "PR has $LABEL_COUNT label(s) and milestone '$MILESTONE'."

0 commit comments

Comments
 (0)