|
10 | 10 |
|
11 | 11 | permissions: |
12 | 12 | contents: read |
| 13 | + issues: write |
13 | 14 |
|
14 | 15 | jobs: |
15 | 16 | build: |
|
28 | 29 | run: dotnet build "${{ github.workspace }}/REPO_Shop_Items_in_Level.sln" --configuration Release |
29 | 30 |
|
30 | 31 | - name: Upload Thunderstore package |
| 32 | + id: upload_artifact |
31 | 33 | uses: actions/upload-artifact@v7.0.1 |
32 | 34 | with: |
33 | 35 | name: REPO_Shop_Items_in_Level-${{ github.sha }} |
|
36 | 38 | ${{ github.workspace }}/Thunderstore/package/** |
37 | 39 | if-no-files-found: error |
38 | 40 |
|
| 41 | + - name: Post artifact link to pull request |
| 42 | + if: github.event_name == 'pull_request' |
| 43 | + uses: actions/github-script@v9.0.0 |
| 44 | + env: |
| 45 | + ARTIFACT_NAME: REPO_Shop_Items_in_Level-${{ github.sha }} |
| 46 | + ARTIFACT_URL: ${{ steps.upload_artifact.outputs.artifact-url }} |
| 47 | + with: |
| 48 | + script: | |
| 49 | + const marker = '<!-- repo-shop-items-in-level-artifact -->'; |
| 50 | + const body = [ |
| 51 | + marker, |
| 52 | + `Build artifact for this PR: [${process.env.ARTIFACT_NAME}](${process.env.ARTIFACT_URL})`, |
| 53 | + ].join('\n'); |
| 54 | +
|
| 55 | + try { |
| 56 | + const { data: comments } = await github.rest.issues.listComments({ |
| 57 | + owner: context.repo.owner, |
| 58 | + repo: context.repo.repo, |
| 59 | + issue_number: context.issue.number, |
| 60 | + per_page: 100, |
| 61 | + }); |
| 62 | +
|
| 63 | + const existing = comments.find(comment => |
| 64 | + comment.user?.type === 'Bot' && comment.body?.includes(marker) |
| 65 | + ); |
| 66 | +
|
| 67 | + if (existing) { |
| 68 | + await github.rest.issues.updateComment({ |
| 69 | + owner: context.repo.owner, |
| 70 | + repo: context.repo.repo, |
| 71 | + comment_id: existing.id, |
| 72 | + body, |
| 73 | + }); |
| 74 | + } else { |
| 75 | + await github.rest.issues.createComment({ |
| 76 | + owner: context.repo.owner, |
| 77 | + repo: context.repo.repo, |
| 78 | + issue_number: context.issue.number, |
| 79 | + body, |
| 80 | + }); |
| 81 | + } |
| 82 | + } catch (error) { |
| 83 | + core.warning(`Unable to post PR artifact comment: ${error.message}`); |
| 84 | + } |
| 85 | +
|
39 | 86 | release: |
40 | 87 | if: startsWith(github.ref, 'refs/tags/') |
41 | 88 | needs: build |
|
0 commit comments