McShelby / hugo-theme-relearn

A theme for Hugo designed for documentation
https://mcshelby.github.io/hugo-theme-relearn/
MIT License
385 stars 179 forks source link

GitHub action issue with permissions #734

Closed rcastley closed 9 months ago

rcastley commented 10 months ago

Hi,

When I try to deploy using GitHub actions I am hit a permissions issue with the CSS files:

Prepare all required actions
Run ./.github/actions/deploy
Run ./.github/ci/do_release -t minor

Already up to date.
[main 8c6b45a36] Releasing v5.[2](https://github.com/splunk/observability-workshop/actions/runs/7022846849/job/19108038477#step:4:2)0
 Date: Tue Nov 2[8](https://github.com/splunk/observability-workshop/actions/runs/7022846849/job/19108038477#step:4:9) 18:18:[15](https://github.com/splunk/observability-workshop/actions/runs/7022846849/job/19108038477#step:4:17) 2023 +0000
 8 files changed, 9 insertions(+), 9 deletions(-)
To https://github.com/splunk/observability-workshop
   5dd339631..8c6b45a36  main -> main
 * [new tag]             v5.20 -> v5.20
Run ./.github/ci/build_site -b https://splunk.github.io/ -t 5.20

hugo: downloading modules …
hugo: collected modules in 4432 ms
Start building sites … 
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:[17](https://github.com/splunk/observability-workshop/actions/runs/7022846849/job/19108038477#step:4:19)Z VendorInfo=gohugoio

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
Total in 10010 ms
Error: error building site: logged 2 error(s)
Error: Process completed with exit code 1.

I am using v0.119 for deployment and using hugo get mod -u to update the theme.

Thank you!

rcastley commented 10 months ago

FYI, reverting back to v0.0.0-20231116235917 fixes the issue.

McShelby commented 10 months ago

This seems like a permission issue on your side. The upcoming release 5.24.0 will first copy and then may overwrite the color variant files during the build step. This does not cause issues in the build actions of this repo.

I may have a workaround for this, but first try to find out why your build action is not allowed to overwrite files.

McShelby commented 9 months ago

@rcastley I am in the final steps of preparation for a new release, but would have a better feeling if I know what's going on here. Do you have any news? Your Github actions look rather unconventional as they are not using the usual predefined hugo actions but seem to be self written. Anything I might should know here?

rcastley commented 9 months ago

I am really sorry but due to unforeseen family circumstances I am unable to test ATM ... thank you so much for your reply/response ... my rollback to an earlier version is working for now ... I will be back on this once we are through this period. Thank you for your time and your understanding.

rcastley commented 9 months ago

The GitHub Actions we use are here - https://github.com/splunk/observability-workshop/tree/main/.github ... I am happy to change this to something more standard to adopt your changes. Thank you again!

McShelby commented 9 months ago

I (and many others) use this https://github.com/peaceiris/actions-hugo but I am not sure if this covers your use case. You can take a look into the .github directory of this theme to see, how I use it in companion with GitHub pages.

A complete list of external GitHub actions used for this themes is in the docs credits: https://mcshelby.github.io/hugo-theme-relearn/more/credits/index.html#tooling-dependencies

McShelby commented 9 months ago

https://discourse.gohugo.io/t/overwriting-static-files/47303

rcastley commented 9 months ago

Thank you 👍🏻

McShelby commented 9 months ago

Seems that my Discourse topic was to niche. I've searched a bit further. Maybe it helps to run hugo with the --noChmod option during build. If this does not help, you can maybe fiddle around with file permissions as described here: https://discourse.gohugo.io/t/file-mode-in-static-folder/27891

McShelby commented 9 months ago

I've pushed a change which hopefully helps you. From the hugo.toml:

# Filename suffix for variant files
# Default: not set
# The theme modifies the variant stylesheets during build and tries to store
# them with the same file name. In certain installations it was observed, that
# Hugo could not overwrite these files due to permission issues. If you
# experience this, you can set this option to eg. ".gen". This will be used
# as a suffix for these generated files, causing them be newly created instead
# of overwriting existing ones.
themeVariantModifier = ""
rcastley commented 9 months ago

Good evening ... the noChmod did the trick, thank you so much 🥇

hugo --minify --destination "site/v${TAG_NAME}" --baseURL "${BASE_URL}observability-workshop/v$TAG_NAME" --noChmod

Successful deployment using:

github.com/McShelby/hugo-theme-relearn v0.0.0-20231203143443-7c97f7b6109f/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=

Thank you again, really much appreciated!

McShelby commented 9 months ago

Great to hear. Thanks for the feedback!

rcastley commented 9 months ago

@McShelby Good Evening, just to let you know that even using the documented Hugo GitHub Action requires --noChmod to be added

https://gohugo.io/hosting-and-deployment/hosting-on-github/#procedure

Just incase other uses are facing any issues.

elgordino commented 8 months ago

For anyone hitting this issue using CloudCannon the --noChmod fix will correct it.

The error for reference

ERROR Failed to publish Resource: open /usr/local/__site/src/public/css/theme-relearn-light.css: permission denied
ERROR Failed to publish Resource: open /usr/local/__site/src/public/css/theme-relearn-dark.css: permission denied

The fix:

ScrumpyJack commented 7 months ago

I'm getting the same problem but just running hugo serve

Watching for changes in /Users/jack/src/docs/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /Users/jack/src/docs/hugo.toml, /Users/jack/src/docs/themes/hugo-theme-relearn/hugo.toml, /Users/jack/src/docs/go.mod
Start building sites …
hugo v0.123.3-a75a659f6fc0cb3a52b2b2ba666a81f79a459376+extended darwin/amd64 BuildDate=2024-02-23T17:09:20Z VendorInfo=brew

ERROR Failed to publish Resource: open /Users/jack/src/docs/public/css/theme-relearn-light.css: permission denied
ERROR Failed to publish Resource: open /Users/jack/src/docs/public/css/theme-relearn-dark.css: permission denied
Built in 1287 ms
Error: error building site: logged 2 error(s)

Permissions on those files are

-r--r--r-- 1 jack staff 3350 Feb 25 10:11 /Users/jack/src/docs/public/css/theme-relearn-dark.css
-r--r--r-- 1 jack staff 3246 Feb 25 10:11 /Users/jack/src/docs/public/css/theme-relearn-light.css

Permissions on the original in /Users/jack/src/docs/ are

🦄 ❯ ls themes/hugo-theme-relearn/static/css -l
total 364
-rw-r--r-- 1 jack staff  1756 Feb 24 14:15 auto-complete.css
-rw-r--r-- 1 jack staff  4653 Feb 24 14:15 chroma-learn.css
-rw-r--r-- 1 jack staff  4480 Feb 24 14:15 chroma-neon.css
-rw-r--r-- 1 jack staff  4534 Feb 24 14:15 chroma-relearn-dark.css
-rw-r--r-- 1 jack staff  4693 Feb 24 14:15 chroma-relearn-light.css
-rw-r--r-- 1 jack staff 59305 Feb 24 14:15 fontawesome-all.min.css
-rw-r--r-- 1 jack staff  1167 Feb 24 14:15 fonts.css
-rw-r--r-- 1 jack staff 26359 Feb 24 14:15 ie.css
-rw-r--r-- 1 jack staff  4671 Feb 24 14:15 nucleus.css
-rw-r--r-- 1 jack staff  2171 Feb 24 14:15 perfect-scrollbar.min.css
-rw-r--r-- 1 jack staff    28 Feb 24 14:15 print.css
-rw-r--r-- 1 jack staff 65276 Feb 24 14:15 swagger-dark.css
-rw-r--r-- 1 jack staff     0 Feb 24 14:15 swagger-light.css
-rw-r--r-- 1 jack staff  8839 Feb 24 14:15 swagger.css
-rw-r--r-- 1 jack staff   922 Feb 24 14:15 tags.css
-rw-r--r-- 1 jack staff  2875 Feb 24 14:15 theme-blue.css
-rw-r--r-- 1 jack staff  2873 Feb 24 14:15 theme-green.css
-rw-r--r-- 1 jack staff  3062 Feb 24 14:15 theme-learn.css
-rw-r--r-- 1 jack staff 11845 Feb 24 14:15 theme-neon.css
-rw-r--r-- 1 jack staff  2866 Feb 24 14:15 theme-red.css
-rw-r--r-- 1 jack staff  3582 Feb 24 14:15 theme-relearn-bright.css
-rw-r--r-- 1 jack staff  3350 Feb 24 14:15 theme-relearn-dark.css
-rw-r--r-- 1 jack staff  3246 Feb 24 14:15 theme-relearn-light.css
-rw-r--r-- 1 jack staff   136 Feb 24 14:15 theme-relearn.css
-rw-r--r-- 1 jack staff  4224 Feb 24 14:15 theme-zen-dark.css
-rw-r--r-- 1 jack staff  4257 Feb 24 14:15 theme-zen-light.css
-rw-r--r-- 1 jack staff 49497 Feb 24 14:15 theme.css
-rw-r--r-- 1 jack staff  9284 Feb 24 14:15 variant-internal.css
-rw-r--r-- 1 jack staff 13450 Feb 24 14:15 variant.css
McShelby commented 7 months ago

In this topic are two ways outlined to solve your issue: --noChmod and themeVariantModifier.

vincentmaule commented 6 months ago

In this topic are two ways outlined to solve your issue: --noChmod and themeVariantModifier.

Hello, I have attempted myself with doing adding theme as a Hugo Module:

[User@Machine:~/Folder]$ cat hugo.toml 
baseURL = 'https://site'
languageCode = 'en-us'
title = ''
theme = "hugo-theme-relearn"

[outputs]
  home = ['html', 'rss', 'search', 'searchpage']

[module]
[[module.imports]]
    path = 'github.com/McShelby/hugo-theme-relearn'

[params]
  description = ''
  disableNextPrev = true

[[params.themeVariant]]
    auto = ['zen-light', 'zen-dark']
    identifier = 'zen-auto'
    name = 'Zen Light/Dark'
[User@Machine:~/Folder]$ hugo --noChmod
Start building sites … 
hugo v0.120.3+extended linux/amd64 BuildDate=unknown VendorInfo=nixpkgs

ERROR Failed to publish Resource: open /public/css/theme-relearn-light.css: permission denied
ERROR Failed to publish Resource: open /public/css/theme-relearn-dark.css: permission denied
Total in 228 ms
Error: error building site: logged 2 error(s)

Anything else you can recommend I try?


Just realizing this issue is closed, should I open a new one?

McShelby commented 6 months ago

Yes please.