-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (56 loc) · 2.19 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
56
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🛒 Git checkout repository
uses: actions/checkout@v4
- name: ⬢ Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .node-version
# - 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 workflow is broken/erroring/unavailable, the site
# can still be deployed 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 clean-install
- name: 👀 Audit dependency signatures
run: npm audit signatures
- 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