Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ initial commit for a single workflow commenter bot #934

Open
wants to merge 20 commits into
base: andrew_testing
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🐛 adding find comment logic
  • Loading branch information
andrew-bierman committed May 15, 2024
commit 130ac58924d162ca6e77dd9c5e9d828260e2cc7b
45 changes: 11 additions & 34 deletions .github/workflows/comment-workflow-status.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading