|
1 | | -name: Deploy Hugo PaperMod Demo to Pages |
2 | | - |
| 1 | +name: Build and deploy |
3 | 2 | on: |
4 | 3 | push: |
5 | | - paths-ignore: |
6 | | - - "images/**" |
7 | | - - "LICENSE" |
8 | | - - "README.md" |
9 | 4 | branches: |
10 | 5 | - main |
11 | 6 | workflow_dispatch: |
12 | | - # manual run |
13 | | - inputs: |
14 | | - hugoVersion: |
15 | | - description: "Hugo Version" |
16 | | - required: false |
17 | | - default: "0.150.0" |
18 | | - |
19 | | -# Allow one concurrent deployment |
20 | | -concurrency: |
21 | | - group: "pages" |
22 | | - cancel-in-progress: true |
23 | | - |
24 | | -# Default to bash |
25 | | -defaults: |
26 | | - run: |
27 | | - shell: bash |
28 | | - |
29 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
30 | 7 | permissions: |
31 | 8 | contents: read |
32 | 9 | pages: write |
33 | 10 | id-token: write |
34 | | - |
| 11 | +concurrency: |
| 12 | + group: pages |
| 13 | + cancel-in-progress: false |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
35 | 17 | jobs: |
36 | | - # Build job |
37 | 18 | build: |
38 | 19 | runs-on: ubuntu-latest |
39 | 20 | env: |
40 | | - HUGO_VERSION: ${{ github.event.inputs.hugoVersion || '0.150.0' }} |
| 21 | + DART_SASS_VERSION: 1.92.1 |
| 22 | + GO_VERSION: 1.25.1 |
| 23 | + HUGO_VERSION: 0.150.0 |
| 24 | + NODE_VERSION: 22.18.0 |
| 25 | + TZ: Europe/Oslo |
41 | 26 | steps: |
42 | | - - name: Install Hugo CLI |
43 | | - run: | |
44 | | - wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.deb \ |
45 | | - && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
46 | 27 | - name: Checkout |
47 | | - uses: actions/checkout@v4 |
| 28 | + uses: actions/checkout@v5 |
| 29 | + with: |
| 30 | + submodules: recursive |
| 31 | + fetch-depth: 0 |
| 32 | + - name: Setup Go |
| 33 | + uses: actions/setup-go@v5 |
48 | 34 | with: |
49 | | - ref: exampleSite |
| 35 | + go-version: ${{ env.GO_VERSION }} |
| 36 | + cache: false |
| 37 | + - name: Setup Node.js |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: ${{ env.NODE_VERSION }} |
50 | 41 | - name: Setup Pages |
51 | 42 | id: pages |
52 | 43 | uses: actions/configure-pages@v5 |
| 44 | + - name: Create directory for user-specific executable files |
| 45 | + run: | |
| 46 | + mkdir -p "${HOME}/.local" |
| 47 | + - name: Install Dart Sass |
| 48 | + run: | |
| 49 | + curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 50 | + tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 51 | + rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 52 | + echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}" |
| 53 | + - name: Install Hugo |
| 54 | + run: | |
| 55 | + curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 56 | + mkdir "${HOME}/.local/hugo" |
| 57 | + tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 58 | + rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 59 | + echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}" |
| 60 | + - name: Verify installations |
| 61 | + run: | |
| 62 | + echo "Dart Sass: $(sass --version)" |
| 63 | + echo "Go: $(go version)" |
| 64 | + echo "Hugo: $(hugo version)" |
| 65 | + echo "Node.js: $(node --version)" |
| 66 | + - name: Install Node.js dependencies |
| 67 | + run: | |
| 68 | + [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true |
| 69 | + - name: Configure Git |
| 70 | + run: | |
| 71 | + git config core.quotepath false |
53 | 72 | - name: Get Theme |
54 | 73 | run: git submodule update --init --recursive |
55 | 74 | - name: Update theme to Latest commit |
56 | 75 | run: git submodule update --remote --merge |
57 | | - - name: Build with Hugo |
| 76 | + - name: Cache restore |
| 77 | + id: cache-restore |
| 78 | + uses: actions/cache/restore@v4 |
| 79 | + with: |
| 80 | + path: ${{ runner.temp }}/hugo_cache |
| 81 | + key: hugo-${{ github.run_id }} |
| 82 | + restore-keys: |
| 83 | + hugo- |
| 84 | + - name: Build the site |
58 | 85 | run: | |
59 | 86 | hugo \ |
60 | | - --buildDrafts --gc \ |
61 | | - --baseURL ${{ steps.pages.outputs.base_url }} |
| 87 | + --gc \ |
| 88 | + --minify \ |
| 89 | + --baseURL "${{ steps.pages.outputs.base_url }}/" \ |
| 90 | + --cacheDir "${{ runner.temp }}/hugo_cache" |
| 91 | + - name: Cache save |
| 92 | + id: cache-save |
| 93 | + uses: actions/cache/save@v4 |
| 94 | + with: |
| 95 | + path: ${{ runner.temp }}/hugo_cache |
| 96 | + key: ${{ steps.cache-restore.outputs.cache-primary-key }} |
62 | 97 | - name: Upload artifact |
63 | 98 | uses: actions/upload-pages-artifact@v3 |
64 | 99 | with: |
65 | 100 | path: ./public |
66 | | - # Deployment job |
67 | 101 | deploy: |
68 | 102 | environment: |
69 | 103 | name: github-pages |
|
0 commit comments