-
-
Notifications
You must be signed in to change notification settings - Fork 10
73 lines (61 loc) · 1.99 KB
/
website-cd.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
name: Website Continuous Deployment
on:
push:
branches:
- main
pull_request: {}
concurrency:
# Group concurrency on workflow, then:
# - Is merge run? Group `push` events
# - Is pull request? Group `pull_request` events
group:
${{ github.workflow }}-${{ github.event_name == 'push' && github.base_ref ||
github.head_ref }}
# Run merge runs in sequence. Cancel in progress pull request runs.
cancel-in-progress: ${{ github.event_name != 'push' }}
env:
NODE_OPTIONS: --max-old-space-size=6144
WEBSITE_PACKAGE_NAME: website
WEBSITE_PACKAGE_PATH: ./build
jobs:
build:
name: Build and verify website
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
# cache: yarn
node-version-file: .nvmrc
- name: Install package dependencies
run: yarn install --immutable
- name: Build website
run: yarn build
- name: Scan for broken links
run: yarn dlx start-server-and-test serve 3000 'yarn broken-link-checker | (! grep ─BROKEN─)'
- name: Upload website package
uses: actions/upload-artifact@v3
with:
name: ${{ env.WEBSITE_PACKAGE_NAME }}
path: ${{ env.WEBSITE_PACKAGE_PATH }}
if-no-files-found: error
deploy:
name: Deploy website to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- build
runs-on: ubuntu-latest
steps:
# Necessary for JamesIves/github-pages-deploy-action
- uses: actions/checkout@v3
- name: Download website package
uses: actions/download-artifact@v3
with:
name: ${{ env.WEBSITE_PACKAGE_NAME }}
path: ${{ env.WEBSITE_PACKAGE_PATH }}
- name: Deploy website to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.WEBSITE_PACKAGE_PATH }}