File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Benchmark
22on :
33 - pull_request
4- permissions :
5- pull-requests : write # needed to post comments
4+
5+ # No special permissions needed — the action uploads an artifact
6+ # instead of commenting directly. A separate workflow_run workflow
7+ # (post_benchmark_comment.yml) picks up the artifact and posts the comment.
8+
69jobs :
710 benchmark :
811 name : Benchmark
912 runs-on : ubuntu-latest
1013 steps :
11- - uses : MilesCranmer /AirspeedVelocity.jl@action-v1
14+ - uses : hakkelt /AirspeedVelocity.jl@main
1215 with :
1316 julia-version : ' 1'
17+ post-comment : ' false'
Original file line number Diff line number Diff line change 1+ name : Post Benchmark Comment
2+
3+ on :
4+ workflow_run :
5+ workflows : ["Benchmark"]
6+ types : [completed]
7+
8+ permissions :
9+ pull-requests : write
10+
11+ jobs :
12+ comment :
13+ if : github.event.workflow_run.conclusion == 'success'
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Download benchmark artifacts
17+ uses : actions/download-artifact@v4
18+ with :
19+ pattern : benchmark-comment-*
20+ run-id : ${{ github.event.workflow_run.id }}
21+ github-token : ${{ github.token }}
22+ path : artifacts
23+
24+ - name : Post comments
25+ env :
26+ GH_TOKEN : ${{ github.token }}
27+ run : |
28+ for dir in artifacts/benchmark-comment-*/; do
29+ [ -d "$dir" ] || continue
30+ pr=$(cat "$dir/pr_number.txt")
31+ jv=$(cat "$dir/julia_version.txt")
32+
33+ # Find existing comment by this bot for this Julia version
34+ comment_id=$(gh api \
35+ "repos/${{ github.repository }}/issues/${pr}/comments" \
36+ --paginate \
37+ --jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | contains(\"Benchmark Results (Julia v${jv})\"))) | .id" \
38+ | head -1)
39+
40+ if [ -n "$comment_id" ]; then
41+ gh api --method PATCH \
42+ "repos/${{ github.repository }}/issues/comments/${comment_id}" \
43+ -F body=@"$dir/body.md"
44+ else
45+ gh api --method POST \
46+ "repos/${{ github.repository }}/issues/${pr}/comments" \
47+ -F body=@"$dir/body.md"
48+ fi
49+ done
You can’t perform that action at this time.
0 commit comments