File tree Expand file tree Collapse file tree 1 file changed +10
-21
lines changed
Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -12,29 +12,18 @@ jobs:
1212 runs-on : ubuntu-latest
1313 steps :
1414 - uses : actions/checkout@v4
15- - name : Check for specific labels
15+ - name : Ensure exactly one "kind/*" label is applied
1616 run : |
17- # ignore dependabot PRs
18- if [[ ${{ github.actor }} == "dependabot[bot]" ]]; then
19- echo "Ignoring dependabot PRs."
20- exit 0
21- fi
22- # Fetch repository labels from the GitHub API
23- REPO_LABELS=$(gh api repos/${{ github.repository }}/labels --jq '.[].name')
24-
25- # Fetch labels applied to the current PR
17+ # Count the number of "kind/*" labels directly from the PR labels
2618 PR_NUMBER=${{ github.event.pull_request.number }}
27- PR_LABELS =$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name ')
19+ KIND_LABEL_COUNT =$(gh pr view " $PR_NUMBER" --json labels -q '.labels.[].name' | grep -c '^kind/ ')
2820
29- # Check if any PR label matches a repository label
30- for PR_LABEL in $PR_LABELS; do
31- if echo "$REPO_LABELS" | grep -qw "$PR_LABEL"; then
32- echo "Label '$PR_LABEL' matches a repository label."
33- exit 0
34- fi
35- done
36-
37- echo "None of the PR labels match repository labels."
38- exit 1
21+ if [[ "$KIND_LABEL_COUNT" -eq 1 ]]; then
22+ echo "✅ Exactly one 'kind/*' label is applied."
23+ exit 0
24+ else
25+ echo "❌ PR must have exactly one 'kind/*' label, but found $KIND_LABEL_COUNT."
26+ exit 1
27+ fi
3928 env :
4029 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments