File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 14
14
- uses : actions/checkout@v4
15
15
- name : Check and Add label
16
16
run : |
17
- LABELS=$(gh issue view ${{ github.event.issue.number }} --json labels -q '.labels[].name')
18
- if [[ $LABELS != *"needs review"* ]]; then
19
- gh issue edit ${{ github.event.issue.number }} --add-label "needs review"
17
+ # The cryptic head -c -1 is because otherwise gh always terminates output with a newline
18
+ readarray -d $'\0' lifecycles < <(gh issue view ${{ github.event.issue.number }} --json labels -q '[.labels[] | .name | select(startswith("lifecycle/"))] | join("\u0000")' | head -c -1)
19
+ if [[ ${#lifecycles[@]} -ne 1 ]]; then
20
+ if [[ ${#lifecycles[@]} -ge 1 ]]; then
21
+ echo 'Too many lifecycle labels; replacing all with `lifecycle/needs review`'
22
+ fi
23
+ commands=()
24
+ for label in "${lifecycles[@]}"; do
25
+ if [[ "$label" != "lifecycle/needs review" ]]; then
26
+ echo "Removing label ${label}"
27
+ commands+=("--remove-label" "${label}")
28
+ fi
29
+ done
30
+ echo 'Adding `lifecycle/needs review`'
31
+ commands+=("--add-label" "lifecycle/needs review")
32
+ gh issue edit ${{ github.event.issue.number }} "${commands[@]}"
20
33
fi
21
34
env :
22
35
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments