workflow_call #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build with Hugo | |
on: | |
push: | |
branches: | |
- main | |
- draft | |
paths: | |
- '.github/**' | |
- 'assets/**' | |
- 'config/**' | |
- 'content/**' | |
- 'layouts/**' | |
- 'resources/**' | |
- 'static/**' | |
- 'themes/**' | |
- 'package.json' | |
- 'pagefind.yaml' | |
- 'postcss.config.js' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.ref_name }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
HUGO_VERSION: 0.128.2 | |
steps: | |
- name: Install Hugo CLI | |
run: | | |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Create LFS file list | |
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id | |
- name: Fetch LFS directory from cache | |
uses: actions/cache@v3 | |
with: | |
path: .git/lfs/objects | |
key: ${{ runner.os }}-lfs-${{ github.ref_name }}-${{ hashFiles('.lfs-assets-id') }} | |
restore-keys: | | |
${{ runner.os }}-lfs-${{ github.ref_name }} | |
- name: Git LFS Pull | |
run: git lfs pull | |
- name: Fetch resources directory from cache | |
uses: actions/cache@v3 | |
with: | |
path: resources | |
key: ${{ runner.os }}-hugo-resources-directory-${{ github.ref_name }}-${{ github.run_id }} | |
restore-keys: | | |
${{ runner.os }}-hugo-resources-directory-${{ github.ref_name }} | |
- name: Build with Hugo | |
env: | |
HUGO_ENVIRONMENT: ${{ github.ref_name == 'main' && 'production' || 'development' }} | |
# For maximum backward compatibility with Hugo modules | |
HUGO_ENV: ${{ github.ref_name == 'main' && 'production' || 'development' }} | |
run: | | |
hugo \ | |
--gc \ | |
--minify | |
- name: Run pagefind | |
run: npm_config_yes=true npx pagefind | |
- name: Upload public directory as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.ref_name }}-public | |
path: ./public | |
if-no-files-found: error | |
deploy: | |
needs: build | |
uses: ./.github/workflows/deploy-hetzner_webhost.yml |