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 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