Skip to content

Commit c0e0270

Browse files
committed
Introduce workflow_run workflow
1 parent 5256786 commit c0e0270

3 files changed

Lines changed: 57 additions & 5 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ insert_final_newline = true
1313
trim_trailing_whitespace = true
1414

1515
[{CMakeLists.txt,*.cmake,*.yml}]
16+
indent_style = space
1617
indent_size = 2
18+
insert_final_newline = true
19+
trim_trailing_whitespace = true

.github/workflows/build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ jobs:
158158
env:
159159
GH_TOKEN: ${{ github.token }}
160160
run: |
161+
python -c 'txt=open("LEGORACERS-diff.txt").read().strip(); open("LEGORACERS-diff.txt","w").write(txt);'
162+
python -c 'txt=open("GOLDP-diff.txt").read().strip(); open("GOLDP-diff.txt","w").write(txt);'
163+
161164
cat <<EOF >reccmp-pr-message.txt
162165
# reccmp report
163166
## LEGORACERS (LEGORacers.exe)
@@ -170,11 +173,9 @@ jobs:
170173
\`\`\`
171174
EOF
172175
173-
gh pr comment ${{ github.event.number }} \
174-
--repo "${{ github.repository }}" \
175-
--create-if-none \
176-
--edit-last \
177-
--body-file "reccmp-pr-message.txt"
176+
echo "${{ github.event.number }}" >pr-number.txt
177+
178+
cat reccmp-pr-message.txt
178179
179180
- name: Upload Artifact
180181
uses: actions/upload-artifact@main
@@ -184,6 +185,15 @@ jobs:
184185
LEGORACERSPROGRESS*
185186
GOLDPPROGRESS*
186187
188+
- name: Upload PR comment payload
189+
if: ${{ github.event_name == 'pull_request' && always() }}
190+
uses: actions/upload-artifact@main
191+
with:
192+
name: reccmp-pr-comment
193+
path: |
194+
reccmp-pr-message.txt
195+
pr-number.txt
196+
187197
upload:
188198
name: Upload artifacts
189199
needs: [verify]

.github/workflows/pr-comment.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Post reccmp output as PR comment
2+
3+
# Runs after the Build workflow finishes. Triggered via workflow_run so it
4+
# executes in the base-repo context with a writable token, which lets it comment
5+
# on pull requests opened from forks (those builds only get a read-only token).
6+
on:
7+
workflow_run:
8+
workflows: [Build]
9+
types: [completed]
10+
11+
jobs:
12+
comment:
13+
name: Comment reccmp report
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
16+
permissions:
17+
actions: read
18+
issues: write
19+
pull-requests: write
20+
steps:
21+
- name: Download PR comment payload
22+
id: download
23+
continue-on-error: true
24+
uses: actions/download-artifact@v8
25+
with:
26+
name: reccmp-pr-comment
27+
run-id: ${{ github.event.workflow_run.id }}
28+
github-token: ${{ github.token }}
29+
30+
- name: Post comment
31+
if: ${{ steps.download.outcome == 'success' }}
32+
env:
33+
GH_TOKEN: ${{ github.token }}
34+
run: |
35+
gh pr comment "$(cat pr-number.txt)" \
36+
--repo "${{ github.repository }}" \
37+
--create-if-none \
38+
--edit-last \
39+
--body-file reccmp-pr-message.txt

0 commit comments

Comments
 (0)