Skip to content

Commit

Permalink
Update label checker for new lifecycle labels
Browse files Browse the repository at this point in the history
Signed-off-by: Lucy Menon <[email protected]>
  • Loading branch information
syntactically authored Jan 30, 2025
1 parent e6fe869 commit ae7b6fd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/IssueLabelChecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ jobs:
- uses: actions/checkout@v4
- name: Check and Add label
run: |
LABELS=$(gh issue view ${{ github.event.issue.number }} --json labels -q '.labels[].name')
if [[ $LABELS != *"needs review"* ]]; then
gh issue edit ${{ github.event.issue.number }} --add-label "needs review"
# The cryptic head -c -1 is because otherwise gh always terminates output with a newline
readarray -d $'\0' lifecycles < <(gh issue view ${{ github.event.issue.number }} --json labels -q '[.labels[] | .name | select(startswith("lifecycle/"))] | join("\u0000")' | head -c -1)
if [[ ${#lifecycles[@]} -ne 1 ]]; then
if [[ ${#lifecycles[@]} -ge 1 ]]; then
echo 'Too many lifecycle labels; replacing all with `lifecycle/needs review`'
fi
commands=()
for label in "${lifecycles[@]}"; do
if [[ "$label" != "lifecycle/needs review" ]]; then
echo "Removing label ${label}"
commands+=("--remove-label" "${label}")
fi
done
echo 'Adding `lifecycle/needs review`'
commands+=("--add-label" "lifecycle/needs review")
gh issue edit ${{ github.event.issue.number }} "${commands[@]}"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ae7b6fd

Please sign in to comment.