Skip to content

Commit

Permalink
Update labeler.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
alankritdabral authored Jan 3, 2024
1 parent 83646e4 commit 830fade
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Remove existing labels
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
action: remove

- name: Run Labeler
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true

# label based on PR title
- uses: github/[email protected]
with:
Expand All @@ -25,25 +31,3 @@ jobs:
enable-versioned-regex: 0
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true

remove-unused-labels:
runs-on: ubuntu-latest
needs: labeler
steps:
- name: Get current labels
run: |
current_labels=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/labels" | \
jq -r '.[].name')
echo "Current labels: $current_labels"
- name: Remove unused labels
run: |
unused_labels="chore docs fix feature"
for label in $unused_labels; do
if [[ ! "$current_labels" =~ "$label" ]]; then
echo "Removing label: $label"
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/$label"
fi
done

0 comments on commit 830fade

Please sign in to comment.