Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when building hugo on Azure Static Sites #2078

Closed
aionic opened this issue Jul 20, 2023 · 4 comments
Closed

Errors when building hugo on Azure Static Sites #2078

aionic opened this issue Jul 20, 2023 · 4 comments
Assignees

Comments

@aionic
Copy link

aionic commented Jul 20, 2023

Bug Report

  • At what date and time did you most recently experience the problem?
    07/19/2023

  • Where did you experience the problem? E.g. Azure Web Apps, Azure Functions, Azure Container Registry, or offline use.
    Azure Static Web App

  • If your repo is publicly available please share its URL:

  • What happened?
    Build a static web app leveraging the hugo v.0.115.3 and the the hugo-awesome-blog theme at https://github.com/hugo-sid/hugo-blog-awesome

Two separate issues/behaviors

  1. On the default run I received the error that the solution was unable to identify the type of code in the solution.
`App` Directory Location: '/' was found.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
---Oryx build logs---
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version: 0.2.20230501.1, Commit: 585[13](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605233596/job/15185522282#step:4:14)374525ab2977af68fc5b3c344d32858d8af, ReleaseTagName: [20](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605233596/job/15185522282#step:4:21)[23](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605233596/job/15185522282#step:4:24)0501.1
Build Operation ID: 3e26f9089bd55785
OS Type           : bullseye
Image Type        : jamstack
Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.
---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
Finished building app with Oryx
Failed to find a default file in the app artifacts folder (/). Valid default files: index.html,Index.html.
If your application contains purely static content, please verify that the variable 'app_location' in your workflow file points to the root of your application.
If your application requires build steps, please validate that a default file exists in the build output directory.
  1. I resolved the above issue by renaming hugo.toml to config.toml in the root; however, when I did that the build failed (as it appeared to attempted to build with an old version of hugo (0.96.0 ) that doesn't support the theme
App Directory Location: '/' was found.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
---Oryx build logs---


Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20230501.1, Commit: 585[13](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:14)374525ab2977af68fc5b3c344d32858d8af, ReleaseTagName: 20230501.1

Build Operation ID: e8b9f68bcb49422a
OS Type           : bullseye
Image Type        : jamstack

Detecting platforms...
Detected following platforms:
  hugo: 0.96.0
Version '0.96.0' of platform 'hugo' is not installed. Generating script to install it...
Detected the following frameworks: hugo


+++ dirname /opt/tmp/images/build/installHugo.sh
++ cd /opt/tmp/images/build
++ pwd
+ __CURRENT_DIR=/opt/tmp/images/build
+ source /opt/tmp/images/build/../../build/__hugoConstants.sh
++ VERSION=0.96.0
++ PLATFORM_NAME=hugo
++ INSTALLED_HUGO_VERSIONS_DIR=/opt/hugo
++ INSTALLATION_URL_FORMAT=https://github.com/gohugoio/hugo/releases/download/v#VERSION#/#TAR_FILE#
++ TAR_FILE_NAME_FORMAT=hugo_extended_#VERSION#_Linux-64bit.tar.gz
++ TOML_FILE_NAME=config.toml
++ YAML_FILE_NAME=config.yaml
++ YML_FILE_NAME=config.yml
++ JSON_FILE_NAME=config.json
++ CONFIG_FOLDER_NAME=config
++ echo hugo_extended_#VERSION#_Linux-64bit.tar.gz
++ sed s/#VERSION#/0.96.0/g
+ fileName=hugo_extended_0.96.0_Linux-64bit.tar.gz
++ echo https://github.com/gohugoio/hugo/releases/download/v#VERSION#/#TAR_FILE#
++ sed s/#VERSION#/0.96.0/g
+ url=https://github.com/gohugoio/hugo/releases/download/v0.96.0/#TAR_FILE#
++ echo https://github.com/gohugoio/hugo/releases/download/v0.96.0/#TAR_FILE#
Source directory     : /github/workspace
Destination directory: /bin/staticsites/374d846f-f66f-4e68-bde7-a9d30bd9301c-swa-oryx/app
++ sed s/#TAR_FILE#/hugo_extended_0.96.0_Linux-64bit.tar.gz/g

+ url=https://github.com/gohugoio/hugo/releases/download/v0.96.0/hugo_extended_0.96.0_Linux-64bit.tar.gz
+ request='curl -fsSLO --compressed https://github.com/gohugoio/hugo/releases/download/v0.96.0/hugo_extended_0.96.0_Linux-64bit.tar.gz'
+ /opt/tmp/images/retry.sh 'curl -fsSLO --compressed https://github.com/gohugoio/hugo/releases/download/v0.96.0/hugo_extended_0.96.0_Linux-64bit.tar.gz'
retry 0
+ installationDir=/opt/hugo/0.96.0
+ mkdir -p /opt/hugo/0.96.0
+ tar -xzf hugo_extended_0.96.0_Linux-64bit.tar.gz -C /opt/hugo/0.96.0
+ rm hugo_extended_0.96.0_Linux-64bit.tar.gz
+ ln -s /opt/hugo/0.96.0 /opt/hugo/lts

Downloading and extracting hugo version 0.96.0 to /opt/hugo/0.96.0...
Downloaded in 0 sec(s).
Extracting contents...
Done in 0 sec(s).

Installing golang tooling and language...
1.15.8
go1.15.8.linux-amd64.tar.gz
retry 0

Using Hugo version:
hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd9[14](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:15)38967bbb+extended linux/amd64 BuildDate=2022-03-26T09:[15](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:16):58Z VendorInfo=gohugoio

Start building sites … 
hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd91438967bbb+extended linux/amd64 BuildDate=2022-03-26T09:15:58Z VendorInfo=gohugoio
ERROR 2023/07/20 00:[17](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:18):22 render of "taxonomy" failed: execute of template failed: template: _default/list.html:3:8: executing "_default/list.html" at <partial "head.html" .>: error calling partial: "/github/workspace/themes/hugo-blog-awesome/layouts/partials/head.html:25:76": execute of template failed: template: partials/head.html:25:76: executing "partials/head.html" at <resources>: can't evaluate field Copy in type interface {}
ERROR [20](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:21)23/07/20 00:17:[22](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:23) render of "taxonomy" failed: execute of template failed: template: _default/list.html:3:8: executing "_default/list.html" at <partial "head.html" .>: error calling partial: "/github/workspace/themes/hugo-blog-awesome/layouts/partials/head.html:[25](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:26):76": execute of template failed: template: partials/head.html:25:76: executing "partials/head.html" at <resources>: can't evaluate field Copy in type interface {}
Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:3:4: executing "index.html" at <partial "head.html" .>: error calling partial: "/github/workspace/themes/hugo-blog-awesome/layouts/partials/head.html:25:76": execute of template failed: template: partials/head.html:25:76: executing "partials/head.html" at <resources>: can't evaluate field Copy in type interface {}
Total in [47](https://github.com/aionic/Null-Reference-Exceptions/actions/runs/5605364594/job/15185902872#step:4:48) ms


---End of Oryx build logs---
Oryx has failed to build the solution.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting

Finally worked around, this by using an alternate build solution, disabling oryx build and only deploying through the staticwebapp action (working example below)

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Initialize job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
          fetch-depth: 0

  ### Using alt build process
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'
          extended: true

      - name: Cache Hugo modules
        uses: actions/cache@v3
        with:
          path: public
          key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-hugo-

      - name: Build site with Hugo
        run: hugo --minify --cleanDestinationDir

  ### Oryx is buggy bypassing the build step for now
      - name: Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_sanitized }}
          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. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "public" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "public" # Built app content directory - optional
          skip_app_build: "true"
          skip_api_build: "true"
          ###### 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_sanatized }}
          action: "close"
  • What did you expect or want to happen?
    Have the solution build / deploy properly

  • How can we reproduce it?
    Install hugo version 0.115.3

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/hugo-sid/hugo-blog-awesome.git themes/hugo-blog-awesome
echo "theme = 'hugo-blog-awesome'" >> hugo.toml
hugo server

Make sure the above runs fine locally, if so

git add -A
git commit -m "hello world"

Run through the quick start process on Azure Static Sites (Push your application to Github)
https://learn.microsoft.com/en-us/azure/static-web-apps/publish-hugo#push-your-application-to-github

  • Do you have log output? Please include between the backticks:
    See above
@snehapar9
Copy link
Contributor

snehapar9 commented Jul 24, 2023

Thanks so much for reaching out @aionic! Seems like this is occurring because the Hugo version was wrongly detected as 0.96? Can you confirm what the Hugo version in your app is? This issue seems to be related to this known issue. The Oryx team rolled out a fix for this issue in this PR. The Static Web Apps team has this update in staging and is planning to roll out the new version of the StaticSitesClient shortly.
Thank you for your patience! Please let me know if you have any other questions.

@aionic
Copy link
Author

aionic commented Aug 9, 2023

Hey @snehapar9 - Hugo version was v.0.115.3.
In this version Hugo no longer uses a "config.toml" file so when running the deployment it failed to detect period.

When I renamed hugo.toml to config.toml the solution ran Hugo but was built via the wrong version.
Looking through the PR above it sounds like the issue, looks like the fix was merged so is it safe to assume this is now in production?

Thanks

@snehapar9
Copy link
Contributor

@aionic From this discussion looks like the changes have been rolled out. It may be possible for the version mismatch to still be there, but it seems to be working for other folks. Do you mind re-trying and letting me know if you still see the same issue?

ljrain added a commit to ljrain/rain-blog that referenced this issue Nov 19, 2023
trying new yaml found online.
microsoft/Oryx#2078
@simonjj
Copy link

simonjj commented Jan 12, 2024

This issue seems resolved. Will be closing this issue. If this is still relevant and impacting you please open a new issue and link back to this issue for reference.

@simonjj simonjj closed this as completed Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants