Overwriting static files

I have some text files (CSS) in the static folder. During build I want to add some lines programatically. For that, I read the file, add the lines and afterwards use resources.FromString to store the result in the same filename.

Moving the files over to assets is not possible without introducing breaking behavior which I try to avoid.

While this worked for me on my local dev box and in my GitHub actions, I have a user that got errors during build:

ERROR Failed to publish Resource: open /home/runner/work/observability-workshop/observability-workshop/site/v5.[20](https://github.com/splunk/observability-workshop/actions/runs/7022846849/job/19108038477#step:4:22)/css/theme-relearn-light.css: permission denied
ERROR Failed to publish Resource: open /home/runner/work/observability-workshop/observability-workshop/site/v5.20/css/theme-relearn-dark.css: permission denied

See GitHub action issue with permissions · Issue #734 · McShelby/hugo-theme-relearn · GitHub

Is this a good idea or should I better use a modified filename instead? Do I have to expect race conditions?

In this case it was enough to run hugo with --noChmod.

You may also have run into this:
https://github.com/gohugoio/hugo/issues/7302

Which, at its core, is an OS restriction:
https://github.com/gohugoio/hugo/issues/7302#issuecomment-980639498

1 Like

Thanks for the references, Joe!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.