Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jobs:
uses: ./
with:
cache: true
cache-hash: ${{ hashFiles('**/deno.lock') }}

- name: Download dependencies for cache
run: deno install --global --no-config npm:cowsay@1.6.0
Expand All @@ -110,7 +109,6 @@ jobs:
uses: ./
with:
cache: true
cache-hash: ${{ hashFiles('**/deno.lock') }}

- name: Run with cached dependencies
run: deno run --cached-only --no-config -RE npm:cowsay@1.6.0 "It works!"
Expand Down
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
description: Cache downloaded modules & packages automatically in GitHub Actions cache.
default: "false"
cache-hash:
description: A hash used as part of the cache key. Use e.g. `$\{{ hashFiles('**/deno.lock') }}` to cache based on the lockfile contents.
description: A hash used as part of the cache key, which defaults to a hash of the deno.lock files.
outputs:
cache-hit:
description: A boolean indicating whether the cache was hit.
Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"imports": {
"@actions/cache": "npm:@actions/cache@^4.0.3",
"@actions/core": "npm:@actions/core@^1.11.1",
"@actions/glob": "npm:@actions/glob@^0.5.0",
"@actions/tool-cache": "npm:@actions/tool-cache@^2.0.2",
"@types/node": "npm:@types/node@^22.15.0",
"@types/semver": "npm:@types/semver@^7.7.0",
Expand Down
11 changes: 10 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions dist/cache-ByPW8-iO.mjs

This file was deleted.

4 changes: 4 additions & 0 deletions dist/cache-D7LLZXo3.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "./semver-DmxAwBYV.mjs";
import { restoreCache, saveCache } from "./cache-zjpbixka.mjs";

export { restoreCache };
Loading