Skip to content

updated delete comment workflow #6

updated delete comment workflow

updated delete comment workflow #6

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')

Check failure on line 15 in .github/workflows/delete-comments.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/delete-comments.yml

Invalid workflow file

You have an error in your yaml syntax on line 15
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 }}