Skip to content

Commit

Permalink
updated delete comment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qcoral committed Jan 27, 2025
1 parent 35d5b80 commit 87d99f6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/delete-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@ on:
jobs:
delete-comments:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Delete comments
run: |
PRS=$(gh pr list --state open --json number -q '.[].number')
set -x # Enable debug mode to see commands being run
PRS=$(gh pr list --state open --json number -q '.[].number') || { echo "Failed to list PRs"; exit 1; }
echo "Found PRs: $PRS"
for PR in $PRS; do
echo "Processing PR #$PR"
# Get all comments on the PR
COMMENTS=$(gh api /repos/${{ github.repository }}/issues/$PR/comments \
--jq '.[] | select(.body | contains("Can't wait to you build it")) | .id')
--jq '.[] | select(.body | contains("Can't wait to you")) | .id') || { echo "Failed to get comments for PR #$PR"; continue; }
echo "Found comments to delete: $COMMENTS"
# Delete each matching comment
for COMMENT_ID in $COMMENTS; do
gh api --method DELETE /repos/${{ github.repository }}/issues/comments/$COMMENT_ID
echo "Deleted comment $COMMENT_ID from PR #$PR"
echo "Attempting to delete comment $COMMENT_ID from PR #$PR"
gh api --method DELETE /repos/${{ github.repository }}/issues/comments/$COMMENT_ID || echo "Failed to delete comment $COMMENT_ID"
done
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_DEBUG: 1 # Enable GitHub CLI debugging

Version 3 of 3



0 comments on commit 87d99f6

Please sign in to comment.