After set up the project in Azure and use Github as repo, the pipeline failed with error:
Using Hugo version:
hugo v0.124.1-db083b05f16c945fec04f745f0ca8640560cf1ec+extended linux/amd64 BuildDate=2024-03-20T11:40:10Z VendorInfo=gohugoio
WARN Module "PaperMod" is not compatible with this Hugo version: Min 0.125.7; run "hugo mod graph" for more information.
Start building sites …
hugo v0.124.1-db083b05f16c945fec04f745f0ca8640560cf1ec+extended linux/amd64 BuildDate=2024-03-20T11:40:10Z VendorInfo=gohugoio
ERROR => hugo v0.125.7 or greater is required for hugo-PaperMod to build <<<<<< the installed version is higher 0.137
Total in 33 ms
Error: error building site: logged 1 error(s)
---End of Oryx build logs---
Oryx has failed to build the solution.
Even though the proper Hugo ver is installed, oryx do not read the proper verion
Solution is to install the latest Hugo and add it as variable:
Template used with sensitive infomation removed:
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Clean up previous Hugo installation
run: |
sudo rm -rf /usr/local/bin/hugo
- name: Install Hugo v0.137.0
run: |
wget https://github.com/gohugoio/hugo/releases/download/v0.137.0/hugo_0.137.0_Linux-64bit.tar.gz
tar -xvzf hugo_0.137.0_Linux-64bit.tar.gz
sudo mv hugo /usr/local/bin/
hugo version
- name: Set Hugo version for Oryx
run: |
echo "HUGO_VERSION=0.137.0" >> $GITHUB_ENV
- name: Deploy to Azure Static Web Apps
id: deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "public" # Built app content directory - optional
skip_build: "true" # Allow Oryx to run the build process
skip_api_build: "true"
environment_variables: |
OryxVersion=20240408.1 # Specify the Oryx version here
HUGO_VERSION=0.137.0 # Ensure Oryx uses the correct Hugo version
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: "close"