Skip to content

Commit bddbd54

Browse files
authored
ci: make sure PRs have a type label (#1557)
* ci: make sure PRs have a type label * ci: fetch labels at runtime
1 parent 4a66170 commit bddbd54

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
check-pr-labels:
14+
name: 'Check PR Labels'
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'pull_request'
17+
18+
steps:
19+
- name: "Check for type: label"
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
run: |
24+
# Fetch at runtime so that re-running a failed workflow
25+
# after adding a label will pick up the newly added label.
26+
LABELS=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/labels" --jq '.[].name')
27+
if echo "$LABELS" | grep -qE '^type: '; then
28+
echo "PR has a valid 'type: ' label."
29+
else
30+
echo "Error: PR must have at least one label starting with 'type: '."
31+
exit 1
32+
fi
33+
1334
smoke-test-drafter:
1435
name: 'Smoke Test for Drafter'
1536
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)