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