From 9cab80d676c60c5fe58d40b1e442f8106901aebf Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Fri, 10 Jul 2026 19:49:31 +0100 Subject: [PATCH] Fix CI --- .github/workflows/pages.yml | 45 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 5ba8750..e55b105 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -7,16 +7,14 @@ on: workflow_dispatch: permissions: - contents: read - pages: write - id-token: write + contents: write concurrency: group: pages cancel-in-progress: false jobs: - build: + deploy: runs-on: ubuntu-latest steps: @@ -35,19 +33,32 @@ jobs: - name: Build site run: npm run build - - name: Configure GitHub Pages - uses: actions/configure-pages@v5 + - name: Publish to gh-pages branch + run: | + set -euo pipefail - - name: Upload GitHub Pages artifact - uses: actions/upload-pages-artifact@v3 - with: - path: dist + touch dist/.nojekyll + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - deploy: - needs: build - runs-on: ubuntu-latest + git fetch origin gh-pages || true - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then + git worktree add /tmp/gh-pages origin/gh-pages + git -C /tmp/gh-pages checkout -B gh-pages + find /tmp/gh-pages -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + + else + git worktree add --detach /tmp/gh-pages + git -C /tmp/gh-pages checkout --orphan gh-pages + git -C /tmp/gh-pages rm -rf . || true + fi + + cp -R dist/. /tmp/gh-pages/ + git -C /tmp/gh-pages add --all + + if git -C /tmp/gh-pages diff --cached --quiet; then + echo "No GitHub Pages changes to publish." + else + git -C /tmp/gh-pages commit -m "chore: deploy GitHub Pages" + git -C /tmp/gh-pages push origin gh-pages + fi