PR Comment #380
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Automatically posts comments on pull requests with messages generated by other workflows | |
| # Triggered when specified workflows complete successfully | |
| name: PR Comment | |
| on: # yamllint disable-line rule:truthy | |
| workflow_run: | |
| # NOTE: Add any workflow that needs to comment on PRs to this list | |
| workflows: | |
| - Check Config Changes | |
| - Profiling Report | |
| types: | |
| - completed | |
| # default permissions as read only | |
| permissions: read-all | |
| jobs: | |
| comment-on-pr: | |
| permissions: | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| # Only run if the triggering workflow succeeded | |
| if: github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| # Download the message artifact created by the triggering workflow | |
| - name: Download comment message | |
| id: download-artifact | |
| continue-on-error: true | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: message | |
| path: /tmp/ | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract PR number from filename | |
| if: steps.download-artifact.outcome == 'success' | |
| id: extract-pr | |
| run: | | |
| echo "message-file=$(ls /tmp/message*.txt)" >> $GITHUB_OUTPUT | |
| echo "pr-number=$(echo /tmp/message*.txt | sed -E 's/.*message-([0-9]+)\.txt/\1/')" >> $GITHUB_OUTPUT | |
| - name: Comment on PR | |
| if: steps.download-artifact.outcome == 'success' && steps.extract-pr.outputs.pr-number != '' | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| file-path: ${{ steps.extract-pr.outputs.message-file }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| pr-number: ${{ steps.extract-pr.outputs.pr-number }} | |
| reactions: eyes, rocket |