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 ffae1e8 commit 490a0bd
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/delete-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,26 @@ 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: |
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"
PRS=$(gh pr list --state open --json number -q '.[].number')
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")) | .id') || { echo "Failed to get comments for PR #$PR"; continue; }
echo "Found comments to delete: $COMMENTS"
--jq '.[] | select(.body | contains("Can't wait to you")) | .id')
# Delete each matching comment
for COMMENT_ID in $COMMENTS; do
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"
gh api --method DELETE /repos/${{ github.repository }}/issues/comments/$COMMENT_ID
echo "Deleted comment $COMMENT_ID from PR #$PR"
done
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_DEBUG: 1 # Enable GitHub CLI debugging


0 comments on commit 490a0bd

Please sign in to comment.