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

support: Actions/cache for Hugo modules with Hugo v0.127.0 #1081

Closed
3 tasks done
Zer0xxxx opened this issue Jun 18, 2024 · 5 comments · Fixed by peaceiris/actions-hugo#650
Closed
3 tasks done

support: Actions/cache for Hugo modules with Hugo v0.127.0 #1081

Zer0xxxx opened this issue Jun 18, 2024 · 5 comments · Fixed by peaceiris/actions-hugo#650
Assignees
Labels
support User support

Comments

@Zer0xxxx
Copy link

Zer0xxxx commented Jun 18, 2024

Checklist

  • I am using the latest version of this action.
  • I have read the latest README and followed the instructions.
  • I have read the latest GitHub Actions official documentation and learned the basic spec and concepts.

Describe your question

Hello!

I'm running on Hugo v0.127.0
And I'm also using a Hugo module (Blowfish).

From the docs of this GitHub Action:

    path: /home/runner/.cache/hugo_cache    # <-- with hugo version v0.116.0 and above
    # path: /tmp/hugo_cache                 # <-- with hugo version < v0.116.0

But, I've checked both folders in my CI, and don't find any of them.
I've even fired a ls -R /home/runner/
And a ls -R .

And I don't find any "hugo_cache"

It's weird, since I'm not using the --gc flag at the build of my Hugo website.
I did everything exactly as it is documented.

Also, this is quite annoying, because the download of the module is likely 78% of the duration of my CI/CD...

hugo: collected modules in 17347 ms

Also:

ls: cannot access '/home/runner/.cache/hugo_cache': No such file or directory
ls: cannot access '/home/runner/.cache': No such file or directory

And ls /tmp gives:

clr-debug-pipe-1618-22959-in
clr-debug-pipe-1618-22959-out
clr-debug-pipe-1635-23181-in
clr-debug-pipe-1635-23181-out
clr-debug-pipe-592-844-in
clr-debug-pipe-592-844-out
dotnet-diagnostic-1618-22959-socket
dotnet-diagnostic-1635-23181-socket
dotnet-diagnostic-592-844-socket
hugo_cache_runner
snap-private-tmp
systemd-private-400d24fb912f435db1794cbdf1e0ff7c-chrony.service-PXMl8E
systemd-private-400d24fb912f435db1794cbdf1e0ff7c-haveged.service-QZT8c2
systemd-private-400d24fb912f435db1794cbdf1e0ff7c-systemd-logind.service-E0KxuY
systemd-private-400d24fb912f435db1794cbdf1e0ff7c-systemd-resolved.service-ZNa6Mx
www-data-temp-aspnet-0

There is a hugo_cache_runner here, but it seems to be pointless in this context...

Any clue?

Relevant links

Public repository: https://github.com/chill-utility/chill-utility.github.io
YAML config: https://github.com/chill-utility/chill-utility.github.io/blob/main/.github/workflows/deploy.yml
Hugo's forum topic: https://discourse.gohugo.io/t/how-to-cache-hugo-modules-in-a-github-action/50334

Relevant log output

No response

Additional context.

No response

@Zer0xxxx Zer0xxxx added the support User support label Jun 18, 2024
@Zer0xxxx
Copy link
Author

Oh, okay, finally found the right way to do it.
Just defining the env variable and rely on it seems to be perfectly safe.

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      HUGO_VERSION: 0.127.0
      HUGO_CACHEDIR: /tmp/hugo_cache
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v4
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: ${{ env.HUGO_VERSION }}

      - uses: actions/cache@v4
        with:
          path: ${{ env.HUGO_CACHEDIR }}
          key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-hugomod-

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

@peaceiris
Copy link
Owner

Looks good 👍

Hugo can define its cache directory by HUGO_CACHEDIR env.
https://gohugo.io/getting-started/configuration/#configure-cachedir

@Zer0xxxx
Copy link
Author

Zer0xxxx commented Jun 19, 2024

Looks good 👍

Hugo can define its cache directory by HUGO_CACHEDIR env. https://gohugo.io/getting-started/configuration/#configure-cachedir

I think the documentation snippet (from the ⭐️ Caching Hugo Modules tips section) should be updated with the HUGO_CACHEDIR env parameter directly set to some path, in order to harmonize all of this and avoid confusion about the use of the action. What are your thoughts?

@peaceiris
Copy link
Owner

I agree! Could you open your PR to fix the section on https://github.com/peaceiris/actions-hugo?

@Zer0xxxx
Copy link
Author

Zer0xxxx commented Jun 19, 2024

I agree! Could you open your PR to fix the section on https://github.com/peaceiris/actions-hugo?

At your service 🧡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants