Skip to content

Commit 8f6ac1e

Browse files
CopilotJohnDeved
andauthored
ci: comment PR artifact link
Agent-Logs-Url: https://github.com/JohnDeved/REPO_Shop_Items_in_Level/sessions/859b6feb-75b8-4a3a-b4a7-260e43cb0508 Co-authored-by: JohnDeved <24187269+JohnDeved@users.noreply.github.com>
1 parent cc31be4 commit 8f6ac1e

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
permissions:
1212
contents: read
13+
issues: write
1314

1415
jobs:
1516
build:
@@ -28,6 +29,7 @@ jobs:
2829
run: dotnet build "${{ github.workspace }}/REPO_Shop_Items_in_Level.sln" --configuration Release
2930

3031
- name: Upload Thunderstore package
32+
id: upload_artifact
3133
uses: actions/upload-artifact@v7.0.1
3234
with:
3335
name: REPO_Shop_Items_in_Level-${{ github.sha }}
@@ -36,6 +38,51 @@ jobs:
3638
${{ github.workspace }}/Thunderstore/package/**
3739
if-no-files-found: error
3840

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+
3986
release:
4087
if: startsWith(github.ref, 'refs/tags/')
4188
needs: build

0 commit comments

Comments
 (0)