|
1 |
| -name: Deploy to Github Pages |
| 1 | +name: Deploy Hugo site to Pages |
2 | 2 |
|
3 | 3 | on:
|
| 4 | + # Runs on pushes targeting the default branch |
4 | 5 | push:
|
5 |
| - branches: [main] |
6 |
| - pull_request: |
7 |
| - branches: [main] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
8 | 10 | workflow_dispatch:
|
9 | 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 |
| 28 | + |
10 | 29 | jobs:
|
| 30 | + # Build job |
11 | 31 | build:
|
12 | 32 | runs-on: ubuntu-latest
|
13 |
| - |
14 |
| - permissions: |
15 |
| - # Give the default GITHUB_TOKEN write permission to commit and push the |
16 |
| - # added or changed files to the repository. |
17 |
| - contents: write |
18 |
| - |
| 33 | + env: |
| 34 | + HUGO_VERSION: 0.145.0 |
| 35 | + HUGO_ENVIRONMENT: production |
| 36 | + TZ: America/Los_Angeles |
19 | 37 | steps:
|
20 |
| - - uses: actions/checkout@v4 |
21 |
| - |
22 |
| - - name: Cache Hugo resources |
23 |
| - uses: actions/cache@v4 |
24 |
| - env: |
25 |
| - cache-name: cache-hugo-resources |
| 38 | + - name: Install Hugo CLI |
| 39 | + run: | |
| 40 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ |
| 41 | + && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
| 42 | + - name: Install Dart Sass |
| 43 | + run: sudo snap install dart-sass |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v4 |
26 | 46 | with:
|
27 |
| - path: resources |
28 |
| - key: ${{ env.cache-name }} |
29 |
| - |
30 |
| - - uses: actions/setup-go@v4 |
| 47 | + submodules: recursive |
| 48 | + fetch-depth: 0 |
| 49 | + - name: Setup Pages |
| 50 | + id: pages |
| 51 | + uses: actions/configure-pages@v5 |
| 52 | + - name: Install Node.js dependencies |
| 53 | + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 54 | + - name: Cache Restore |
| 55 | + id: cache-restore |
| 56 | + uses: actions/cache/restore@v4 |
31 | 57 | with:
|
32 |
| - go-version: "^1.24.0" |
33 |
| - - run: go version |
34 |
| - |
35 |
| - - name: Setup Hugo |
36 |
| - uses: peaceiris/actions-hugo@v3 |
| 58 | + path: | |
| 59 | + ${{ runner.temp }}/hugo_cache |
| 60 | + key: hugo-${{ github.run_id }} |
| 61 | + restore-keys: |
| 62 | + hugo- |
| 63 | + - name: Configure Git |
| 64 | + run: git config core.quotepath false |
| 65 | + - name: Build with Hugo |
| 66 | + run: | |
| 67 | + hugo \ |
| 68 | + --gc \ |
| 69 | + --minify \ |
| 70 | + --baseURL "${{ steps.pages.outputs.base_url }}/" \ |
| 71 | + --cacheDir "${{ runner.temp }}/hugo_cache" |
| 72 | + - name: Cache Save |
| 73 | + id: cache-save |
| 74 | + uses: actions/cache/save@v4 |
37 | 75 | with:
|
38 |
| - hugo-version: "latest" |
39 |
| - extended: true |
40 |
| - |
41 |
| - - name: Build |
42 |
| - run: hugo --minify --gc |
43 |
| - |
44 |
| - - name: Deploy 🚀 |
45 |
| - uses: JamesIves/github-pages-deploy-action@v4 |
| 76 | + path: | |
| 77 | + ${{ runner.temp }}/hugo_cache |
| 78 | + key: ${{ steps.cache-restore.outputs.cache-primary-key }} |
| 79 | + - name: Upload artifact |
| 80 | + uses: actions/upload-pages-artifact@v3 |
46 | 81 | with:
|
47 |
| - branch: gh-pages |
48 |
| - folder: public |
49 |
| - clean: true |
50 |
| - single-commit: true |
| 82 | + path: ./public |
| 83 | + |
| 84 | + # Deployment job |
| 85 | + deploy: |
| 86 | + environment: |
| 87 | + name: github-pages |
| 88 | + url: ${{ steps.deployment.outputs.page_url }} |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: build |
| 91 | + steps: |
| 92 | + - name: Deploy to GitHub Pages |
| 93 | + id: deployment |
| 94 | + uses: actions/deploy-pages@v4 |
0 commit comments