2525# tags:
2626# - 'review/*'
2727#
28+ # Examples:
29+ # git tag -a "review/abc1234" -m "Asking for review of abc1234"
30+ # or by using the lightweight approach: git tag "review/abc1234"
31+ # git push origin review/abc1234
32+ #
2833# B) Conventional commit filter — add to the `create-review` job:
2934# if: >-
3035# github.event_name == 'workflow_dispatch' ||
7176 branches:
7277 - main
7378 # --- (A) Uncomment to also trigger on review tags ---
74- # tags:
75- # - 'review/*'
79+ #tags:
80+ # - 'review/*'
7681
7782 # Trigger when review issues are closed (updates commit status)
7883 issues:
@@ -308,14 +313,16 @@ jobs:
308313 echo "✅ Commit status set to pending"
309314
310315 # Update commit status when review issue is closed.
311- # Matches review-pending (manual close) OR review-accepted (tbdflow CLI approve) .
316+ # Matches any review label to ensure commit status is always updated .
312317 on-review-closed:
313318 runs-on: ubuntu-latest
314319 if: >-
315320 github.event_name == 'issues' &&
316321 github.event.action == 'closed' &&
317322 (contains(github.event.issue.labels.*.name, 'review-pending') ||
318- contains(github.event.issue.labels.*.name, 'review-accepted'))
323+ contains(github.event.issue.labels.*.name, 'review-accepted') ||
324+ contains(github.event.issue.labels.*.name, 'review-dismissed') ||
325+ contains(github.event.issue.labels.*.name, 'invalid'))
319326 permissions:
320327 statuses: write
321328 issues: write # needs write to swap labels on close
@@ -327,6 +334,7 @@ jobs:
327334 ISSUE_BODY: ${{ github.event.issue.body }}
328335 ISSUE_TITLE: ${{ github.event.issue.title }}
329336 ISSUE_URL: ${{ github.event.issue.html_url }}
337+ ISSUE_LABELS: ${{ join(github.event.issue.labels.*.name, ',') }}
330338 REPO_FULL_NAME: ${{ github.repository }}
331339 run: |
332340 # Extract commit SHA from issue body (looks for /commit/SHA pattern)
@@ -344,14 +352,30 @@ jobs:
344352 if [ -n "$FULL_SHA" ]; then
345353 ISSUE_NUM=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$')
346354
347- # Swap labels idempotently (safe if tbdflow CLI already did this)
348- gh issue edit "$ISSUE_NUM" --repo "$REPO_FULL_NAME" --remove-label "review-pending" 2>/dev/null || true
349- gh issue edit "$ISSUE_NUM" --repo "$REPO_FULL_NAME" --add-label "review-accepted" 2>/dev/null || true
355+ # Swap labels only if no terminal label is already set
356+ # (tbdflow CLI or a human may have already set review-accepted or review-dismissed)
357+ HAS_ACCEPTED=$(echo "$ISSUE_LABELS" | grep -c "review-accepted" || true)
358+ HAS_DISMISSED=$(echo "$ISSUE_LABELS" | grep -c "review-dismissed" || true)
359+ IS_INVALID=$(echo "$ISSUE_LABELS" | grep -c "invalid" || true)
360+
361+ if [ "$HAS_ACCEPTED" -eq 0 ] && [ "$HAS_DISMISSED" -eq 0 ] && [ "$IS_INVALID" -eq 0 ]; then
362+ gh issue edit "$ISSUE_NUM" --repo "$REPO_FULL_NAME" --remove-label "review-pending" 2>/dev/null || true
363+ gh issue edit "$ISSUE_NUM" --repo "$REPO_FULL_NAME" --add-label "review-accepted" 2>/dev/null || true
364+ fi
365+
366+ # Set commit status based on review outcome
367+ if [ "$HAS_DISMISSED" -gt 0 ]; then
368+ STATUS_DESC="Review dismissed"
369+ elif [ "$IS_INVALID" -gt 0 ]; then
370+ STATUS_DESC="Invalid review"
371+ else
372+ STATUS_DESC="Non-blocking review completed ✅"
373+ fi
350374
351375 gh api "repos/$REPO_FULL_NAME/statuses/$FULL_SHA" \
352376 -f state='success' \
353377 -f context='peer-review' \
354- -f description='Non-blocking review completed ✅' \
378+ -f description="$STATUS_DESC" \
355379 -f target_url="$ISSUE_URL"
356380 echo "✅ Commit $FULL_SHA marked as reviewed"
357381 else
0 commit comments