Skip to content

Commit

Permalink
workflows/eval: Clear unnecessary rebuild labels
Browse files Browse the repository at this point in the history
Previously the labels would never be removed, even if the number of
rebuilds changed
  • Loading branch information
infinisil committed Nov 30, 2024
1 parent 962a686 commit a6056d8
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/eval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,33 @@ jobs:

- name: Tagging pull request
run: |
# Get all currently set rebuild labels
gh api \
--method POST \
/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \
--input <(jq -c '{ labels: .labels }' comparison/changed-paths.json)
/repos/"$REPOSITORY"/issues/"$NUMBER"/labels \
--jq '.[].name | select(startswith("10.rebuild"))' \
| sort > before
# And the labels that should be there
jq -r '.labels[]' comparison/changed-paths.json \
| sort > after
# Remove the ones not needed anymore
while read -r toRemove; do
echo "Removing label $toRemove"
gh api \
--method DELETE \
/repos/"$REPOSITORY"/issues/"$NUMBER"/labels/"$toRemove"
done < <(comm -23 before after)
# And add the ones that aren't set already
while read -r toAdd; do
echo "Adding label $toAdd"
gh api \
--method POST \
/repos/"$REPOSITORY"/issues/"$NUMBER"/labels \
-f "labels[]=$toAdd"
done < <(comm -13 before after)
env:
GH_TOKEN: ${{ github.token }}
REPOSIORY: ${{ github.repository }}
NUMBER: ${{ github.event.number }}

0 comments on commit a6056d8

Please sign in to comment.