Post PR Comment #300
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: Post PR Comment | |
| on: | |
| workflow_run: | |
| workflows: ["E2E Test Execution"] | |
| types: | |
| - completed | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: Get PR number | |
| id: pr | |
| run: | | |
| # Get PR number from workflow run | |
| PR_NUMBER=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}" | \ | |
| jq -r '.pull_requests[0].number // empty') | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "No PR associated with this workflow run" | |
| exit 0 | |
| fi | |
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| echo "Found PR #$PR_NUMBER" | |
| - name: Comment PR with test results | |
| if: steps.pr.outputs.pr_number | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const pr_number = ${{ steps.pr.outputs.pr_number }}; | |
| const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.event.workflow_run.id }}`; | |
| // Build comment | |
| const comment = `## 📊 E2E Test Results | |
| Excel summaries and screenshots are available as artifacts: | |
| - [View all artifacts](${runUrl}#artifacts) | |
| *Run ID: ${{ github.event.workflow_run.id }}*`; | |
| // Post comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr_number, | |
| body: comment | |
| }); |