Skip to content

Commit

Permalink
add cache-dependency-path
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Jan 25, 2024
1 parent 44bead6 commit b2a8802
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
</table>
📝 Installs [Typst] for GitHub Actions \
⚡ Caches installation files and packages
⚡ Caches Typst installation in the tool cache \
📦 Caches [Typst packages]() as dependencies
## Usage
Expand Down Expand Up @@ -49,10 +50,9 @@ jobs:
`0.10` or `0.x`. You can also specify `latest` to always use
the latest version. The default is `latest`.

- **`packages-id`:** The identifier of a group of packages to be
cached, to distinguish between different groups of packages
and to flush the cache folder. The default is -1, which means
no caching.
- **`cache`:** Whether or not to cache any Typst packages installed during the workflow. Defaults to `true`.

- **`cache-dependency-path`:** This should be any `.typ` file that when changed you wish to invalidate previous Typst package caches. By default it's `**/*.typ`.

### Outputs

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
cache:
description: Whether or not to cache any Typst packages installed during the workflow. Defaults to 'true'.
default: true
cache-dependency-path:
description: This should be any '.typ' file that when changed you wish to invalidate previous Typst package caches. By default it's '**/*.typ'.
default: "**/*.typ"

outputs:
typst-version:
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (core.getBooleanInput("cache")) {
darwin: () => join(process.env.HOME!, "Library/Caches", "typst/packages"),
win32: () => join(process.env.LOCALAPPDATA!, "typst/packages"),
}[process.platform as string]!();
const hash = await glob.hashFiles("**/*.typ");
const hash = await glob.hashFiles(core.getInput("cache-dependency-path"));
const primaryKey = `typst-packages-cache-${process.env.RUNNER_OS}-${hash}`;
core.saveState("cache-primary-key", primaryKey);
core.info(`Restoring ${cacheDir} with key ${primaryKey}`);
Expand Down

0 comments on commit b2a8802

Please sign in to comment.