From 756f059b5757456a737e50775105bd96d9075943 Mon Sep 17 00:00:00 2001 From: JavaZero <71128095+JavaZeroo@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:37:39 +0800 Subject: [PATCH 1/2] Add PR preview deployment workflow --- .github/workflows/pr-preview.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/pr-preview.yml diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000..78a3c1e --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,36 @@ +name: Deploy PR Preview + +on: + pull_request: + types: [opened, reopened, synchronize, closed] + +permissions: + contents: write + pull-requests: write + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install and Build + if: github.event.action != 'closed' + run: | + npm install + npm run build + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./dist/ + pages-base-url: log.javazero.top + preview-branch: gh-pages + From 02d2f5be28cb8a5262a9d2056f4e5d4bfa8ec234 Mon Sep 17 00:00:00 2001 From: JavaZero <71128095+JavaZeroo@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:56:52 +0800 Subject: [PATCH 2/2] Update deploy workflow to preserve main site --- .github/workflows/deploy.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 15d0905..d66e51d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,9 +10,7 @@ jobs: build-and-deploy: runs-on: ubuntu-latest permissions: - contents: read - pages: write - id-token: write + contents: write steps: - name: Checkout @@ -39,14 +37,10 @@ jobs: - name: Build run: npm run build - - name: Setup Pages - uses: actions/configure-pages@v4 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: './dist' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: ./dist + branch: gh-pages + clean-exclude: pr-preview + force: false