-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (40 loc) · 1.37 KB
/
post-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Post CI
on:
workflow_run:
workflows:
- ci
types:
- completed
jobs:
comment:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
with:
script: |
console.log(context.payload.workflow_run)
const { data: { artifacts }} = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const artifact = artifacts.find(a => a.name === "coverage");
if (artifact == null) return;
const url = `https://artifact-viewer.vercel.app/${context.repo.owner}/${context.repo.repo}/${artifact.id}/`;
const body =
`<!-- artifact-comment -->
# Artifacts
| | |
| -------- | ------ |
| Coverage | ${url} |
`;
if (context.payload.workflow_run.event === "push") {
await github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.payload.workflow_run.head_sha,
body
});
}