Hi, I am trying to create a github action to deploy my hugo site on githib pages. I keep getting the error described below. Maybe someone has encountered this.
This is my gh-pages.yml file
name: github pages
on:
push:
branches:
- live # Set a branch that will trigger a deployment
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Install Dart Sass Embedded # Installs dart-sass
run: sudo snap install dart-sass-embedded
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true
- name: NPM Install # runs npm install to get dependancies
run: npm ci
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
The script fails on the build step:
Start building sites …
hugo v0.108.0-a0d64a46e36dd2f503bfd5ba1a5807b900df231d+extended linux/amd64 BuildDate=2022-12-06T13:37:56Z VendorInfo=gohugoio
Error: Error building site: TOCSS-DART: failed to transform "scss/main.scss" (text/x-scss): "/home/runner/work/website/website/assets/scss/third-party/bootstrap.scss:2:8": Cannot open file
Total in 679 ms
Error: Process completed with exit code 255.
The main error being Cannot open file. Not sure if this is a permissions error or a dart sass error, or something else.
I have no idea about using Snap with GitHub Actions, but here’s the step in my Hugo repo’s GHA that gets Embedded Dart Sass (after having supplied the version, earlier in the GHA, through the environment variable DART_SASS_VERSION):
Also: in Dart Sass, you don’t want to use @import, which was part of the now-deprecated Libsass. Instead, you should use @use, as explained in this Medium article.
Finally, I am assuming (since you didn’t say otherwise) that you have correctly set the transpiler to use Dart Sass, as briefly described in the documentation. For example, my head for each page on my Hugo repo has:
The underlying problem was lack of access to $HOME, due to:
An incorrect assumption on my part, and more importantly…
Inadequate testing (@use and @import rules outside of the pwd without mounting to assets)
I apologize for the inconvenience.
@ ivanbacher I would greatly appreciate it if you could test by reverting your workflow to use sudo snap install dart-sass-embedded. No other changes are required. Please post your findings.
Thanks for the reply and sharing your Hugo repo’s github action. Interesting to read through the file. Regarding the @use vs @import for sass, unfortunately bootstrap does not support @use out of the box yet.