-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvisualize_stopping_patterns_comment.yml
More file actions
71 lines (63 loc) · 2.53 KB
/
visualize_stopping_patterns_comment.yml
File metadata and controls
71 lines (63 loc) · 2.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Post stopping pattern visualization comment
on:
workflow_run:
workflows: ["Visualize Stopping Patterns"]
types: [completed]
permissions:
actions: read
pull-requests: write
issues: write
jobs:
comment:
name: Post visualization comment
runs-on: ubuntu-latest
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: visualization-result
path: /tmp/visualize-artifacts
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Read metadata
id: meta
run: |
PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
if [ -z "$PR_NUMBER" ] && [ -s /tmp/visualize-artifacts/pr_number ]; then
PR_NUMBER=$(cat /tmp/visualize-artifacts/pr_number)
echo "::warning::pull_requests context empty, using artifact fallback"
fi
if [ -z "$PR_NUMBER" ]; then
echo "::error::Could not determine PR number"
exit 1
fi
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
if [ -s /tmp/visualize-artifacts/has_changes ]; then
echo "has_changes=$(cat /tmp/visualize-artifacts/has_changes)" >> "$GITHUB_OUTPUT"
else
echo "::warning::has_changes metadata missing or empty, defaulting to false"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find_comment
with:
issue-number: ${{ steps.meta.outputs.pr_number }}
comment-author: "github-actions[bot]"
body-includes: "<!-- station-visualizer -->"
- name: Post or update comment
if: steps.meta.outputs.has_changes == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.meta.outputs.pr_number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body-path: /tmp/visualize-artifacts/visualization_comment.md
edit-mode: replace
- name: Delete comment if no changes
if: steps.meta.outputs.has_changes == 'false' && steps.find_comment.outputs.comment-id != ''
run: gh api repos/${{ github.repository }}/issues/comments/${{ steps.find_comment.outputs.comment-id }} -X DELETE
env:
GH_TOKEN: ${{ github.token }}