-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (97 loc) · 3.36 KB
/
build.yml
File metadata and controls
111 lines (97 loc) · 3.36 KB
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
106
107
108
109
110
111
name: Build and Deploy
on:
push:
branches: [ main, migrated ]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
# Checkout code and pull LFS files
- name: Checkout (with LFS)
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
# Cache LFS objects
- name: Cache Git LFS objects
uses: actions/cache@v4
with:
path: .git/lfs/objects
key: ${{ runner.os }}-git-lfs-${{ hashFiles('.gitattributes') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-git-lfs-${{ github.sha }}-
${{ runner.os }}-git-lfs-
# Ensure LFS files are real (materialize)
- name: Ensure LFS files are real (materialize)
shell: bash
run: |
set -euo pipefail
git lfs install --local
git lfs fetch origin "${GITHUB_SHA}"
git lfs checkout
echo "LFS files tracked (pointer -> actual):"
git lfs ls-files
# Verify no LFS pointers in source assets
- name: Verify no LFS pointers in source assets
shell: bash
run: |
set -euo pipefail
if grep -RIl "version https://git-lfs.github.com/spec" assets 2>/dev/null; then
echo "::error::Found LFS pointer(s) under assets/. 'git lfs checkout' did not materialize some files." >&2
exit 1
fi
echo "No LFS pointers in raw source assets."
# Set up Ruby
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
# Build site
- name: Build site
run: bundle exec jekyll build --trace
# Deploy to gh-pages
- name: Deploy to gh-pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
publish_branch: gh-pages
cname: zihaofu245.me
# # Connect this GitHub runner to your tailnet
# - name: Connect to Tailscale
# if: github.ref == 'refs/heads/main'
# uses: tailscale/github-action@v4
# with:
# authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
# tags: tag:ci
# # Install SSH key so we can log in as zihao@DEPLOY_HOST
# - name: Configure SSH
# if: github.ref == 'refs/heads/main'
# env:
# SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
# DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
# run: |
# set -euo pipefail
# mkdir -p ~/.ssh
# chmod 700 ~/.ssh
# printf '%s\n' "$SSH_KEY" > ~/.ssh/id_ed25519
# chmod 600 ~/.ssh/id_ed25519
# ssh-keyscan "$DEPLOY_HOST" >> ~/.ssh/known_hosts
# # Push built site to ~/zihaofu245.me and restart HTTP server
# - name: Deploy to Tailscale host
# if: github.ref == 'refs/heads/main'
# env:
# DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
# run: |
# set -euo pipefail
# # Sync _site/ to your home web root
# rsync -avz --delete ./_site/ "zihao@${DEPLOY_HOST}:~/zihaofu245.me/"
# # Restart your user-level HTTP server
# ssh "zihao@${DEPLOY_HOST}" "systemctl --user restart blog.service"