Leave PR comment #51
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
| # Copyright ARDUINO SRL (https://www.arduino.cc) | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Leave PR comment | |
| on: | |
| workflow_run: | |
| workflows: ["Package, test and upload core"] | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| comment-on-pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11 | |
| with: | |
| workflow: package-core.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: comment-request | |
| if_no_artifact_found: ignore | |
| - name: Load PR number | |
| run: | | |
| echo "PR_NUM=$(cat pr_number || true)" >> $GITHUB_ENV | |
| - name: Check PR number | |
| id: check-pr | |
| uses: carpentries/actions/check-valid-pr@2e20fd5ee53b691e27455ce7ca3b16ea885140e8 # v0.15.0 | |
| with: | |
| pr: ${{ env.PR_NUM }} | |
| sha: ${{ github.event.workflow_run.head_sha }} | |
| - name: Validate PR number | |
| if: ${{ steps.check-pr.outputs.VALID != 'true' }} | |
| run: | | |
| echo "::error::PR number $PR_NUM validation failed" | |
| exit 1 | |
| - name: Update PR comment | |
| if: ${{ steps.check-pr.outputs.VALID == 'true' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| run: | | |
| BODY="$(cat comment_body || echo '# :fire: CI failure processing logs!')" | |
| # delete existing comment, if present, then add a new one | |
| gh pr comment ${PR_NUM} --delete-last --yes || true | |
| gh pr comment ${PR_NUM} --body "${BODY}" |