hugo icon indicating copy to clipboard operation
hugo copied to clipboard

Official GitHub Actions action does not work on macOS

Open myitcv opened this issue 2 years ago • 14 comments

What version of Hugo are you using (hugo version)?

$ hugo version
v0.112.1

Does this issue reproduce with the latest release?

Yes

Please can I confirm that https://github.com/peaceiris/actions-hugo is the official action to install Hugo in GitHub Actions workflows? Is there an official place where this is documented?

Assuming that it is, there are two blockers to using that action to install Hugo on macOS:

https://github.com/peaceiris/actions-hugo/issues/605 https://github.com/peaceiris/actions-hugo/issues/608

It feels like there should be an official Hugo-project owned and maintained action to make the installation of Hugo as part of GitHub Actions seamless.

Thoughts?

myitcv avatar May 24 '23 06:05 myitcv

Our recommended GitHub Action is based on GitHub's Starter Action for Hugo.

You would need to modify our recommended GitHub Action to be compatible with macOS. I have never tried this; I have never had a need to use anything other than Ubuntu in a CI/CD workflow.

Please use the forum (https://discourse.gohugo.io/) for questions and troubleshooting. We prefer to use GitHub for verified bugs and vetted enhancements. Thanks.

jmooring avatar May 24 '23 16:05 jmooring

I'll reopen this. It's limited what we as a project can do, but this issue is at least within the scope of things I care (and know a little) about.

bep avatar May 24 '23 17:05 bep

I'll reopen this.

Thanks @bep. My suggestion would be something like github.com/gohugoio/setup-hugo as a GitHub action that knows how to install Hugo on various platforms. In the same spirit as https://github.com/actions/setup-go and friends. That should be a relatively simple action, because all it would do is shim the installation of the binaries Hugo already produces for every platform.

The main use case here (and I'm sure I can't be the first to run into this) is to ensure that all developers of https://github.com/cue-lang/cuelang.org can reliably follow steps in a readme and know that they will work. That requires us to have a build matrix that includes macOS (and windows, at a later date).

myitcv avatar May 25 '23 04:05 myitcv

@myitcv yea, we can do something like that ... as to naming the repo ... setup-actions-hugo? Sounds a little clumsy, but it makes room for other "setup" repos later...

bep avatar May 25 '23 05:05 bep

Sounds a little clumsy, but it makes room for other "setup" repos later...

Do you know of any such patterns that exist today?

The setup-* pattern is so common with GitHub actions.

I'd suggest unless there are compelling reasons to stray from that (i.e. a clash with another very common pattern), the GitHub pattern is likely to dominate and hence be most "accessible" for folks.

myitcv avatar May 25 '23 08:05 myitcv

The setup-* pattern is so common with GitHub actions.

The example you gave had that context in the org name, actions/setup-go. Adding gohugoio/setup-hugo would

  1. Not tell me that it's about GitHub actions.
  2. Give an indication that it's an all purpose "Hugo setup tool", whatever that is...

bep avatar May 25 '23 14:05 bep

The example you gave had that context in the org name, actions/setup-go

That's a good point.

We (perhaps wrongly therefore) went with https://github.com/cue-lang/setup-cue.

Building on your context point, I'll throw ghactions-setup-hugo out there as an alternative.

cc @mvdan who often has good ideas re naming.

myitcv avatar May 25 '23 15:05 myitcv

How about action-setup-hugo or actions-setup-hugo? I don't think one needs to repeat github or shorten it like gh, since the repo is under github.com after all, and "actions" is a well known concept in the context of a GitHub repo already.

mvdan avatar May 30 '23 10:05 mvdan

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] avatar May 30 '24 01:05 github-actions[bot]

This is still relevant.

myitcv avatar May 30 '24 07:05 myitcv

Please feel free to run the latest and greatest versions of Hugo (extended) through a combination of actions/setup-python and pipx via the pipx run hugo==<your hugo version here> new site mysite command or similar commands of your liking. I would like to note that this distribution is unaffiliated with the Hugo developers here at the time of writing and is a community-maintained unofficial build.

agriyakhetarpal avatar May 30 '24 17:05 agriyakhetarpal

I would like this too, because:

  • Keeping the current "official" way up to date is cumbersome. I sometimes visit this gohugo.io documentation page to update my action workflow to use the current recommended commands
  • Currently no way to set version to 'latest'
  • I'd rather use an "official" action than one from a random gh user
  • The default action for deploying hugo on gh pages would be easy to grasp:
name: Deploy Hugo site to Pages

on:
  push:
    branches:
      - main

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Pages
        uses: actions/configure-pages@v5

      - name: Hugo
        uses: gohugoio/hugo-action@v1

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./public

      - name: Deploy to GitHub Pages
        uses: actions/deploy-pages@v4

I would also suggest that the action runs the hugo command to simplify general usage. Passing an args argument would allow for more advanced usage of Hugo. Therefore, I suggest the name to be hugo-action instead of setup-hugo, since it not only sets up hugo, but also runs it.

yochem avatar Aug 27 '24 11:08 yochem

Totally reasonable on your part, @yochem – I would have pitched for my own project and its builds, but I understand the lack of trust that can come from unofficial, community-maintained ones.

You could use the https://github.com/jmooring/hvm CLI tool to set up Hugo from the official releases with not too many lines of code.

agriyakhetarpal avatar Aug 27 '24 15:08 agriyakhetarpal

I could have a go with this if that's welcome.

There are 3 different approaches for building custom GH actions:

  1. Typescript/javascript. Runs native on runners, github provides modules to interact with actions inputs and more
  2. Docker. Very flexible, not so fast.
  3. Composed. This is like a normal actions workflow, where you define steps in the yaml file. Could for example be different shell commands. Also seems fast?

Approach 1 might not be desired because most other Hugo things are in Go.

Approach 2 might have a lot of overhead for the little that this action has to do (install and run hugo).

Approach 3 it is not clear if it can be done in Go. We could opt for a simple shell script

yochem avatar Sep 06 '24 13:09 yochem

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] avatar Sep 07 '25 02:09 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Nov 23 '25 02:11 github-actions[bot]