From ef1f9ce188b39e7004b5874acab4e7b22d6b428b Mon Sep 17 00:00:00 2001 From: ethan-CCY Date: Mon, 22 Dec 2025 09:44:56 +0800 Subject: [PATCH 1/2] Add GitHub Actions workflow for deployment --- .github/workflows/deploy-main.yml | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/deploy-main.yml diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml new file mode 100644 index 0000000..d661d1c --- /dev/null +++ b/.github/workflows/deploy-main.yml @@ -0,0 +1,42 @@ +name: Deploy Main (root) + +on: + push: + branches: ["main"] + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: pages-main + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + + - name: Install + run: npm ci + + - name: Build + run: npm run build + + # 部署到 gh-pages 分支根目錄,但不要清掉 previews + - name: Deploy to gh-pages (root) + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: dist + clean: true + clean-exclude: previews/** + single-commit: true From 8b6f531a9e20878f0a00e077f1d3e2e1dd3c4258 Mon Sep 17 00:00:00 2001 From: ethan-CCY Date: Mon, 22 Dec 2025 09:47:18 +0800 Subject: [PATCH 2/2] Add GitHub Actions workflow for deploy previews --- .github/workflows/deploy-preview.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..9c639ab --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,41 @@ +name: Deploy Preview (by branch) + +on: + push: + branches-ignore: ["main"] + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: pages-preview-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + + - name: Install + run: npm ci + + - name: Build + run: npm run build + + - name: Deploy to gh-pages (preview folder) + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: dist + target-folder: previews/${{ github.ref_name }} + clean: true + single-commit: true