Skip to content

Commit 96c0b35

Browse files
committed
Update issue label checker to use lifecycle/* label convention
Aligns the issue label checker with the convention used across other Hyperlight projects by using lifecycle/* prefixed labels instead of plain 'needs review'. Ensures exactly one lifecycle label is applied, replacing any extras with lifecycle/needs-review. Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 740b0f0 commit 96c0b35

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/IssueLabelChecker.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,22 @@ jobs:
1414
- uses: actions/checkout@v6
1515
- name: Check and Add label
1616
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[@]}"
2033
fi
2134
env:
2235
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)