···168 run: |
169 # Get the latest eval.yml workflow run for the PR's base commit
170 if ! run=$(gh api --method GET /repos/"$REPOSITORY"/actions/workflows/eval.yml/runs \
171- -f head_sha="$BASE_SHA" \
172 --jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \
173 || [[ -z "$run" ]]; then
174 echo "Could not find an eval.yml workflow run for $BASE_SHA, cannot make comparison"
···237238 - name: Tagging pull request
239 run: |
0240 gh api \
241- --method POST \
242- /repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \
243- --input <(jq -c '{ labels: .labels }' comparison/changed-paths.json)
000000000000000000000244 env:
245 GH_TOKEN: ${{ github.token }}
00
···168 run: |
169 # Get the latest eval.yml workflow run for the PR's base commit
170 if ! run=$(gh api --method GET /repos/"$REPOSITORY"/actions/workflows/eval.yml/runs \
171+ -f head_sha="$BASE_SHA" -f event=push \
172 --jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \
173 || [[ -z "$run" ]]; then
174 echo "Could not find an eval.yml workflow run for $BASE_SHA, cannot make comparison"
···237238 - name: Tagging pull request
239 run: |
240+ # Get all currently set rebuild labels
241 gh api \
242+ /repos/"$REPOSITORY"/issues/"$NUMBER"/labels \
243+ --jq '.[].name | select(startswith("10.rebuild"))' \
244+ | sort > before
245+246+ # And the labels that should be there
247+ jq -r '.labels[]' comparison/changed-paths.json \
248+ | sort > after
249+250+ # Remove the ones not needed anymore
251+ while read -r toRemove; do
252+ echo "Removing label $toRemove"
253+ gh api \
254+ --method DELETE \
255+ /repos/"$REPOSITORY"/issues/"$NUMBER"/labels/"$toRemove"
256+ done < <(comm -23 before after)
257+258+ # And add the ones that aren't set already
259+ while read -r toAdd; do
260+ echo "Adding label $toAdd"
261+ gh api \
262+ --method POST \
263+ /repos/"$REPOSITORY"/issues/"$NUMBER"/labels \
264+ -f "labels[]=$toAdd"
265+ done < <(comm -13 before after)
266 env:
267 GH_TOKEN: ${{ github.token }}
268+ REPOSITORY: ${{ github.repository }}
269+ NUMBER: ${{ github.event.number }}