fix: 升级 github action 脚本版本 v4 #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Hugo site to Pages | |
| on: | |
| # 推送到默认分支时触发 | |
| push: | |
| branches: | |
| - master | |
| - main # 如果你的默认分支是main,请保留此行 | |
| # 允许你从Actions选项卡手动运行此工作流 | |
| workflow_dispatch: | |
| # 设置GITHUB_TOKEN的权限以允许部署到GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 只允许一个并发部署,跳过正在运行和最新排队之间的运行 | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| # 默认使用bash | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| # 构建任务 | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| HUGO_VERSION: 0.153.4 # 更新至当前最新的稳定版本[citation:1] | |
| 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 | |
| - name: Checkout | |
| uses: actions/checkout@v4 # 升级至v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v4 # 升级至v4 | |
| - name: Install Node.js dependencies | |
| run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
| - name: Build with Hugo | |
| env: | |
| # 为了与Hugo模块的最大兼容性 | |
| 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 # 升级至v3[citation:6] | |
| 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@v4 # 升级至v4[citation:6] |