diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 000000000..93243e802 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -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=$(> $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<> $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 \ No newline at end of file diff --git a/.github/workflows/test-benchmark.yml b/.github/workflows/test-benchmark.yml index dfa53ca67..8ce8a7909 100644 --- a/.github/workflows/test-benchmark.yml +++ b/.github/workflows/test-benchmark.yml @@ -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