diff --git a/.github/workflows/comment-workflow-status.yml b/.github/workflows/comment-workflow-status.yml index 2a5fe68b7..3a29e1b52 100644 --- a/.github/workflows/comment-workflow-status.yml +++ b/.github/workflows/comment-workflow-status.yml @@ -88,40 +88,17 @@ jobs: return { body: commentBody }; - - name: Comment on PR - if: github.event_name == 'pull_request' - uses: peter-evans/create-or-update-comment@v4 - with: - issue-number: ${{ github.event.pull_request.number }} - body: ${{ steps.create-table.outputs.body }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment on Push - if: github.event_name == 'push' - uses: actions/github-script@v6 + - name: Find or Create Comment + id: find-or-create-comment + uses: peter-evans/find-comment@v3 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { context } = require('@actions/github'); - const body = `## Workflow Status Comment\n\n${{ steps.create-table.outputs.body }}`; - await github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.run_id, - body: body - }); + issue-number: ${{ github.event.pull_request.number || github.sha }} + comment-author: 'github-actions[bot]' + body-includes: '## Workflow Status' - - name: Comment on Workflow Run - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 + - name: Create or Update Comment + uses: peter-evans/create-or-update-comment@v4 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { context } = require('@actions/github'); - const body = `## Workflow Status Comment\n\n${{ steps.create-table.outputs.body }}`; - await github.repos.createCommitComment({ - owner: context.repo.owner, - repo: context.repo.repo, - commit_sha: context.workflow_run.head_sha, - body: body - }); + comment-id: ${{ steps.find-or-create-comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number || github.sha }} + body: ${{ steps.create-table.outputs.body }}