-
Notifications
You must be signed in to change notification settings - Fork 87
184 lines (161 loc) Β· 5.82 KB
/
publish-docs.yaml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: "Publish Docs"
on:
workflow_run:
workflows: ["CI"]
branches: [master]
types:
- completed
jobs:
publishing:
name: Publish Documentation
runs-on: ubuntu-latest
permissions:
contents: write
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: π₯ Checkout repository
uses: actions/checkout@v4
with:
repository: cardano-scaling/hydra
ref: release
# Also ensure we have all history with all tags
fetch-depth: 0
- name: β Prepare nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
accept-flake-config = true
log-lines = 1000
- name: Set up and use the "ci" devShell
uses: nicknovitski/nix-develop@v1
with:
arguments: ".#ci"
- name: Get released workflow run id
id: released-workflow
uses: actions/github-script@v7
with:
script: |
let res = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'ci-nix.yaml',
branch: 'release',
status: 'success'
});
return res.data.workflow_runs[0].id;
- name: Get latest workflow run id
id: latest-workflow
uses: actions/github-script@v7
with:
script: |
let res = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'ci-nix.yaml',
branch: 'master',
status: 'success'
});
return res.data.workflow_runs[0].id;
- name: π₯ Download released hydra-spec
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.released-workflow.outputs.result}}
name: hydra-spec
path: docs/static
- name: π₯ Download released benchmarks
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.released-workflow.outputs.result}}
pattern: benchmarks-*
merge-multiple: true
path: docs/benchmarks
- name: π₯ Download released test-results
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.released-workflow.outputs.result}}
pattern: test-results-*
merge-multiple: true
path: docs/benchmarks/tests
- name: π₯ Download released haddock documentation
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.released-workflow.outputs.result}}
name: haddocks
path: docs/static/haddock
- name: Build documentation
working-directory: docs
run: |
# Only warn on broken links here as the individual documentation builds
# should have failed with broken links originally.
sed -i 's|onBrokenLinks: "throw"|onBrokenLinks: "warn"|' docusaurus.config.js
yarn
yarn build
mkdir -p /tmp/public
mv build /tmp/public/head-protocol
# Clean the working copy
git clean -dxf
- name: Checkout master
working-directory: docs
run: |
git reset origin/master --hard
sed -i 's|head-protocol|head-protocol/unstable|' docusaurus.config.js
- name: π₯ Download latest hydra-spec
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.latest-workflow.outputs.result}}
name: hydra-spec
path: docs/static
- name: π₯ Download latest benchmarks
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.latest-workflow.outputs.result}}
pattern: benchmarks-*
merge-multiple: true
path: docs/benchmarks
- name: π₯ Download latest test-results
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.latest-workflow.outputs.result}}
pattern: test-results-*
merge-multiple: true
path: docs/benchmarks/tests
- name: π₯ Download latest haddock documentation
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN || github.token }}
run-id: ${{steps.latest-workflow.outputs.result}}
name: haddocks
path: docs/static/haddock
- name: Build /unstable documentation
working-directory: docs
run: |
yarn
yarn build
mv build /tmp/public/head-protocol/unstable
- name: π Create redirects
run: |
function redirect() {
echo "Creating redirect: $1 -> $2"
mkdir -p $(dirname $1)
echo "<!DOCTYPE html><html><head><meta http-equiv=\"Refresh\" content=\"0; URL=${2}\"></head></html>" > $1
}
echo "hydra.family" > /tmp/public/CNAME
redirect /tmp/public/index.html https://hydra.family/head-protocol
# Monthly reports moved to scaling website (2024-02-29)
rm -rf /tmp/public/head-protocol/monthly
redirect /tmp/public/head-protocol/monthly/index.html https://cardano-scaling.github.io/website/monthly
redirect /tmp/public/head-protocol/unstable/monthly/index.html https://cardano-scaling.github.io/website/monthly
- name: π’ Publish Documentation
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: /tmp/public
enable_jekyll: true
force_orphan: true