Mirrowel commited on
Commit
97aafae
·
1 Parent(s): 0dceed7

ci: Mirrobot-agent pending review clear

Browse files
.github/workflows/bot-reply.yml CHANGED
@@ -405,6 +405,34 @@ jobs:
405
  echo "$CONTEXT_DELIMITER" >> "$GITHUB_ENV"
406
  fi
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  - name: Determine Review Type and Last Reviewed SHA
409
  if: steps.context.outputs.IS_PR == 'true'
410
  id: review_type
 
405
  echo "$CONTEXT_DELIMITER" >> "$GITHUB_ENV"
406
  fi
407
 
408
+ - name: Clear pending bot review
409
+ if: steps.context.outputs.IS_PR == 'true'
410
+ env:
411
+ GH_TOKEN: ${{ steps.setup.outputs.token }}
412
+ BOT_NAMES_JSON: ${{ env.BOT_NAMES_JSON }}
413
+ run: |
414
+ pending_review_ids=$(gh api --paginate \
415
+ "/repos/${GITHUB_REPOSITORY}/pulls/${{ env.THREAD_NUMBER }}/reviews" \
416
+ | jq -r --argjson bots "$BOT_NAMES_JSON" '.[]? | select((.state // "") == "PENDING" and (((.user.login // "") as $login | $bots | index($login)))) | .id' \
417
+ | sort -u)
418
+
419
+ if [ -z "$pending_review_ids" ]; then
420
+ echo "No pending bot reviews to clear."
421
+ exit 0
422
+ fi
423
+
424
+ while IFS= read -r review_id; do
425
+ [ -z "$review_id" ] && continue
426
+ if gh api \
427
+ --method DELETE \
428
+ -H "Accept: application/vnd.github+json" \
429
+ "/repos/${GITHUB_REPOSITORY}/pulls/${{ env.THREAD_NUMBER }}/reviews/$review_id"; then
430
+ echo "Cleared pending review $review_id"
431
+ else
432
+ echo "::warning::Failed to clear pending review $review_id"
433
+ fi
434
+ done <<< "$pending_review_ids"
435
+
436
  - name: Determine Review Type and Last Reviewed SHA
437
  if: steps.context.outputs.IS_PR == 'true'
438
  id: review_type
.github/workflows/pr-review.yml CHANGED
@@ -58,6 +58,33 @@ jobs:
58
  opencode-fast-model: ${{ secrets.OPENCODE_FAST_MODEL }}
59
  custom-providers-json: ${{ secrets.CUSTOM_PROVIDERS_JSON }}
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  - name: Add reaction to PR
62
  env:
63
  GH_TOKEN: ${{ steps.setup.outputs.token }}
 
58
  opencode-fast-model: ${{ secrets.OPENCODE_FAST_MODEL }}
59
  custom-providers-json: ${{ secrets.CUSTOM_PROVIDERS_JSON }}
60
 
61
+ - name: Clear pending bot review
62
+ env:
63
+ GH_TOKEN: ${{ steps.setup.outputs.token }}
64
+ BOT_NAMES_JSON: ${{ env.BOT_NAMES_JSON }}
65
+ run: |
66
+ pending_review_ids=$(gh api --paginate \
67
+ "/repos/${GITHUB_REPOSITORY}/pulls/${{ env.PR_NUMBER }}/reviews" \
68
+ | jq -r --argjson bots "$BOT_NAMES_JSON" '.[]? | select((.state // "") == "PENDING" and (((.user.login // "") as $login | $bots | index($login)))) | .id' \
69
+ | sort -u)
70
+
71
+ if [ -z "$pending_review_ids" ]; then
72
+ echo "No pending bot reviews to clear."
73
+ exit 0
74
+ fi
75
+
76
+ while IFS= read -r review_id; do
77
+ [ -z "$review_id" ] && continue
78
+ if gh api \
79
+ --method DELETE \
80
+ -H "Accept: application/vnd.github+json" \
81
+ "/repos/${GITHUB_REPOSITORY}/pulls/${{ env.PR_NUMBER }}/reviews/$review_id"; then
82
+ echo "Cleared pending review $review_id"
83
+ else
84
+ echo "::warning::Failed to clear pending review $review_id"
85
+ fi
86
+ done <<< "$pending_review_ids"
87
+
88
  - name: Add reaction to PR
89
  env:
90
  GH_TOKEN: ${{ steps.setup.outputs.token }}