Skip to content

Commit

Permalink
Comment after workflow is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Oct 29, 2023
1 parent c53d3a0 commit afdbac0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Comment pull request

on:
workflow_run:
workflows: ["Benchmark Suite"]
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/download-artifact@v3
with:
name: pr
path: ./var/phpbench/pr-id.txt

- name: save PR id
id: pr
run: |
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v3
with:
name: phpbench
path: ./var/phpbench/summary.txt

- name: Get Benchmarks Output
id: get-benchmarks
run: |
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$(cat ./var/phpbench/summary.txt)" >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: "Find Comment"
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ steps.pr.outputs.id }}
comment-author: 'github-actions[bot]'
body-includes: '# Flow PHP - Benchmarks'

- name: "Create or update comment"
uses: peter-evans/create-or-update-comment@v3
with:
token: "${{ secrets.FLOW_BOT_TOKEN }}"
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.pr.outputs.id }}
body: ${{ steps.get-benchmarks.outputs.content }}
edit-mode: replace
9 changes: 9 additions & 0 deletions .github/workflows/test-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ jobs:
name: phpbench
path: ./var/phpbench/summary.txt

- name: Save PR number
run: echo ${{ github.event.pull_request.number }} > ./pr-id.txt

- name: Upload PR number
uses: actions/upload-artifact@v3
with:
name: pr
path: ./pr-id.txt

- name: "Set job summary"
run: |
echo "${{ env.COMMENT_CONTENT }}" >> $GITHUB_STEP_SUMMARY

0 comments on commit afdbac0

Please sign in to comment.