1+ name : Deploy Quartz site to GitHub Pages
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ permissions :
9+ contents : read
10+ pages : write
11+ id-token : write
12+
13+ concurrency :
14+ group : " pages"
15+ cancel-in-progress : false
16+
17+ jobs :
18+ cleanup :
19+ runs-on : ubuntu-latest
20+ permissions : write-all
21+ steps :
22+ - name : Delete old deployment
23+ uses : strumwolf/delete-deployment-environment@v2
24+ with :
25+ token : ${{ secrets.GITHUB_TOKEN }}
26+ environment : github-pages
27+ onlyRemoveDeployments : true
28+
29+ build :
30+ needs : cleanup
31+ runs-on : ubuntu-22.04
32+ steps :
33+ - name : Checkout code
34+ uses : actions/checkout@v4
35+ with :
36+ fetch-depth : 0 # Fetch all history for git info
37+
38+ # quartz uses file modification dates for last edited
39+ # date on each page. Use the git added date as the file ts
40+ - name : Set file timestamps
41+ run : |
42+ readarray -t CONTENT < <(git ls-files -z content | xargs -0 -n 1)
43+ for file in "${CONTENT[@]}"; do
44+ time="$(git log --pretty=format:%cd -n 1 \
45+ --date=format:%Y%m%d%H%M.%S --date-order -- "$file")"
46+ if [ -z "$time" ]; then
47+ echo "ERROR: skipping '$file' -- no git log found" >&2
48+ continue
49+ fi
50+ touch -m -t "$time" "$file"
51+ done
52+
53+ - name : Setup Docker Buildx
54+ uses : docker/setup-buildx-action@v3
55+
56+ - name : Build docker image
57+ run : docker build -t quartz .
58+
59+ - name : Extract static site from quartz container
60+ run : |
61+ docker run --name quartz_builder --env CI=true quartz
62+ docker cp quartz_builder:/quartz/public ./public
63+ docker rm quartz_builder
64+
65+ - name : Upload artifact
66+ uses : actions/upload-pages-artifact@v3
67+ with :
68+ path : public
69+
70+ deploy :
71+ needs : build
72+ environment :
73+ name : github-pages
74+ url : ${{ steps.deployment.outputs.page_url }}
75+ runs-on : ubuntu-latest
76+ steps :
77+ - name : Deploy to GitHub Pages
78+ id : deployment
79+ uses : actions/deploy-pages@v4
0 commit comments