-
Notifications
You must be signed in to change notification settings - Fork 5
252 lines (245 loc) · 8.99 KB
/
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
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
# This is the name of our workflow.
# Github will show it on its Website UI
name: deploy
# This configures our workflow to be triggered
# only when we push to the master branch
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
workflow_dispatch:
env:
RUBY_VERSION: "3.1.2"
BUNDLER_VERSION: "2.3.21"
# Here is where we define our jobs.
# Which means the tasks we want Github to execute
jobs:
build:
name: build
# Here we specify in whith OS we want it to run
runs-on: ubuntu-latest
# Now we define which actions will take place.
# One after another
steps:
# This is the first action. It will make sure that we have
# all the necessary files from our repo, including our custom actions
# This action here is actually from a remote repo available from Githup itself
- name: 🛎 Checkout master
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: ⚡️ Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends bats build-essential ca-certificates curl make shellcheck libgsl-dev libffi-dev minify liblapacke-dev libopenblas-dev
sudo gem install bundler:${{ env.BUNDLER_VERSION }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }} # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: ⚡️ Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: ⚡️ Setting up dependencies
continue-on-error: true
run: |
npm install
- name: Checking Jekyll configuration
run: bundle exec jekyll doctor
- name: 🔨 Build site
run: |
bundle exec jekyll build --lsi --profile
env:
JEKYLL_ENV: production
- name: Optimize
run: |
minify -r -o _site/ --html-keep-document-tags --html-keep-end-tags --html-keep-default-attrvals --html-keep-whitespace --verbose _site
- name: Cache jekyll
uses: actions/cache@v3
with:
path: "_site/"
key: ${{ runner.os }}-${{ github.sha }}
# npm run build:js
# - name: 🔨 Test calculations JS
# run: |
# npm run test
deploy:
if: github.event_name == 'push'
name: deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Use cache
uses: actions/cache@v3
with:
path: "_site/"
key: ${{ runner.os }}-${{ github.sha }}
- name: 🎉 Deploy to GitHub Pages 🎊
if: success()
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: _site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_and_deploy_azure:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
needs: build
runs-on: ubuntu-latest
name: Build and Deploy Azure
steps:
- name: Use cache
uses: actions/cache@v3
with:
path: "_site/"
key: ${{ runner.os }}-${{ github.sha }}
- name: Remove exercise images
uses: JesseTG/[email protected]
with:
path: ./_site/assets/images/exercises/
- name: Remove exercise Pdfs
uses: JesseTG/[email protected]
with:
path: ./_site/assets/pdf/
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_COAST_0BC93F003 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
skip_app_build: true
app_location: "/_site" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
JEKYLL_ENV: development
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Use cache
uses: actions/cache@v3
with:
path: "_site/"
key: ${{ runner.os }}-${{ github.sha }}
- name: ⚡️ Cache HTMLProofer
id: cache-htmlproofer
uses: actions/cache@v2
with:
path: tmp/.htmlproofer
key: ${{ runner.os }}-htmlproofer
- name: 📉 Check HTML
uses: chabad360/htmlproofer@master
with:
directory: "./_site"
# The directory to scan
arguments: |
--only-4xx
--ignore-status-codes "400,403,409,429"
--ignore-empty-alt
--ignore-urls "/bjsm.bmj.com/"
--cache '{ "timeframe": { "external": "30d" } }'
# The arguments to pass to HTMLProofer
clean:
needs: [build,deploy,test]
runs-on: ubuntu-latest
steps:
- name: Use cache
uses: actions/cache@v3
with:
path: "_site/"
key: ${{ runner.os }}-${{ github.sha }}
- name: ☁️ Cleaning up
run: bundle exec jekyll clean
close_pull_request_azure:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_COAST_0BC93F003 }}
action: "close"
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Lighthouse
uses: foo-software/lighthouse-check-action@master
with:
urls: 'https://www.motionsplan.dk/,https://www.motionsplan.dk/bmi-beregner-boern-unge-teenagere/,https://www.motionsplan.dk/skridt-pr-km-10000/,https://www.motionsplan.dk/idealvaegt/'
lighthouse_staging_azure:
name: Lighthouse report
needs: build_and_deploy_azure
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Static Web App - get preview URL
id: static_web_app_preview_url
uses: azure/CLI@v1
with:
inlineScript: |
CUSTOM_DOMAIN='calm-coast-0bc93f003.1.azurestaticapps.net'
LOCATION='westeurope'
PREVIEW_URL="https://${CUSTOM_DOMAIN/.[1-9]./-${{github.event.pull_request.number }}.$LOCATION.1.}"
echo "::set-output name=PREVIEW_URL::$PREVIEW_URL"
- name: Static Web App - wait for preview
id: static_web_app_wait_for_preview
uses: nev7n/wait_for_response@v1
with:
url: '${{ steps.static_web_app_preview_url.outputs.PREVIEW_URL }}'
responseCode: 200
timeout: 600000
interval: 1000
- name: Audit URLs using Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v8
with:
urls: |
${{ steps.static_web_app_preview_url.outputs.PREVIEW_URL }}
${{ steps.static_web_app_preview_url.outputs.PREVIEW_URL }}/idealvaegt/
configPath: ./.github/workflows/lighthousesrc.json
uploadArtifacts: true
temporaryPublicStorage: true
runs: 5
- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v5
with:
script: |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
const lighthouseOutputs = {
manifest: ${{ steps.lighthouse_audit.outputs.manifest }},
links: ${{ steps.lighthouse_audit.outputs.links }}
};
const comment = lighthouseCommentMaker({ lighthouseOutputs });
core.setOutput("comment", comment);
- name: Add Lighthouse stats as comment
id: comment_to_pr
uses: marocchino/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.format_lighthouse_score.outputs.comment }}