Skip to content

Commit

Permalink
Reverted pull-requests to issues write permissions (#664)
Browse files Browse the repository at this point in the history
* Moved commenting PR to a standalone workflow to bypass permissions limitations

* Reverd to default token
  • Loading branch information
norberttech authored Oct 29, 2023
1 parent bd92b37 commit 5adc19f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 18 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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=$(<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:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.pr.outputs.id }}
body: ${{ steps.get-benchmarks.outputs.content }}
edit-mode: replace
29 changes: 11 additions & 18 deletions .github/workflows/test-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -75,7 +72,6 @@ jobs:
id: init_comment
run: |
{
echo 'COMMENT_CONTENT<<EOF'
echo '# Flow PHP - Benchmarks'
echo '<sup><sub>Results of the benchmarks from this PR are compared with the results from 1.x branch.</sub></sup>'
echo ' '
Expand Down Expand Up @@ -111,24 +107,21 @@ jobs:
echo ' '
echo '</details>'
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: |
Expand Down

0 comments on commit 5adc19f

Please sign in to comment.