forked from CalConnect/cc-admin-documents
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (159 loc) · 5.67 KB
/
docker.yml
File metadata and controls
183 lines (159 loc) · 5.67 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
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
name: docker
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Bundler install
uses: metanorma/ci/docker-gem-install@main
- name: Print Metanorma version
run: metanorma --version
# In case of cache miss, the generate MN XML step will run
# and the cache will be filled after job finishes.
# Next time it’ll be a cache hit, unless sources changed.
# See also “Upload cached Metanorma XML” step, which is important.
- name: Restore cached Metanorma XML, if any
id: cache-mn-xml
uses: actions/cache@v4
env:
cache-name: _site
with:
path: _site
# NOTE: cache key does not include current MN version,
# which means if sources did not change but it’s desirable
# to rebuild XML using a newer MN version it may be impossible to do
# without making a dummy/meaningless change in the content
# to change the hash.
#
# The proper way to address this could be pinning MN version
# somewhere and including it as part of the hash here;
# alternatively, if we really want to always use whatever MN version
# is latest, we could detect that version and include it
# as part of this key.
key: ${{ runner.os }}-mn-${{ env.cache-name }}-${{ hashFiles('sources/00*-v5/**', 'sources/xmi/**', 'sources/liquid_templates/**', 'sources/guidance/**') }}
# We can fuzzy-match latest available cache,
# instead of precise hash.
# This can speed up build in some scenarios,
# but can in theory also cause issues where XML is not updated
# after source changes.
# restore-keys: |
# ${{ runner.os }}-mn-${{ env.cache-name }}-
# ${{ runner.os }}-mn-
# ${{ runner.os }}-
- name: Generate Metanorma XML
uses: actions-mn/build-and-publish@v2
if: steps.cache-mn-xml.outputs.cache-hit != 'true'
with:
destination: artifact
artifact-name: mn
agree-to-terms: true
# In case of cache hit, we must explicitly upload the _site dir as artifact
- name: Upload cached Metanorma XML
uses: actions/upload-artifact@v4
if: steps.cache-mn-xml.outputs.cache-hit == 'true'
with:
name: mn
path: _site
if-no-files-found: error
fl-build:
runs-on: ubuntu-latest
needs: build
name: Build Firelight version
steps:
- name: Download Metanorma artifacts
uses: actions/download-artifact@v4
with:
name: mn
- name: "Firelight: create temporary Git repo"
run: |
git config --global user.email "57123902+metanorma-ci@users.noreply.github.com"
git config --global user.name "Metanorma CI"
git config --global init.defaultBranch main
git init .
- name: "Firelight: commit"
run: |
ls -Al documents/cc-0001-report-ioptest
git add documents.xml
git add **/*.pdf
git add **/*.xml
git commit -m "Commit MN XML & PDF artifacts"
- name: "Firelight: prepare config"
run: |
cat <<'EOF' >> anafero-config.json
{
"version": "0.1",
"entryPoint": "file:documents.xml",
"storeAdapters": [
"git+https://github.com/metanorma/firelight#collection-support/packages/relaton-collection-xml-store",
"git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-xml-store"
],
"contentAdapters": [
"git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-site-content"
],
"resourceLayouts": [
"git+https://github.com/metanorma/firelight#collection-support/packages/plateau-layout"
]
}
EOF
git add anafero-config.json
git commit -m "Add build config"
- name: "Firelight: generate HTML"
run: |
npx --node-options='--experimental-vm-modules' \
-y @riboseinc/anafero-cli@0.0.47 \
--target-dir dist \
--path-prefix /cc-admin-documents \
--current-rev main \
--debug
- uses: actions/upload-artifact@v4
with:
name: fl
path: dist
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: fl-cache-dump
path: cacheDump.json
deploy:
if: ${{ github.ref_name == github.event.repository.default_branch }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: fl-build
steps:
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Make dist dir
run: mkdir dist
- name: Download HTML artifacts
uses: actions/download-artifact@v4
with:
pattern: fl
path: dist
- name: List files in dist
run: ls -l dist
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4