Update hugo.yml #1401
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: Deploy Hugo site to Pages | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
#HUGO_VERSION: v0.139.4 | ||
steps: | ||
- name: Get Latest Hugo Version | ||
if: ${{ env.HUGO_VERSION == '' }} | ||
run: | | ||
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name') | ||
echo "HUGO_VERSION=$HUGO_VERSION" >> $GITHUB_ENV | ||
echo "Latest Hugo version: ${HUGO_VERSION}" | ||
- name: Create Hugo Directory | ||
id: hugo-dir | ||
continue-on-error: true | ||
run: | | ||
target_dir="${{ runner.tool_cache }}/hugo" | ||
echo "target_dir=${target_dir}" >> $GITHUB_OUTPUT | ||
mkdir -p "${target_dir}" | ||
- name: Cache Hugo | ||
id: cache-hugo | ||
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | ||
with: | ||
path: ${{ runner.tool_cache }}/hugo/hugo | ||
key: ${{ runner.os }}-${{ env.HUGO_VERSION }}-hugo | ||
- name: Install Hugo CLI | ||
if: steps.cache-hugo.outputs.cache-hit != 'true' | ||
run: | | ||
declare -A oses=( ["Linux"]="linux" ["macOS"]="darwin" ) | ||
_os="${oses[$RUNNER_OS]}" | ||
declare -A arches=( ["X64"]="amd64" ["ARM"]="arm64" ["ARM64"]="arm64" ) | ||
_arch="${arches[$RUNNER_ARCH]}" | ||
output_file="${{ runner.temp }}/hugo.tar.gz" | ||
wget -O ${output_file} https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_extended_${HUGO_VERSION#v}_${_os}-${_arch}.tar.gz | ||
tar -C "${{ runner.temp }}" -xzf "${output_file}" | ||
mv "${{ runner.temp }}/hugo" "${{ steps.hugo-dir.outputs.target_dir }}" | ||
- name: Add Hugo to PATH | ||
run: echo "${{ runner.tool_cache }}/hugo" >> $GITHUB_PATH | ||
- name: Install Dart Sass | ||
run: sudo snap install dart-sass | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
submodules: recursive | ||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 | ||
- name: Install Node.js dependencies | ||
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | ||
- name: Build with Hugo | ||
env: | ||
# For maximum backward compatibility with Hugo modules | ||
HUGO_ENVIRONMENT: production | ||
HUGO_ENV: production | ||
run: | | ||
hugo \ | ||
--gc \ | ||
--minify \ | ||
--baseURL "${{ steps.pages.outputs.base_url }}/" | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 | ||
with: | ||
path: ./public | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |