1- name : Validate build & urls
2- on : [pull_request]
3- jobs :
4- build :
5- runs-on : ubuntu-latest
6- strategy :
7- matrix :
8- node-version : [12.x]
9- steps :
10- - name : Checkout repository
11- uses : actions/checkout@v2
1+ name : Build site
122
13- - name : Capture changed files
14- uses : jitterbit/get-changed-files@v1
15- id : files
16- with :
17- format : csv
18- token : ${{ secrets.GITHUB_TOKEN }}
3+ on :
4+ push :
5+ branches : [ "dev" ]
6+ pull_request :
7+ types :
8+ - opened
9+ - reopened
10+ - synchronize
11+ - closed
1912
20- - name : Cache node modules
21- uses : actions/cache@v2
22- env :
23- cache-name : cache-node-modules
24- with :
25- # npm cache files are stored in `~/.npm` on Linux/macOS
26- path : ~/.npm
27- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
28- restore-keys : |
29- ${{ runner.os }}-build-${{ env.cache-name }}-
30- ${{ runner.os }}-build-
31- ${{ runner.os }}-
13+ concurrency : preview-${{ github.ref }}
3214
33- - name : Install dependencies
34- run : npm install
15+ env :
16+ CARGO_TERM_COLOR : always
3517
36- - name : Backwards compatibility
37- run : |
38- mkdir -p dist
39- npm run babel
40-
41- - name : Build
42- run : npm run build
43-
44- - name : Validate URLs
45- # Only run this if these files were edited
46- if : contains(steps.files.outputs.added_modified, 'app/data/*.json')
47- uses : urlstechie/urlchecker-action@0.0.33
48- with :
49- # Only validate the files that were changed
50- include_files : ${{ steps.files.outputs.added_modified }}
51- sub_folder : app/data/
52- file_types : .json
53- timeout : 3
18+ jobs :
19+ build_and_deploy :
20+ runs-on : ubuntu-latest
21+ if : github.ref == 'refs/heads/dev'
22+ steps :
23+ - name : Check out repository
24+ uses : actions/checkout@v4
25+ - name : Build and deploy
26+ uses : shalzz/zola-deploy-action@v0.21.0
27+ env :
28+ PAGES_BRANCH : gh-pages
29+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30+ preview :
31+ runs-on : ubuntu-latest
32+ if : github.ref != 'refs/heads/dev'
33+ steps :
34+ - name : Checkout
35+ uses : actions/checkout@v4
36+ - name : Install and build
37+ if : github.event.action != 'closed'
38+ run : shalzz/zola-deploy-action@v0.21.0
39+ env :
40+ BUILD_ONLY : true
41+ BUILD_FLAGS : --drafts
42+ BUILD_THEMES : false
43+ CHECK_LINKS : true
44+ - name : Deploy preview
45+ uses : rossjrw/pr-preview-action@v1
46+ id : preview-step
47+ - if : steps.preview-step.outputs.deployment-action == "deploy"
48+ run : echo "Preview visible at ${{ steps.preview-step.outputs.preview-url }}"
0 commit comments