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