From c4e084121c3de2ecedda0739cc5eda6e33026354 Mon Sep 17 00:00:00 2001 From: Yanzheng Sun Date: Mon, 29 Jan 2024 18:09:37 +0800 Subject: [PATCH] =?UTF-8?q?[=C2=B1]=20Synced=20GitHub=20Actions=20file=20w?= =?UTF-8?q?ith=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yaml | 86 ++++++++++++++--------------------- 1 file changed, 34 insertions(+), 52 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index bd448be..7032b41 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -5,63 +5,45 @@ on: branches: [main] pull_request: branches: [main] - workflow_dispatch: - -permissions: - contents: read - pages: write - id-token: write - -defaults: - run: - shell: bash jobs: build: runs-on: ubuntu-latest - env: - HUGO_VERSION: 0.122.0 + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + steps: - - name: Install Hugo CLI - run: | - wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ - && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - uses: actions/checkout@v3 - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: Setup Pages - id: pages - uses: actions/configure-pages@v4 - - - name: Install Node.js dependencies - run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" - - - name: Build with Hugo + - name: Cache Hugo resources + uses: actions/cache@v3 env: - HUGO_ENVIRONMENT: production - HUGO_ENV: production - run: | - hugo \ - --gc \ - --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + cache-name: cache-hugo-resources with: - path: ./public - - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v3 \ No newline at end of file + path: resources + key: ${{ env.cache-name }} + + - uses: actions/setup-go@v4 + with: + go-version: "^1.17.0" + - run: go version + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: "latest" + extended: true + + - name: Build + run: hugo --minify --gc + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: public + clean: true + single-commit: true \ No newline at end of file