From 35d5b8058c18c91060d5124aa979c30e9d8cbf25 Mon Sep 17 00:00:00 2001 From: Alex Ren <41168529+qcoral@users.noreply.github.com> Date: Mon, 27 Jan 2025 12:03:29 -0500 Subject: [PATCH] updated workflows --- .github/workflows/comment-message.md | 2 +- .github/workflows/comment-pr.yml | 12 ++---------- .github/workflows/delete-comments.yml | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/delete-comments.yml diff --git a/.github/workflows/comment-message.md b/.github/workflows/comment-message.md index 3fd51d4..2b6b8e9 100644 --- a/.github/workflows/comment-message.md +++ b/.github/workflows/comment-message.md @@ -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**: diff --git a/.github/workflows/comment-pr.yml b/.github/workflows/comment-pr.yml index 9103716..df84a7b 100644 --- a/.github/workflows/comment-pr.yml +++ b/.github/workflows/comment-pr.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/delete-comments.yml b/.github/workflows/delete-comments.yml new file mode 100644 index 0000000..066f053 --- /dev/null +++ b/.github/workflows/delete-comments.yml @@ -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 }}