Post Probe Comment #10
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 Probe Comment | |
| on: | |
| workflow_run: | |
| workflows: ["Probe"] | |
| types: [completed] | |
| jobs: | |
| comment: | |
| name: Post PR Comment | |
| if: > | |
| github.event.workflow_run.event == 'pull_request' && | |
| github.event.workflow_run.conclusion != 'cancelled' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Check artifact exists | |
| id: check | |
| run: | | |
| ARTIFACTS=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts --jq '.artifacts[] | select(.name == "probe-pr-comment") | .id') | |
| if [ -z "$ARTIFACTS" ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No probe-pr-comment artifact found — skipping comment." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download artifact | |
| if: steps.check.outputs.skip == 'false' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: probe-pr-comment | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Post or update comment | |
| if: steps.check.outputs.skip == 'false' | |
| run: | | |
| PR_NUMBER=$(cat pr-number.txt) | |
| COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments \ | |
| --jq '.[] | select(.body | contains("<!-- http11probe-results -->")) | .id' | head -1) | |
| if [ -n "$COMMENT_ID" ]; then | |
| gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID \ | |
| -X PATCH -f body="$(cat probe-comment.md)" | |
| else | |
| gh pr comment "$PR_NUMBER" --body-file probe-comment.md --repo "${{ github.repository }}" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |