-
Notifications
You must be signed in to change notification settings - Fork 50
105 lines (99 loc) · 3.06 KB
/
build-test-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
name: Build, test, deploy to GitHub Pages
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch: # Can run this workflow manually from the Actions tab
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment per branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
# Build using Jekyll, and Node.js, save GitHub Pages artifact and build artifact
build:
name: Jekyll build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Ruby # See https://www.ruby-lang.org/en/downloads/branches/
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build site
run: bundle exec jekyll build
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "yarn"
check-latest: true
- name: Install dependencies
run: yarn install --immutable
- name: Generate sitemap
run: yarn run generate-sitemap
- name: Upload build artifact, ready for GitHub Pages deployment
uses: actions/upload-pages-artifact@v3
with:
path: build/
- name: Upload build artifact, ready for testing
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: build/ # the Jekyll build directory
include-hidden-files: true # Workaround https://github.com/actions/upload-artifact/issues/610
# Test the build artifact
test:
name: Test
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "yarn"
check-latest: true
- name: Install dependencies
run: yarn install --immutable
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: build/
- name: Restore testing cache
uses: actions/cache/restore@v4
with:
path: cache/
key: test-cache
- name: Test suite
run: yarn run test
- name: Save testing cache
uses: actions/cache/save@v4
if: always()
with:
path: cache/
key: test-cache
# Deploy the GitHub Pages artifact
deploy-github-pages:
name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4