Closed simonw closed 2 years ago
I think I figured out a pattern to do this. The cache: npm
option requires either a package.json
or yarn.lock
file... or you can give it a custom path.
I'm now doing this:
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
cache-dependency-path: '**/.github/workflows/*.yml'
Since the tools that might be run using npx
are defined in my workflow YAML, I'm using the workflow YAML itself as the cache-dependency-path
.
It looks like this works, so I'm happy to keep using this pattern.
Wrote this up here: https://til.simonwillison.net/github-actions/npm-cache-with-npx-no-package
Some of my actions use
npx
to run commands, for example:Is there a way to configure the Actions cache such that
npx
doesn't download packages when it runs every single time, without needing to add apackage.json
file to the repository?