From 62d410dcdf3ae25c263df19fcbced1da9ab02a0e Mon Sep 17 00:00:00 2001 From: Cyan Date: Thu, 14 Nov 2024 00:09:46 +0800 Subject: [PATCH] ci: optimize --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e9da474..5369aef 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,26 +1,42 @@ # https://github.com/actions/deploy-pages#usage name: Deploy to GitHub Pages on: - push: - branches: - - deploy + workflow_run: + workflows: + - Sync + types: + - completed workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: deploy - uses: oven-sh/setup-bun@v2 with: bun-version: latest + - name: Cache Node Modules + id: cache-blackhole + uses: actions/cache/restore@v4 + with: + path: node_modules + key: blackhole # Pick your own package manager and build script - run: bun install --locked + - name: Save Primes + id: cache-blackhole + uses: actions/cache/save@v4 + with: + path: node_modules + key: blackhole - run: bun run build --preset github_pages - - run: npx nuxt build --preset github_pages - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-artifact@v4 with: + name: build-output path: ./.output/public # Deployment job deploy: @@ -28,7 +44,8 @@ jobs: needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: - pages: write # to deploy to Pages + contents: write # to deploy to gh_pages branch + # pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source # Deploy to the github_pages environment environment: @@ -37,6 +54,19 @@ jobs: # Specify runner + deployment step runs-on: ubuntu-latest steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - uses: actions/checkout@v4 + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: build-output + path: dist + - name: Deploy to gh_pages branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: dist + publish_branch: gh_pages + # https://github.com/peaceiris/actions-gh-pages/issues/163 + exclude_assets: '' + force_orphan: true + commit_message: 'deploy'