updated delete comment workflow #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete PR Comments | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
delete-comments: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Delete comments | ||
run: | | ||
PRS=$(gh pr list --state open --json number -q '.[].number') | ||
for PR in $PRS; do | ||
# Get all comments on the PR | ||
COMMENTS=$(gh api /repos/hackclub/asylum/issues/$PR/comments \ | ||
--jq '.[] | select(.body | contains("Can't wait to you")) | .id') | ||
# Delete each matching comment | ||
if [ -n "$COMMENTS" ]; then | ||
echo "$COMMENTS" | while IFS= read -r COMMENT_ID; do | ||
gh api --method DELETE /repos/hackclub/asylum/issues/comments/$COMMENT_ID | ||
echo "Deleted comment $COMMENT_ID from PR #$PR" | ||
done | ||
else | ||
echo "No matching comments found for PR #$PR" | ||
fi | ||
done | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||