Skip to content

Commit a23cdf0

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

File tree

1 file changed

+56
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)