Leave a comment #33
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
| name: Leave a comment | |
| on: | |
| workflow_run: | |
| workflows: ['Generate and Compare Docs'] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: write | |
| jobs: | |
| aggregate: | |
| name: Aggregate Comparison Results | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 | |
| with: | |
| egress-policy: audit | |
| - name: Download all comparison artifacts | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| path: results | |
| - name: Combine results | |
| id: combine | |
| # Even if the cat fails (no files found), we don't want to fail the workflow | |
| continue-on-error: true | |
| run: | | |
| { | |
| echo "combined<<EOF" | |
| cat results/*/comparison.txt | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Add Comment to PR | |
| if: steps.combine.outputs.combined | |
| uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 | |
| with: | |
| comment-tag: compared | |
| message: ${{ steps.combine.outputs.combined }} | |
| pr-number: ${{ github.event.workflow_run.pull_requests[0].number }} |