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