From 288264f9c9c4a54b634fdbfdc119faefe699d549 Mon Sep 17 00:00:00 2001 From: Zer0xxxx <36828641+Zer0xxxx@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:09:50 +0200 Subject: [PATCH] docs: add env.HUGO_CACHEDIR (#650) --- README.md | 20 +++++++++++++++++--- package-lock.json | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bc44011..9a7750e 100644 --- a/README.md +++ b/README.md @@ -151,13 +151,27 @@ This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](htt ### ⭐️ Caching Hugo Modules Insert a cache step before site-building as follows. -Note that with latest hugo version, the [cache dir location](https://gohugo.io/getting-started/configuration/#configure-cachedir) on a Linux-based operating system is `${HOME}/.cache`. On macOS, `${HOME}/Library/Caches` has the location. + +First, to maximize compatibility with all Hugo versions, let's define the variable `HUGO_CACHEDIR`: + +```yaml +# * ... + +jobs: + deploy: + runs-on: ubuntu-22.04 + env: + HUGO_CACHEDIR: /tmp/hugo_cache # <- Define the env variable here, so that Hugo's cache dir is now predictible in your workflow and doesn't depend on the Hugo's version you're using. + +# * ... +``` + +Now, let's add the cache action call just above the _Build_ step: ```yaml - uses: actions/cache@v4 with: - path: /home/runner/.cache/hugo_cache # <-- with hugo version v0.116.0 and above - # path: /tmp/hugo_cache # <-- with hugo version < v0.116.0 + path: ${{ env.HUGO_CACHEDIR }} # <- Use the same env variable just right here key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-hugomod- diff --git a/package-lock.json b/package-lock.json index e1369b9..6647a60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "actions-hugo", - "version": "2.6.0", + "version": "3.0.0", "hasInstallScript": true, "license": "MIT", "dependencies": {