Skip to content

Commit e2535c9

Browse files
ci: Combine both docs/coverage before uploading
1 parent 704788b commit e2535c9

3 files changed

Lines changed: 116 additions & 40 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,9 @@ jobs:
102102
--ignore "**/examples/*" \
103103
--ignore "**/target/*"
104104
105-
- name: Setup Pages
106-
if: github.ref == 'refs/heads/main'
107-
uses: actions/configure-pages@v4
108-
109-
- name: Upload to GitHub Pages
110-
if: github.ref == 'refs/heads/main'
111-
uses: actions/upload-pages-artifact@v3
112-
with:
113-
path: site/
114-
115105
- name: Upload coverage artifacts
116106
uses: actions/upload-artifact@v4
117107
with:
118108
name: coverage-reports
119-
path: site/coverage/
109+
path: site/coverage/html/
120110
retention-days: 30
121-
122-
deploy:
123-
name: Deploy to GitHub Pages
124-
runs-on: ubuntu-latest
125-
needs: coverage
126-
if: github.ref == 'refs/heads/main'
127-
128-
environment:
129-
name: github-pages
130-
url: ${{ steps.deployment.outputs.page_url }}coverage/
131-
132-
steps:
133-
- name: Deploy to GitHub Pages
134-
id: deployment
135-
uses: actions/deploy-pages@v4

.github/workflows/deploy.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
workflow_run:
5+
workflows: ["docs", "Code Coverage"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
deploy:
22+
name: Deploy Combined Site
23+
runs-on: ubuntu-latest
24+
if: github.event.workflow_run.conclusion == 'success'
25+
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
30+
steps:
31+
- name: Setup Pages
32+
uses: actions/configure-pages@v4
33+
34+
- name: Find latest successful workflow runs
35+
id: find-runs
36+
uses: actions/github-script@v7
37+
with:
38+
script: |
39+
// Find latest successful docs run
40+
const { data: runs } = await github.rest.actions.listWorkflowRuns({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
workflow_id: 'docs.yml',
44+
status: 'completed',
45+
conclusion: 'success',
46+
branch: 'main',
47+
per_page: 1
48+
});
49+
const docsRun = runs.workflow_runs[0];
50+
51+
// Find latest successful coverage run
52+
const { data: coverageRuns } = await github.rest.actions.listWorkflowRuns({
53+
owner: context.repo.owner,
54+
repo: context.repo.repo,
55+
workflow_id: 'coverage.yml',
56+
status: 'completed',
57+
conclusion: 'success',
58+
branch: 'main',
59+
per_page: 1
60+
});
61+
const coverageRun = coverageRuns.workflow_runs[0];
62+
63+
if (!docsRun && !coverageRun) {
64+
core.setFailed('No successful runs found for either workflow');
65+
return;
66+
}
67+
68+
if (docsRun) {
69+
core.setOutput('docs-run-id', docsRun.id);
70+
core.setOutput('has-docs', 'true');
71+
console.log(`Found docs run: ${docsRun.id}`);
72+
} else {
73+
core.setOutput('has-docs', 'false');
74+
console.log('No successful docs run found, skipping docs');
75+
}
76+
77+
if (coverageRun) {
78+
core.setOutput('coverage-run-id', coverageRun.id);
79+
core.setOutput('has-coverage', 'true');
80+
console.log(`Found coverage run: ${coverageRun.id}`);
81+
} else {
82+
core.setOutput('has-coverage', 'false');
83+
console.log('No successful coverage run found, skipping coverage');
84+
}
85+
86+
- name: Download docs artifact
87+
if: steps.find-runs.outputs.has-docs == 'true'
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: docs-reports
91+
path: ./site/
92+
github-token: ${{ secrets.GITHUB_TOKEN }}
93+
run-id: ${{ steps.find-runs.outputs.docs-run-id }}
94+
95+
- name: Download coverage artifact
96+
if: steps.find-runs.outputs.has-coverage == 'true'
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: coverage-reports
100+
path: ./site/coverage/
101+
github-token: ${{ secrets.GITHUB_TOKEN }}
102+
run-id: ${{ steps.find-runs.outputs.coverage-run-id }}
103+
104+
- name: Upload combined site
105+
uses: actions/upload-pages-artifact@v4
106+
with:
107+
path: ./site/
108+
109+
- name: Deploy to GitHub Pages
110+
id: deployment
111+
uses: actions/deploy-pages@v4

.github/workflows/docs.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,9 @@ jobs:
2727
chmod -c -R +rX "target/doc/" | while read line; do
2828
echo "::warning title=Invalid file permissions automatically fixed::$line"
2929
done
30-
- name: Upload Pages artifact
31-
uses: actions/upload-pages-artifact@v4
30+
- name: Upload docs artifact
31+
uses: actions/upload-artifact@v4
3232
with:
33+
name: docs-reports
3334
path: ./target/doc/
34-
35-
deploy:
36-
needs: build
37-
environment:
38-
name: github-pages
39-
url: ${{ steps.deployment.outputs.page_url }}
40-
41-
runs-on: ubuntu-latest
42-
steps:
43-
- name: Deploy to GitHub Pages
44-
id: deployment
45-
uses: actions/deploy-pages@v4
35+
retention-days: 30

0 commit comments

Comments
 (0)