Skip to content

Commit d06c25b

Browse files
committed
prBuildResultComment test [skip ci]
1 parent ab43984 commit d06c25b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: pull request build result comment
2+
on:
3+
workflow_run:
4+
workflows: [build]
5+
types: [completed]
6+
jobs:
7+
success:
8+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
9+
runs-on: ubuntu-latest
10+
steps:
11+
# The pull request number isn't readily available, so get it using the
12+
# branch.
13+
- id: getPr
14+
name: get PR number
15+
run: gh pr view --repo ${{ github.repository }} ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }} --json 'number' --jq '"number=\(.number)"' >> "${GITHUB_OUTPUT}"
16+
# Get the URLs to the Windows and mac artifacts.
17+
- id: getUrls
18+
name: get URLs
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const result = {};
23+
const resp = await github.rest.actions.listWorkflowRunArtifacts({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
run_id: context.payload.workflow_run.id,
27+
});
28+
for (const artifact of resp.data.artifacts) {
29+
if (artifact.name.startsWith("osara_windows")) {
30+
result.windows = artifact.archive_download_url;
31+
} else if (artifact.name.startsWith("osara_mac")) {
32+
result.mac = artifact.archive_download_url;
33+
}
34+
}
35+
return result;
36+
- name: comment
37+
uses: thollander/actions-comment-pull-request@v3
38+
with:
39+
pr-number: ${{ steps.getPr.outputs.number }}
40+
message: |
41+
[Build succeeded!](https://github.com/jcsteh/osara/actions/runs/${{ github.event.workflow_run.id }})
42+
- [Download for Windows](${{ steps.getUrls.outputs.windows }})
43+
- [Download for Mac](${{ steps.getUrls.outputs.mac }})
44+
failure:
45+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' }}
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: comment
49+
uses: thollander/actions-comment-pull-request@v3
50+
with:
51+
pr-number:
52+
message: |
53+
[Build failed!](https://github.com/jcsteh/osara/actions/runs/${{ github.event.workflow_run.id }})

0 commit comments

Comments
 (0)