|
1 | 1 | --- |
2 | | -name: github pages |
| 2 | +# Sample workflow for building and deploying a Hugo site to GitHub Pages |
| 3 | +name: Deploy Hugo site to Pages |
3 | 4 |
|
4 | 5 | on: |
| 6 | + # Runs on pushes targeting the default branch |
5 | 7 | push: |
6 | | - branches: |
7 | | - - main |
| 8 | + branches: [$default-branch] |
8 | 9 |
|
9 | | -jobs: |
10 | | - build-deploy: |
11 | | - runs-on: ubuntu-20.04 |
12 | | - steps: |
13 | | - - uses: actions/checkout@master |
14 | | - with: |
15 | | - submodules: true |
16 | | - |
17 | | - - name: Setup Hugo |
18 | | - uses: peaceiris/actions-hugo@v2 |
19 | | - with: |
20 | | - hugo-version: '0.97.3' |
21 | | - extended: true |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
22 | 12 |
|
| 13 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pages: write |
| 17 | + id-token: write |
23 | 18 |
|
24 | | - - uses: actions/cache@v2 |
25 | | - with: |
26 | | - path: /tmp/hugo_cache |
27 | | - key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }} |
28 | | - restore-keys: | |
29 | | - ${{ runner.os }}-hugomod- |
| 19 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 20 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 21 | +concurrency: |
| 22 | + group: "pages" |
| 23 | + cancel-in-progress: false |
30 | 24 |
|
31 | | - - name: Build |
32 | | - run: hugo --gc --minify --cleanDestinationDir |
| 25 | +# Default to bash |
| 26 | +defaults: |
| 27 | + run: |
| 28 | + shell: bash |
33 | 29 |
|
34 | | - - name: Deploy |
35 | | - uses: peaceiris/actions-gh-pages@v3 |
| 30 | +jobs: |
| 31 | + # Build job |
| 32 | + build: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + env: |
| 35 | + HUGO_VERSION: 0.122.0 |
| 36 | + steps: |
| 37 | + - name: Install Hugo CLI |
| 38 | + run: | |
| 39 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ |
| 40 | + && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
| 41 | + - name: Install Dart Sass |
| 42 | + run: sudo snap install dart-sass |
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + submodules: recursive |
| 47 | + - name: Setup Pages |
| 48 | + id: pages |
| 49 | + uses: actions/configure-pages@v4 |
| 50 | + - name: Install Node.js dependencies |
| 51 | + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 52 | + - name: Build with Hugo |
| 53 | + env: |
| 54 | + # For maximum backward compatibility with Hugo modules |
| 55 | + HUGO_ENVIRONMENT: production |
| 56 | + HUGO_ENV: production |
| 57 | + run: | |
| 58 | + hugo \ |
| 59 | + --minify \ |
| 60 | + --baseURL "${{ steps.pages.outputs.base_url }}/" |
| 61 | + - name: Upload artifact |
| 62 | + uses: actions/upload-pages-artifact@v3 |
36 | 63 | with: |
37 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
38 | | - publish_branch: gh-pages |
39 | | - publish_dir: ./public |
| 64 | + path: ./public |
| 65 | + |
| 66 | + # Deployment job |
| 67 | + deploy: |
| 68 | + environment: |
| 69 | + name: github-pages |
| 70 | + url: ${{ steps.deployment.outputs.page_url }} |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build |
| 73 | + steps: |
| 74 | + - name: Deploy to GitHub Pages |
| 75 | + id: deployment |
| 76 | + uses: actions/deploy-pages@v4 |
0 commit comments