File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -304,10 +304,39 @@ jobs:
304304 exit 1
305305 fi
306306
307+ # Type, priority and workflow are mutually exclusive, so a re-triage has to
308+ # retire the previous verdict. Components are additive and left alone.
309+ gh issue view "$ISSUE" --json labels --jq '.labels[].name' > current.txt
310+ new_type="$(jq -r '.type' <<< "$json")"
311+ new_priority="$(jq -r '.priority' <<< "$json")"
312+ new_workflow="$(jq -r '.workflow // empty' <<< "$json")"
313+
314+ stale=()
315+ while IFS= read -r label; do
316+ case "$label" in
317+ bug|enhancement|question)
318+ if [ "$label" != "$new_type" ]; then stale+=("$label"); fi ;;
319+ P0|P1|P2|P3)
320+ if [ "$label" != "$new_priority" ]; then stale+=("$label"); fi ;;
321+ "needs confirmation"|"needs repro"|"ready for work")
322+ if [ -n "$new_workflow" ] && [ "$label" != "$new_workflow" ]; then
323+ stale+=("$label")
324+ fi ;;
325+ esac
326+ done < current.txt
327+
307328 args=()
308329 for label in "${valid[@]}"; do
309330 args+=(--add-label "$label")
310331 done
332+ for label in ${stale[@]+"${stale[@]}"}; do
333+ args+=(--remove-label "$label")
334+ done
311335 gh issue edit "$ISSUE" "${args[@]}"
312336
313- echo "Labeled #$ISSUE: ${valid[*]}" >> "$GITHUB_STEP_SUMMARY"
337+ {
338+ echo "Labeled #$ISSUE: ${valid[*]}"
339+ if [ "${#stale[@]}" -gt 0 ]; then
340+ echo "Removed: ${stale[*]}"
341+ fi
342+ } >> "$GITHUB_STEP_SUMMARY"
You can’t perform that action at this time.
0 commit comments