Skip to content

Commit

Permalink
[github_actions] update PRLabelChecker workflow to pull new labels (#77)
Browse files Browse the repository at this point in the history
Signed-off-by: danbugs <danilochiarlone@gmail.com>
  • Loading branch information
danbugs authored Nov 20, 2024
1 parent c824f92 commit 9f0dd13
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/PRLabelChecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ jobs:
- uses: actions/checkout@v4
- name: Check for specific labels
run: |
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
LABELS_JSON=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
REQUIRED_LABELS=("chore" "ignore" "breaking-change" "enhancement" "feature" "dependencies" "bug" "security" "performance" "refactor" "testing" "documentation" "github-actions")
for REQUIRED_LABEL in "${REQUIRED_LABELS[@]}"; do
if echo "$LABELS_JSON" | grep -q "$REQUIRED_LABEL"; then
echo "One of the required labels is present"
# Fetch repository labels from the GitHub API
REPO_LABELS=$(gh api repos/${{ github.repository }}/labels --jq '.[].name')
# Fetch labels applied to the current PR
PR_NUMBER=${{ github.event.pull_request.number }}
PR_LABELS=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
# Check if any PR label matches a repository label
for PR_LABEL in $PR_LABELS; do
if echo "$REPO_LABELS" | grep -qw "$PR_LABEL"; then
echo "Label '$PR_LABEL' matches a repository label."
exit 0
fi
done
echo "None of the required labels are present"
echo "None of the PR labels match repository labels."
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9f0dd13

Please sign in to comment.