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

Deployment on GitHub Pages with Workflow action fails #1975

Closed
benjaminpope opened this issue May 1, 2024 · 5 comments
Closed

Deployment on GitHub Pages with Workflow action fails #1975

benjaminpope opened this issue May 1, 2024 · 5 comments
Labels
bug Something isn't working needs-triage

Comments

@benjaminpope
Copy link

Environment

  • Version of Docsy you are using: v0.9.2-0.20240423183652-ec13ca8f7f8a
  • How are you using Docsy? As a:
    • Hugo module
  • Version of Hugo you are using (output of hugo version): hugo v0.125.4+extended darwin/arm64 BuildDate=2024-04-25T13:27:26Z VendorInfo=brew

Problem

I am trying to deploy this website, which is a clone of the example site, to GitHub Pages using the officially recommended hugo.yaml workflow. I have added the following lines to the workflow to try and match the instructions:

    steps:
      - name: install npm
        run: |
          npm install --save-dev autoprefixer
          npm install --save-dev postcss-cli
          npm install -D postcss

hugo server builds locally just fine on my M1 MacBook Pro, but when I push to GitHub I get the following error in the workflow:

hugo: downloading modules …
hugo: collected modules in 11142 ms
Start building sites … 
hugo v0.125.4-cc3574ef4f41fccbe88d9443ed066eb10867ada2+extended linux/amd64 BuildDate=2024-04-25T13:27:26Z VendorInfo=gohugoio
Total in 14208 ms
Error: error building site: POSTCSS: failed to transform "/scss/main.css" (text/css). Check your PostCSS installation; install with "npm install postcss-cli". See https://gohugo.io/hugo-pipes/postcss/: binary with name "npx" not found
Error: Process completed with exit code 1.

If I downgrade to v0.9.1 and try again, I get a different error

hugo: downloading modules …
hugo: collected modules in 22735 ms
Start building sites … 
hugo v0.125.4-cc3574ef4f41fccbe88d9443ed066eb10867ada2+extended linux/amd64 BuildDate=2024-04-25T13:27:26Z VendorInfo=gohugoio
ERROR render of "home" failed: "/tmp/hugo_cache_runner/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.1/layouts/_default/baseof.html:4:7": execute of template failed: template: home.html:4:7: executing "home.html" at <partial "head.html" .>: error calling partial: execute of template failed: html/template:partials/head.html:53:[16](https://github.com/aew10/website/actions/runs/8908963883/job/24465502306#step:8:17): no such template "_internal/google_analytics_async.html"
ERROR render of "section" failed: "/tmp/hugo_cache_runner/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.1/layouts/_default/baseof.html:4:7": execute of template failed: template: _default/list.html:4:7: executing "_default/list.html" at <partial "head.html" .>: error calling partial: execute of template failed: html/template:partials/head.html:53:16: no such template "_internal/google_analytics_async.html"
Total in 22793 ms
Error: error building site: render: failed to render pages: render of "404" failed: "/tmp/hugo_cache_runner/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.9.1/layouts/_default/baseof.html:4:7": execute of template failed: template: 404.html:4:7: executing "404.html" at <partial "head.html" .>: error calling partial: execute of template failed: html/template:partials/head.html:53:16: no such template "_internal/google_analytics_async.html"

What is going on? Is there a workflow that anyone has that will just work for a GitHub Action?

@benjaminpope benjaminpope added bug Something isn't working needs-triage labels May 1, 2024
@deining
Copy link
Collaborator

deining commented May 1, 2024

What is going on? Is there a workflow that anyone has that will just work for a GitHub Action?

To run docsy with latest hugo version 0.125.4, some tweaking is needed, see #1973 for details.
I authored this PR which hopefully solves your problem. Can you give it a try, please?

@benjaminpope
Copy link
Author

Thank you - really appreciate your help!

Merged the PR - the workflow still fails. We get the error message about npx again:

Run hugo \
hugo: downloading modules …
hugo: collected modules in 24199 ms
Start building sites … 
hugo v0.125.4-cc3574ef4f41fccbe88d9443ed066eb10867ada2+extended linux/amd64 BuildDate=2024-04-25T[13](https://github.com/aew10/website/actions/runs/8918256442/job/24492572389#step:8:14):27:26Z VendorInfo=gohugoio

Total in 27202 ms
Error: error building site: POSTCSS: failed to transform "/scss/main.css" (text/css). Check your PostCSS installation; install with "npm install postcss-cli". See https://gohugo.io/hugo-pipes/postcss/: binary with name "npx" not found
Error: Process completed with exit code 1.

I can't see any Actions run on your fork - did it work for you?

@deining
Copy link
Collaborator

deining commented May 2, 2024

I revisited this issue and I was able to make it work by simply adding actions/setup-node to the workflow.
See my second, improved pull request and my successful action run in my own repo.
Also, have a look at the deployed site and enjoy!

@benjaminpope
Copy link
Author

Thank you - it works perfectly! This is really helpful! Perhaps would be of general interest to GitHub Actions users.

@deining
Copy link
Collaborator

deining commented May 3, 2024

Thank you - it works perfectly! This is really helpful!

Glad I could help out.

Perhaps would be of general interest to GitHub Actions users.

Yes indeed. I addressed this with my PR #1435, which has an approval already. This PR is waiting for merging for more than one year already 😞. Please note that this PR takes a different approach (which is more straightforward IMO).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants