Skip to content

Commit 9f0dd13

Browse files
authored
[github_actions] update PRLabelChecker workflow to pull new labels (#77)
Signed-off-by: danbugs <[email protected]>
1 parent c824f92 commit 9f0dd13

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.github/workflows/PRLabelChecker.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- name: Check for specific labels
1616
run: |
17-
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
18-
LABELS_JSON=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
19-
REQUIRED_LABELS=("chore" "ignore" "breaking-change" "enhancement" "feature" "dependencies" "bug" "security" "performance" "refactor" "testing" "documentation" "github-actions")
20-
for REQUIRED_LABEL in "${REQUIRED_LABELS[@]}"; do
21-
if echo "$LABELS_JSON" | grep -q "$REQUIRED_LABEL"; then
22-
echo "One of the required labels is present"
17+
# Fetch repository labels from the GitHub API
18+
REPO_LABELS=$(gh api repos/${{ github.repository }}/labels --jq '.[].name')
19+
20+
# Fetch labels applied to the current PR
21+
PR_NUMBER=${{ github.event.pull_request.number }}
22+
PR_LABELS=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
23+
24+
# Check if any PR label matches a repository label
25+
for PR_LABEL in $PR_LABELS; do
26+
if echo "$REPO_LABELS" | grep -qw "$PR_LABEL"; then
27+
echo "Label '$PR_LABEL' matches a repository label."
2328
exit 0
2429
fi
2530
done
26-
echo "None of the required labels are present"
31+
32+
echo "None of the PR labels match repository labels."
2733
exit 1
2834
env:
29-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)