|
6 | 6 | pull_request: |
7 | 7 | branches: [ master ] |
8 | 8 |
|
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pull-requests: write |
| 12 | + |
9 | 13 | jobs: |
10 | 14 | build: |
11 | 15 | strategy: |
|
75 | 79 | name: ${{ matrix.config.displayTargetName }} |
76 | 80 | path: ${{ matrix.config.artifact }} |
77 | 81 | 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