Skip to content

Post CI

Post CI #510

Workflow file for this run

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
});
}