Skip to content

Commit

Permalink
🐛 adding find comment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bierman committed May 15, 2024
1 parent 2dc533a commit 130ac58
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions .github/workflows/comment-workflow-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 130ac58

Please sign in to comment.