feat: include a hash of deno.lock files in the cache key automatically (#98)

This commit is contained in:
David Sherret
2025-05-13 12:53:56 -04:00
committed by GitHub
parent fd6b0ad149
commit 3169cf993b
12 changed files with 1993 additions and 830 deletions

View File

@@ -144,20 +144,38 @@ number.
### Caching dependencies downloaded by Deno automatically
Dependencies installed by Deno can be cached automatically, which is similar to
the [`cache` option in `setup-node`](https://github.com/actions/setup-node).
Dependencies installed by Deno can be cached automatically between workflow
runs. This helps make your GH action run faster by not repeating caching work
and network requests done by a previous run.
To enable the cache, use `cache: true`. It's recommended to also add the
`cache-hash` property, to scope caches based on lockfile changes.
To enable the cache, use `cache: true`.
```yaml
- uses: denoland/setup-deno@v2
with:
cache: true
cache-hash: ${{ hashFiles('**/deno.lock') }}
```
> [!WARNING]
> If an environment variable `DENO_DIR` is set for steps that run/download
> dependencies, then `DENO_DIR` must also be set for the `denoland/setup-deno`
> action, for the caching to work as intended.
By default, the cache is automatically keyed by:
- the github
[job_id](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_id)
- the runner os and architecture
- a hash of the `deno.lock` files in the project
It is possible to customize the default hash
(`${{ hashFiles('**/deno.lock') }}`) used as part of the cache key via the
`cache-hash` input.
```yaml
- uses: denoland/setup-deno@v2
with:
# setting `cache-hash` implies `cache: true` and will replace
# the default cache-hash of `${{ hashFiles('**/deno.lock') }}`
cache-hash: ${{ hashFiles('**/deno.json') }}
```