fix #81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |