-
Notifications
You must be signed in to change notification settings - Fork 7
54 lines (48 loc) · 1.77 KB
/
probe-comment.yml
File metadata and controls
54 lines (48 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 }}