File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 14
14
- uses : actions/checkout@v4
15
15
- name : Ensure exactly one "kind/*" label is applied
16
16
run : |
17
- # Count the number of "kind/*" labels using GitHub API via github.event
18
- LABELS=$(echo '$ {{ toJSON( github.event.pull_request.labels) }}' | jq -r '.[].name')
19
- KIND_LABEL_COUNT=$(echo "$LABELS" | grep -c " ^kind/" || true )
17
+ # Count the number of "kind/*" labels directly from the PR labels
18
+ PR_NUMBER=$ {{ github.event.pull_request.number }}
19
+ KIND_LABEL_COUNT=$(gh pr view "$PR_NUMBER" --json labels -q '.labels.[].name' | grep -c ' ^kind/' )
20
20
21
21
if [[ "$KIND_LABEL_COUNT" -eq 1 ]]; then
22
22
echo "✅ Exactly one 'kind/*' label is applied."
25
25
echo "❌ PR must have exactly one 'kind/*' label, but found $KIND_LABEL_COUNT."
26
26
exit 1
27
27
fi
28
+ env :
29
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments