Skip to content

Commit 4136d68

Browse files
JoeMattclaude
andcommitted
Post build artifact links as PR comments
- Add post-artifacts job to c-cpp.yml that comments a table of artifact download links on PRs after all builds complete - Remove broken artifacts.yml (used unmaintained action on deprecated windows-2019, workflow_run trigger never fired for fork PRs) Closes #60 Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent d071e7b commit 4136d68

2 files changed

Lines changed: 61 additions & 20 deletions

File tree

.github/workflows/artifacts.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/c-cpp.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: [ master ]
88

9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
913
jobs:
1014
build:
1115
strategy:
@@ -75,3 +79,60 @@ jobs:
7579
name: ${{ matrix.config.displayTargetName }}
7680
path: ${{ matrix.config.artifact }}
7781
if-no-files-found: error
82+
83+
post-artifacts:
84+
if: github.event_name == 'pull_request'
85+
needs: build
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Comment artifact links on PR
89+
continue-on-error: true
90+
uses: actions/github-script@v7
91+
with:
92+
script: |
93+
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
94+
95+
const comments = await github.paginate(
96+
github.rest.issues.listComments,
97+
{
98+
owner: context.repo.owner,
99+
repo: context.repo.repo,
100+
issue_number: context.issue.number,
101+
per_page: 100,
102+
}
103+
);
104+
const marker = '<!-- build-artifacts -->';
105+
const existing = comments.find(c => c.body.includes(marker));
106+
107+
const body = [
108+
marker,
109+
'### Build Artifacts',
110+
'',
111+
'| Platform | Download |',
112+
'|----------|----------|',
113+
'| Linux x86_64 (GCC) | [virtualjaguar_libretro.so](' + runUrl + ') |',
114+
'| Linux x86_64 (Clang) | [virtualjaguar_libretro.so](' + runUrl + ') |',
115+
'| Linux aarch64 | [virtualjaguar_libretro.so](' + runUrl + ') |',
116+
'| macOS arm64 | [virtualjaguar_libretro.dylib](' + runUrl + ') |',
117+
'| Windows x86_64 | [virtualjaguar_libretro.dll](' + runUrl + ') |',
118+
'',
119+
'> Download artifacts from the [workflow run](' + runUrl + ').',
120+
'',
121+
`<sub>Updated by CI at ${new Date().toISOString()}</sub>`,
122+
].join('\n');
123+
124+
if (existing) {
125+
await github.rest.issues.updateComment({
126+
owner: context.repo.owner,
127+
repo: context.repo.repo,
128+
comment_id: existing.id,
129+
body,
130+
});
131+
} else {
132+
await github.rest.issues.createComment({
133+
owner: context.repo.owner,
134+
repo: context.repo.repo,
135+
issue_number: context.issue.number,
136+
body,
137+
});
138+
}

0 commit comments

Comments
 (0)