Skip to content

Commit

Permalink
updated workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
qcoral committed Jan 27, 2025
1 parent d84dd07 commit 35d5b80
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/comment-message.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hey!! awesome job on this asylum submission. Can't wait to you build it.
Hey!! awesome job on this asylum submission. Can't wait to see you build it.

This is just a friendly reminder to make sure your PR follows the example format, including **directory structure**:

Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Read comment message
id: read_message
run: |
MESSAGE=$(cat .github/workflows/comment-message.md)
# Properly escape the message for GitHub Actions
MESSAGE="${MESSAGE//'%'/'%25'}"
MESSAGE="${MESSAGE//$'\n'/'%0A'}"
MESSAGE="${MESSAGE//$'\r'/'%0D'}"
echo "message=$MESSAGE" >> $GITHUB_OUTPUT
- name: Comment on all open PRs
run: |
MESSAGE=$(cat .github/workflows/comment-message.md)
PRS=$(gh pr list --state open --json number -q '.[].number')
for PR in $PRS; do
gh pr comment $PR --body "${{ steps.read_message.outputs.message }}"
echo "$MESSAGE" | gh pr comment $PR --body-file -
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/delete-comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Delete PR Comments
on:
workflow_dispatch:

jobs:
delete-comments:
runs-on: ubuntu-latest
steps:
- 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/${{ github.repository }}/issues/$PR/comments \
--jq '.[] | select(.body | contains("Can't wait to you build it")) | .id')
# 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"
done
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 35d5b80

Please sign in to comment.