From e9a00db6bdfb90f59d2c1a61104b05d8ee133ee1 Mon Sep 17 00:00:00 2001 From: bamboo Date: Thu, 22 Feb 2024 23:02:13 +0800 Subject: [PATCH] :construction_worker: Ci: adjust action to deploy gh-pages --- .github/workflows/hugo.yaml | 43 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/hugo.yaml b/.github/workflows/hugo.yaml index 14c9fec..8ad93f2 100644 --- a/.github/workflows/hugo.yaml +++ b/.github/workflows/hugo.yaml @@ -1,14 +1,31 @@ -name: GitHub Pages +name: Build and Deploy to GitHub Pages on: push: branches: - master # Set a branch to deploy # pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false jobs: deploy: - runs-on: ubuntu-22.04 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest concurrency: group: ${{ github.workflow }}-${{ github.ref }} steps: @@ -17,6 +34,10 @@ jobs: submodules: recursive # Fetch Hugo themes (true OR recursive) fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + - name: Setup Pages + id: pages + uses: actions/configure-pages@v4 + - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: @@ -33,11 +54,17 @@ jobs: ${{ runner.os }}-hugomod- - name: Build - run: hugo --minify + run: | + hugo \ + --gc \ + --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/master' + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public + path: ./public + + - name: Deploy + id: deployment + uses: actions/deploy-pages@v3