Debian Codegraph @

.github/workflows/doc-deploy.yaml

raw
1 name: Deploy Docs
2 on:
3 workflow_run:
4 workflows: [Tests, Lint, Documentation]
5 types: [completed]
6 permissions:
7 contents: read
8 pages: write
9 id-token: write
10 actions: read
11 concurrency:
12 group: pages
13 cancel-in-progress: false
14 jobs:
15 deploy:
16 name: Deploy
17 runs-on: ubuntu-latest
18 if: github.repository == 'libmbd/libmbd'
19 environment:
20 name: github-pages
21 url: ${{ steps.deployment.outputs.page_url }}
22 steps:
23 - name: Check all CI passed
24 id: gate
25 uses: actions/github-script@v9
26 with:
27 script: |
28 const trigger = context.payload.workflow_run;
29 if (trigger.event !== 'push' || trigger.head_branch !== 'master') {
30 core.info(`event=${trigger.event} branch=${trigger.head_branch} - skipping`);
31 core.setOutput('ok', 'false');
32 return;
33 }
34 const sha = trigger.head_sha;
35 const required = ['Tests', 'Lint', 'Documentation'];
36 const { data: { workflow_runs } } = await github.rest.actions
37 .listWorkflowRunsForRepo({
38 owner: context.repo.owner,
39 repo: context.repo.repo,
40 head_sha: sha,
41 per_page: 100,
42 });
43 for (const name of required) {
44 const runs = workflow_runs
45 .filter(r => r.name === name)
46 .sort((a, b) => b.id - a.id);
47 const run = runs[0];
48 if (!run || run.status !== 'completed' || run.conclusion !== 'success') {
49 core.info(`${name}: ${run ? (run.conclusion ?? run.status) : 'not found'} - skipping`);
50 core.setOutput('ok', 'false');
51 return;
52 }
53 if (name === 'Documentation') core.setOutput('doc_run_id', run.id);
54 }
55 core.setOutput('ok', 'true');
56 - name: Download docs artifact
57 if: steps.gate.outputs.ok == 'true'
58 uses: actions/download-artifact@v4
59 with:
60 name: docs
61 path: doc/build
62 run-id: ${{ steps.gate.outputs.doc_run_id }}
63 github-token: ${{ secrets.GITHUB_TOKEN }}
64 - name: Upload pages artifact
65 if: steps.gate.outputs.ok == 'true'
66 uses: actions/upload-pages-artifact@v5
67 with:
68 path: doc/build
69 - name: Deploy
70 if: steps.gate.outputs.ok == 'true'
71 id: deployment
72 uses: actions/deploy-pages@v5