-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.97 KB
/
build.yaml
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
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
# use GitHub Pages to host the site's files by sourcing from the www branch
# adapted from "Using git worktree to deploy GitHub Pages"
# https://sangsoonam.github.io/2019/02/08/using-git-worktree-to-deploy-github-pages.html
- name: Git configure identity
run: |
git config user.email "[email protected]"
git config user.name "build GitHub Action by Dustin Ruetz"
# note: if ever the GitHub Actions pipeline is broken/erroring/unavailable,
# you can still deploy the site by running the individual commands below
# from the root of the repo using the terminal on your local machine
- name: Git checkout orphaned www branch
run: |
git checkout --orphan www
git reset --hard
git commit --allow-empty -m "feat: initial commit for www branch"
git checkout main
# add ./www/ directory to www branch
- name: Create Git worktree
run: |
rm -rf ./www/
git worktree add ./www/ www
- name: Install dependencies
run: npm ci
- name: Build site
run: npm run build
- name: Deploy site
run: |
cd ./www/
git add --all
git commit -m "build: dustinruetz.com on `date +\"%Y-%b-%d at %T UTC\"`"
git push origin www --force
# note: if you're trying to deploy the site from your local machine and you receive a
# `fatal: not a git repository` error when running the `remove ./www/` command,
# run `cd ./../` first and then try to remove the worktree again after that
- name: Remove Git worktree
run: |
git worktree remove ./www/
git worktree prune