|
1 |
| -# Sample workflow for building and deploying a Hugo site to GitHub Pages |
| 1 | +# GitHub Actions workflow for building and deploying a Hugo site to GitHub Pages |
2 | 2 | name: Deploy Hugo site to Pages
|
3 | 3 |
|
4 | 4 | on:
|
5 |
| - # Runs on pushes targeting the default branch |
6 | 5 | push:
|
7 | 6 | branches:
|
8 | 7 | - main
|
9 |
| - |
10 |
| - # Allows you to run this workflow manually from the Actions tab |
11 | 8 | workflow_dispatch:
|
12 | 9 |
|
13 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
14 | 10 | permissions:
|
15 | 11 | contents: read
|
16 | 12 | pages: write
|
17 | 13 | id-token: write
|
18 | 14 |
|
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 | 15 | concurrency:
|
22 | 16 | group: "pages"
|
23 | 17 | cancel-in-progress: false
|
24 | 18 |
|
25 |
| -# Default to bash |
26 | 19 | defaults:
|
27 | 20 | run:
|
28 | 21 | shell: bash
|
29 | 22 |
|
30 | 23 | jobs:
|
31 |
| - # Build job |
32 | 24 | build:
|
33 | 25 | runs-on: ubuntu-latest
|
34 | 26 | env:
|
35 |
| - HUGO_VERSION: 0.123.7 |
| 27 | + HUGO_VERSION: 0.135.0 # Update to match your local Hugo version |
| 28 | + |
36 | 29 | 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 |
| 30 | + - name: Checkout repository |
44 | 31 | uses: actions/checkout@v4
|
45 | 32 | with:
|
46 | 33 | submodules: recursive
|
47 | 34 | fetch-depth: 0
|
| 35 | + |
| 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 | +
|
| 41 | + - name: Install Dart Sass |
| 42 | + run: sudo snap install dart-sass |
| 43 | + |
48 | 44 | - name: Setup Pages
|
49 | 45 | id: pages
|
50 | 46 | uses: actions/configure-pages@v4
|
| 47 | + |
| 48 | + - name: Setup Node.js |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: "lts/*" |
| 52 | + |
51 | 53 | - name: Install Node.js dependencies
|
52 |
| - run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 54 | + run: | |
| 55 | + if [ -f package.json ]; then |
| 56 | + npm install |
| 57 | + fi |
| 58 | +
|
53 | 59 | - name: Build with Hugo
|
54 | 60 | env:
|
55 |
| - # For maximum backward compatibility with Hugo modules |
56 | 61 | HUGO_ENVIRONMENT: production
|
57 | 62 | HUGO_ENV: production
|
58 | 63 | run: |
|
59 |
| - hugo \ |
60 |
| - --gc \ |
61 |
| - --minify \ |
62 |
| - --baseURL "${{ steps.pages.outputs.base_url }}/" |
63 |
| - - name: Upload artifact |
| 64 | + hugo --gc --minify --baseURL "${{ steps.pages.outputs.base_url }}/" |
| 65 | +
|
| 66 | + - name: Upload build artifact |
| 67 | + uses: actions/upload-artifact@v4 # Updated to prevent deprecation issues |
| 68 | + with: |
| 69 | + name: hugo-site |
| 70 | + path: ./public |
| 71 | + |
| 72 | + - name: Upload Pages artifact |
64 | 73 | uses: actions/upload-pages-artifact@v1
|
65 | 74 | with:
|
66 | 75 | path: ./public
|
67 | 76 |
|
68 |
| - # Deployment job |
69 | 77 | deploy:
|
70 | 78 | environment:
|
71 | 79 | name: github-pages
|
72 | 80 | url: ${{ steps.deployment.outputs.page_url }}
|
73 | 81 | runs-on: ubuntu-latest
|
74 | 82 | needs: build
|
| 83 | + |
75 | 84 | steps:
|
76 | 85 | - name: Deploy to GitHub Pages
|
77 | 86 | id: deployment
|
|
0 commit comments