From c1f2ddcae937864da5a2ab8552960b5c2619157a Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 29 Oct 2023 15:17:58 +0100 Subject: [PATCH 1/2] Moved commenting PR to a standalone workflow to bypass permissions limitations --- .github/workflows/pr-comment.yml | 53 ++++++++++++++++++++++++++++ .github/workflows/test-benchmark.yml | 29 ++++++--------- 2 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 000000000..ea6b65cb1 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,53 @@ +name: Pull Request Comment + +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 47dbca40b..43e8269b2 100644 --- a/.github/workflows/test-benchmark.yml +++ b/.github/workflows/test-benchmark.yml @@ -11,9 +11,6 @@ on: - 'composer.json' - 'composer.lock' -permissions: - pull-requests: write - # See https://stackoverflow.com/a/72408109 concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -75,7 +72,6 @@ jobs: id: init_comment run: | { - echo 'COMMENT_CONTENT<Results of the benchmarks from this PR are compared with the results from 1.x branch.' echo ' ' @@ -111,24 +107,21 @@ jobs: echo ' ' echo '' echo ' ' - echo EOF - } >> "$GITHUB_ENV" + } >> "./var/phpbench/summary.txt" - - name: "Find Comment" - uses: peter-evans/find-comment@v2 - id: fc + - uses: actions/upload-artifact@v3 with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: '# Flow PHP - Benchmarks' + name: phpbench + path: ./var/phpbench/summary.txt + + - name: Save PR number + run: echo ${{ github.event.pull_request.number }} > ./pr-id.txt - - name: "Create or update comment" - uses: peter-evans/create-or-update-comment@v3 + - name: Upload PR number + uses: actions/upload-artifact@v3 with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: ${{ env.COMMENT_CONTENT }} - edit-mode: replace + name: pr + path: ./pr-id.txt - name: "Set job summary" run: | From 1082b8b5cbffa573fde4cb303a04046a582e5af2 Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 29 Oct 2023 15:19:32 +0100 Subject: [PATCH 2/2] Reverd to default token --- .github/workflows/pr-comment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index ea6b65cb1..97b395825 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -46,7 +46,6 @@ jobs: - 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 }}