GitHub Action to build my site doesn't have permission to create /resource directory?

My Hugo site (https://github.com/EOCOnline/eoconline.github.io) builds & runs fine locally, on my Windows desktop.

However, the Github Action/workflow
https://github.com/EOCOnline/eoconline.github.io/blob/main/.github/workflows/main.yml
fails with
`ERROR mkdir /resourceCache: permission denied
Total in 2065 ms

Error: error building site: render: failed to render pages: render of “404” failed: “/home/runner/work/eoconline.github.io/eoconline.github.io/themes/eoconline/layouts/_default/baseof.html:38:7”: execute of template failed: template: 404.en.html:38:7: executing “404.en.html” at <partial “essentials/header.html” .>: error calling partial: “/home/runner/work/eoconline.github.io/eoconline.github.io/themes/eoconline/layouts/partials/essentials/header.html:8:11”: execute of template failed: template: partials/essentials/header.html:8:11: executing “partials/essentials/header.html” at <partial “logo”>: error calling partial: “/tmp/hugo_cache_runner/modules/filecache/modules/pkg/mod/github.com/gethugothemes/hugo-modules/images@v0.0.0-20240711030223-49ae4a26e064/layouts/partials/logo.html:83:33”: execute of template failed: template: partials/logo.html:83:33: executing “partials/logo.html” at <$logo.Resize>: error calling Resize: mkdir /resourceCache: permission denied

Error: Process completed with exit code 1.`

(In hugo.toml I’ve added resourceDir = "/resourceCache/", since I’m offering “resources” to folks.)

I’ve tried:

  • reading lots of docs
  • ensuring I was using Hugo-extended (required by the Resize command)
  • git update-index --chmod=+x .github/workflows/main.yml
  • set GITHUB_TOKEN permissions within main.yml to write-all
  • removing resourceCache from my gitignore file, so the directories are already there & need not be created
  • coffee & sugar & sleep

Any other ideas?!

Why do you have two workflows for deploying to GitHub Pages?

If you want to deploy to GitHub Pages, use these instructions:
https://gohugo.io/hosting-and-deployment/hosting-on-github/

The documented workflow file is used by hundreds or perhaps thousands of sites. Works great.

Thanks for validating that process is still valid!

I’ve read/followed about 5 guides to doing this now (including that one early on!), so am not sure what script came from where. Nothing has worked yet, although I had a variety of earlier errors that I might have shot myself in the foot with…

I also tried the only GitHub workflow that comes up if searching for “Hugo”:

OK, I’ve gone to just your suggested workflow & I still get the same error.

I’ve gone back to the default for resouceDir - renaming mine as resources2.

Oh, now I’ve a new error: postCss is installed & seems to work locally, but apparently isn’t installed in my remote environment. I’ll look into that next…

THANKS jm!

You need to include package-lock.json in source control in order for npm ci to install the dependencies.

OMG! Dancing with joy over here on the left side of the US. So many thanks Joe. On a Saturday none-the-less.

I did have to revert to the default publishDir, but that was an artifact of some bad idea I had anyway.

Much appreciated! :partying_face: