-
Notifications
You must be signed in to change notification settings - Fork 3
174 lines (167 loc) · 4.76 KB
/
build_deploy.yml
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
name: build_deploy
on:
push:
branches: [ main ]
pull_request:
repository_dispatch:
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
#
# Build the Jekyll site
#
build-site:
name: Build site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey jekyll _config.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.3
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
bundle exec jekyll build
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: jekyll-site
path: _site
#
# For each document category (administrative, standard, etc.),
# build using `metanorma site generate`.
#
build-docs:
name: Build ${{ matrix.doc_type }} docs
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:latest
strategy:
matrix:
doc_type:
- administrative
- directive
- pending-publication
- public-review
- report
- specification
- standard
- advisory
- amendment
- guide
- technical-corrigendum
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma src-documents/metanorma-${{ matrix.doc_type }}.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site/${{ matrix.doc_type }}
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Metanorma generate site
if: steps.cache.outputs.cache-hit != 'true'
uses: actions-mn/build-and-publish@main
with:
destination: artifact
agree-to-terms: true
output-dir: _site/${{ matrix.doc_type }}
artifact-name: metanorma-docs-${{ matrix.doc_type }}
source-path: ./
config-file: src-documents/metanorma-${{ matrix.doc_type }}.yml
- name: Save artifacts
if: steps.cache.outputs.cache-hit == 'true'
uses: actions/upload-artifact@v4
with:
name: metanorma-docs-${{ matrix.doc_type }}
path: _site/${{ matrix.doc_type }}
#
# At the very end, integrate them all with Jekyll.
#
check-artifacts:
name: Check aggregating artifacts with site
runs-on: ubuntu-latest
needs: [build-site, build-docs]
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/src-documents/Gemfile
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download Jekyll artifacts
uses: actions/download-artifact@v4
with:
name: jekyll-site
path: _site
- name: Download all doc artifacts
uses: actions/download-artifact@v4
with:
pattern: "metanorma-docs-*"
path: _site
merge-multiple: false
- name: Fix doc artifacts paths
shell: bash
run: |
for dir in _site/metanorma-docs-*; do
mv "$dir" "${dir/metanorma-docs-}"
done
- name: Use Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.3
- name: Build Relaton index files
shell: bash
run: |
make build-relaton
- name: Debug
if: ${{ github.ref != 'refs/heads/main' }}
run: |
ls -al
ls -alR _site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
#
# Deploy to GitHub Pages
#
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: check-artifacts
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4