-
Notifications
You must be signed in to change notification settings - Fork 8
255 lines (229 loc) · 14.2 KB
/
build-website.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: build-website
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
jekyll:
runs-on: ubuntu-20.04
strategy:
matrix:
branch: [slicer-org, download-slicer-org, download-maintenance-slicer-org, deploy-download-preview, deploy-download-maintenance-preview]
include:
- branch: download-slicer-org
custom_opts: '--config _config.yml,_config_download.yml'
- branch: download-maintenance-slicer-org
custom_opts: '--config _config.yml,_config_download.yml,_config_download_maintenance.yml'
- branch: deploy-download-preview
custom_opts: '--config _config.yml,_config_download.yml,_config_netlify_deploy_download_preview.yml'
- branch: deploy-download-maintenance-preview
custom_opts: '--config _config.yml,_config_download.yml,_config_download_maintenance.yml,_config_netlify_deploy_download_maintenance_preview.yml'
env:
deploy_download_preview: ${{ matrix.branch == 'deploy-download-preview' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
deploy_download_maintenance_preview: ${{ matrix.branch == 'deploy-download-maintenance-preview' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
steps:
# See https://github.com/thollander/actions-comment-pull-request
- name: Add or update Pull Request comment including screenshot [deploy_download_preview]
if: env.deploy_download_preview == 'true'
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0
env:
MESSAGE: |
### download.slicer.org preview [branch: deploy_download_preview]
:hourglass: **IN PROGRESS**
with:
message: ${{ env.MESSAGE }}
comment_tag: deploy_download_preview
GITHUB_TOKEN: ${{ secrets.SLICERBOT_GITHUB_TOKEN }}
# See https://github.com/thollander/actions-comment-pull-request
- name: Add or update Pull Request comment including screenshot [deploy_download_maintenance_preview]
if: env.deploy_download_maintenance_preview == 'true'
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0
env:
MESSAGE: |
### download.slicer.org preview [branch: deploy_download_maintenance_preview]
:hourglass: **IN PROGRESS**
with:
message: ${{ env.MESSAGE }}
comment_tag: deploy_download_maintenance_preview
GITHUB_TOKEN: ${{ secrets.SLICERBOT_GITHUB_TOKEN }}
- name: 📂 setup
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 💎 setup ruby
uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
ruby-version: 2.7 # can change this to 2.7 or whatever version you prefer
# See https://github.com/ouzi-dev/commit-status-updater
- name: Update status check for deploy-download-preview to pending
if: env.deploy_download_preview == 'true'
uses: ouzi-dev/commit-status-updater@26588d166ff273fc4c0664517359948f7cdc9bf1 # v2.0.2
with:
name: 'netlify/deploy-download-preview'
status: 'pending'
url: https://app.netlify.com/sites/slicer-org/deploys?filter=deploy-download-preview
description: 'Deploy Preview processing.'
# See https://github.com/ouzi-dev/commit-status-updater
- name: Update status check for deploy-download-maintenance-preview to pending
if: env.deploy_download_maintenance_preview == 'true'
uses: ouzi-dev/commit-status-updater@26588d166ff273fc4c0664517359948f7cdc9bf1 # v2.0.2
with:
name: 'netlify/deploy-download-maintenance-preview'
status: 'pending'
url: https://app.netlify.com/sites/slicer-org/deploys?filter=deploy-download-maintenance-preview
description: 'Download Maintenance processing.'
# See https://github.com/marketplace/actions/jekyll-action-ts
- name: 🔨 install dependencies & build site
uses: limjh16/jekyll-action-ts@807a5f09755d777bfd3070e9505d02347844c9b2 # v2
with:
enable_cache: true
custom_opts: ${{ matrix.custom_opts }}
- name: 'Evaluate download template [release_and_nightly]'
if: env.deploy_download_preview == 'true'
uses: cuchi/jinja2-action@6d31ec73a23fdd391e21e3efce8a91a87762980d # v1.2.2
with:
template: _site/download.html
data_file: _data/template_test_data/download_release_and_nightly.json
output_file: _site/download_release_and_nightly.html
- name: 'Evaluate download template [only_release]'
if: env.deploy_download_preview == 'true'
uses: cuchi/jinja2-action@6d31ec73a23fdd391e21e3efce8a91a87762980d # v1.2.2
with:
template: _site/download.html
data_file: _data/template_test_data/download_only_release.json
output_file: _site/download_only_release.html
- name: 'Evaluate download template [only_nightly]'
if: env.deploy_download_preview == 'true'
uses: cuchi/jinja2-action@6d31ec73a23fdd391e21e3efce8a91a87762980d # v1.2.2
with:
template: _site/download.html
data_file: _data/template_test_data/download_only_nightly.json
output_file: _site/download_only_nightly.html
- name: 'Evaluate download template [incomplete_releases]'
if: env.deploy_download_preview == 'true'
uses: cuchi/jinja2-action@6d31ec73a23fdd391e21e3efce8a91a87762980d # v1.2.2
with:
template: _site/download.html
data_file: _data/template_test_data/download_incomplete_releases.json
output_file: _site/download_incomplete_releases.html
- name: 'Upload website build'
if: matrix.branch != 'deploy-download-preview'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ matrix.branch }}-website-build
path: ./_site
retention-days: 1
# See https://github.com/marketplace/actions/github-pages-action
- name: 🚀 deploy
if: |
github.ref == 'refs/heads/main' || env.deploy_download_preview == 'true' || env.deploy_download_maintenance_preview == 'true'
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
force_orphan: true
github_token: ${{ secrets.SLICERBOT_GITHUB_TOKEN }}
publish_dir: ./_site
publish_branch: ${{ matrix.branch }}
user_name: 'Slicer Bot'
user_email: '[email protected]'
# See https://github.com/ouzi-dev/commit-status-updater
- name: Update status check for deploy-download-preview
if: env.deploy_download_preview == 'true'
uses: ouzi-dev/commit-status-updater@26588d166ff273fc4c0664517359948f7cdc9bf1 # v2.0.2
with:
name: 'netlify/deploy-download-preview'
status: 'success'
url: https://deploy-download-preview--slicer-org.netlify.app/download.html
description: 'Deploy Preview ready!'
# See https://github.com/ouzi-dev/commit-status-updater
- name: Update status check for deploy-download-maintenance-preview
if: env.deploy_download_maintenance_preview == 'true'
uses: ouzi-dev/commit-status-updater@26588d166ff273fc4c0664517359948f7cdc9bf1 # v2.0.2
with:
name: 'netlify/deploy-download-maintenance-preview'
status: 'success'
url: https://deploy-download-maintenance-preview--slicer-org.netlify.app/download.html
description: 'Deploy Maintenance Preview ready!'
- name: Wait for Netlify to deploy 'deploy-download-preview' or 'deploy-download-maintenance-preview' branch
if: env.deploy_download_preview == 'true' || env.deploy_download_maintenance_preview == 'true'
run: sleep 30s
shell: bash
- name: Capture deploy-download-preview screenshot [release_and_nightly]
if: env.deploy_download_preview == 'true'
uses: ./.github/actions/screenshot-website-imgur-upload
id: capture_deploy_download_preview_release_and_nightly
with:
source_url: https://deploy-download-preview--slicer-org.netlify.app/download_release_and_nightly.html
imgur_client_id: ${{secrets.SLICER_IMGUR_CLIENT_ID}}
- name: Capture deploy-download-preview screenshot [only_release]
if: env.deploy_download_preview == 'true'
uses: ./.github/actions/screenshot-website-imgur-upload
id: capture_deploy_download_preview_only_release
with:
source_url: https://deploy-download-preview--slicer-org.netlify.app/download_only_release.html
imgur_client_id: ${{secrets.SLICER_IMGUR_CLIENT_ID}}
- name: Capture deploy-download-preview screenshot [only_nightly]
if: env.deploy_download_preview == 'true'
uses: ./.github/actions/screenshot-website-imgur-upload
id: capture_deploy_download_preview_only_nightly
with:
source_url: https://deploy-download-preview--slicer-org.netlify.app/download_only_nightly.html
imgur_client_id: ${{secrets.SLICER_IMGUR_CLIENT_ID}}
- name: Capture deploy-download-preview screenshot [incomplete_releases]
if: env.deploy_download_preview == 'true'
uses: ./.github/actions/screenshot-website-imgur-upload
id: capture_deploy_download_preview_incomplete_releases
with:
source_url: https://deploy-download-preview--slicer-org.netlify.app/download_incomplete_releases.html
imgur_client_id: ${{secrets.SLICER_IMGUR_CLIENT_ID}}
# See https://github.com/thollander/actions-comment-pull-request
- name: Add or update Pull Request comment including screenshot [deploy_download_preview]
if: env.deploy_download_preview == 'true'
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0
env:
IMG_URL_0: ${{ steps.capture_deploy_download_preview_release_and_nightly.outputs.imgur_url }}
IMG_URL_1: ${{ steps.capture_deploy_download_preview_only_release.outputs.imgur_url }}
IMG_URL_2: ${{ steps.capture_deploy_download_preview_only_nightly.outputs.imgur_url }}
IMG_URL_3: ${{ steps.capture_deploy_download_preview_incomplete_releases.outputs.imgur_url }}
MESSAGE: |
### download.slicer.org preview [branch: deploy_download_preview]
_:warning: The download preview is a static website generated using mock data [^1], is temporary and may be updated at anytime [^2]_
| Screenshot from https://deploy-download-preview--slicer-org.netlify.app/download_release_and_nightly.html | Screenshot from https://deploy-download-preview--slicer-org.netlify.app/download_only_release.html | Screenshot from https://deploy-download-preview--slicer-org.netlify.app/download_only_nightly.html |
|--|--|--|
| ![Screenshot]({0}) | ![Screenshot]({1}) | ![Screenshot]({2}) |
| Screenshot from https://deploy-download-preview--slicer-org.netlify.app/download_release_and_nightly.html |
| ![Screenshot]({3}) | | |
[^1]: See [front matter](https://jekyllrb.com/docs/front-matter/) variable `download_mock` associated with https://raw.githubusercontent.com/Slicer/slicer.org/main/download.markdown
[^2]: Due to limitation of Netlify preventing us from having multiple [deploy previews](https://docs.netlify.com/site-deploys/deploy-previews/) associated with a single pull request and the [impossibility](https://github.community/t/make-secrets-available-to-builds-of-forks/16166) of using repository secret in a workflow associated with a pull-request originating from forks, the `deploy-download-preview` site is only updated for pull request originating from this repository and will be overriden after another pull request is pushed or updated.
with:
message: ${{ format(env.MESSAGE, env.IMG_URL_0, env.IMG_URL_1, env.IMG_URL_2, env.IMG_URL_3) }}
comment_tag: deploy_download_preview
GITHUB_TOKEN: ${{ secrets.SLICERBOT_GITHUB_TOKEN }}
- name: Capture deploy-download-maintenance-preview screenshot
if: env.deploy_download_maintenance_preview == 'true'
uses: ./.github/actions/screenshot-website-imgur-upload
id: capture_deploy_download_maintenance_preview
with:
source_url: https://deploy-download-maintenance-preview--slicer-org.netlify.app/download.html
imgur_client_id: ${{secrets.SLICER_IMGUR_CLIENT_ID}}
# See https://github.com/thollander/actions-comment-pull-request
- name: Add or update Pull Request comment including screenshot [deploy_download_maintenance_preview]
if: env.deploy_download_maintenance_preview == 'true'
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0
env:
IMG_URL_0: ${{ steps.capture_deploy_download_maintenance_preview.outputs.imgur_url }}
MESSAGE: |
### download.slicer.org preview [branch: deploy_download_maintenance_preview]
_:warning: The download preview is a static website generated using mock data [^1], is temporary and may be updated at anytime [^2]_
| Screenshot from https://deploy-download-maintenance-preview--slicer-org.netlify.app/download.html |
|--|
| ![Screenshot]({0}) |
[^1]: See [front matter](https://jekyllrb.com/docs/front-matter/) variable `download_mock` associated with https://raw.githubusercontent.com/Slicer/slicer.org/main/download.markdown
[^2]: Due to limitation of Netlify preventing us from having multiple [deploy previews](https://docs.netlify.com/site-deploys/deploy-previews/) associated with a single pull request and the [impossibility](https://github.community/t/make-secrets-available-to-builds-of-forks/16166) of using repository secret in a workflow associated with a pull-request originating from forks, the `deploy-download-preview` site is only updated for pull request originating from this repository and will be overriden after another pull request is pushed or updated.
with:
message: ${{ format(env.MESSAGE, env.IMG_URL_0) }}
comment_tag: deploy_download_maintenance_preview
GITHUB_TOKEN: ${{ secrets.SLICERBOT_GITHUB_TOKEN }}