-
Notifications
You must be signed in to change notification settings - Fork 27
113 lines (98 loc) · 3.41 KB
/
deploy.yml
File metadata and controls
113 lines (98 loc) · 3.41 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Deploy to GitHub Pages
on:
workflow_run:
workflows: ["docs", "Code Coverage"]
types:
- completed
branches:
- main
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Deploy Combined Site
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Find latest successful workflow runs
id: find-runs
uses: actions/github-script@v8
with:
script: |
// Find latest successful docs run
const { data: runs } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'docs.yml',
status: 'completed',
conclusion: 'success',
branch: 'main',
per_page: 1
});
const docsRun = runs.workflow_runs[0];
// Find latest successful coverage run
const { data: coverageRuns } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'coverage.yml',
status: 'completed',
conclusion: 'success',
branch: 'main',
per_page: 1
});
const coverageRun = coverageRuns.workflow_runs[0];
if (!docsRun && !coverageRun) {
core.setFailed('No successful runs found for either workflow');
return;
}
if (docsRun) {
core.setOutput('docs-run-id', docsRun.id);
core.setOutput('has-docs', 'true');
console.log(`Found docs run: ${docsRun.id}`);
} else {
core.setOutput('has-docs', 'false');
console.log('No successful docs run found, skipping docs');
}
if (coverageRun) {
core.setOutput('coverage-run-id', coverageRun.id);
core.setOutput('has-coverage', 'true');
console.log(`Found coverage run: ${coverageRun.id}`);
} else {
core.setOutput('has-coverage', 'false');
console.log('No successful coverage run found, skipping coverage');
}
- name: Download docs artifact
if: steps.find-runs.outputs.has-docs == 'true'
uses: actions/download-artifact@v8
with:
name: docs-reports
path: ./site/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.find-runs.outputs.docs-run-id }}
continue-on-error: true
- name: Download coverage artifact
if: steps.find-runs.outputs.has-coverage == 'true'
uses: actions/download-artifact@v8
with:
name: coverage-reports
path: ./site/coverage/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.find-runs.outputs.coverage-run-id }}
continue-on-error: true
- name: Upload combined site
uses: actions/upload-pages-artifact@v4
with:
path: ./site/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5