Compare commits

..

17 Commits
v5.0.3 ... main

Author SHA1 Message Date
Bassem Dghaidi
b45623637f
Merge pull request #1690 from XZTDean/docs/v5-example-update
docs: Update examples to use the latest version
2026-01-29 11:36:35 +01:00
Bassem Dghaidi
bdb94ce451
Merge branch 'main' into docs/v5-example-update 2026-01-29 11:32:26 +01:00
Bassem Dghaidi
cb6ea63971
Merge pull request #1699 from actions/Link-/fix-workflow-permissions
Fix workflow permissions and cleanup workflow names / formatting
2026-01-29 11:31:19 +01:00
Bassem Dghaidi
49bc452f55 Merge branch 'Link-/fix-workflow-permissions' of github.com:actions/cache into Link-/fix-workflow-permissions 2026-01-29 02:27:40 -08:00
Bassem Dghaidi
1e06c934a1
Merge branch 'main' of github.com:actions/cache into Link-/fix-workflow-permissions 2026-01-29 02:27:32 -08:00
Bassem Dghaidi
a838313d22
Merge pull request #1697 from actions/alert-autofix-52
Potential fix for code scanning alert no. 52: Workflow does not contain permissions
2026-01-29 11:26:02 +01:00
Bassem Dghaidi
6e48a73476
Update .github/workflows/pr-opened-workflow.yml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-29 11:25:11 +01:00
Bassem Dghaidi
9848277c90 Cleanup workflow file names 2026-01-29 02:19:45 -08:00
Bassem Dghaidi
94056f1871 Fix workflow permissions and cleanup 2026-01-29 02:17:35 -08:00
Bassem Dghaidi
b56bb3a202 Fix permissions for workflows/workflow.yml 2026-01-29 02:11:09 -08:00
Bassem Dghaidi
4a6586c009
Merge branch 'main' into alert-autofix-52 2026-01-29 11:04:16 +01:00
Bassem Dghaidi
0de23fd4eb
Merge pull request #1696 from actions/Link-/release-docs
Add release instructions and update maintainer docs
2026-01-29 11:03:40 +01:00
Bassem Dghaidi
4e38c8636e
Potential fix for code scanning alert no. 52: Workflow does not contain permissions
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-01-29 11:02:45 +01:00
Bassem Dghaidi
24e8b877a8 Add note 2026-01-29 01:58:41 -08:00
Bassem Dghaidi
3baa5f1c7b Update contribution docs 2026-01-29 01:58:05 -08:00
XZTDean
5b7a9f8ae5 docs: Update other actions in examples to the latest version 2025-12-15 06:34:21 -08:00
XZTDean
de99935c0c docs: Update examples to cache@v5 2025-12-15 06:15:33 -08:00
17 changed files with 182 additions and 136 deletions

View File

@ -1,4 +1,4 @@
name: Check dist/ name: Check dist content
on: on:
push: push:
@ -11,6 +11,9 @@ on:
- '**.md' - '**.md'
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
call-check-dist: call-check-dist:
name: Check dist/ name: Check dist/

View File

@ -1,4 +1,5 @@
name: Close inactive issues name: Close inactive issues
on: on:
schedule: schedule:
- cron: "30 8 * * *" - cron: "30 8 * * *"

View File

@ -1,4 +1,4 @@
name: "Code scanning - action" name: Code scanning
on: on:
push: push:
@ -6,15 +6,14 @@ on:
schedule: schedule:
- cron: '0 19 * * 0' - cron: '0 19 * * 0'
permissions:
contents: read
security-events: write
jobs: jobs:
CodeQL-Build: CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5

View File

@ -1,7 +1,12 @@
name: Assign issue name: Assign issue
on: on:
issues: issues:
types: [opened] types: [opened]
permissions:
issues: write
jobs: jobs:
run-action: run-action:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -1,4 +1,4 @@
name: Licensed name: License check
on: on:
push: push:
@ -9,6 +9,9 @@ on:
- main - main
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
validate-cached-dependency-records: validate-cached-dependency-records:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -1,7 +1,12 @@
name: Add Reviewer PR name: Assign pull request reviewer
on: on:
pull_request_target: pull_request_target:
types: [opened] types: [opened]
permissions:
pull-requests: write
jobs: jobs:
run-action: run-action:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -1,17 +1,17 @@
name: 'Publish Immutable Action Version' name: Publish immutable action
on: on:
release: release:
types: [released] types: [released]
jobs:
publish:
runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
id-token: write id-token: write
packages: write packages: write
jobs:
publish:
runs-on: ubuntu-latest
steps: steps:
- name: Checking out - name: Checking out
uses: actions/checkout@v5 uses: actions/checkout@v5

View File

@ -1,4 +1,5 @@
name: Release new action version name: Release new action version
on: on:
release: release:
types: [released] types: [released]
@ -10,6 +11,7 @@ on:
env: env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
permissions: permissions:
contents: write contents: write

View File

@ -10,6 +10,9 @@ on:
- main - main
- releases/** - releases/**
permissions:
contents: read
jobs: jobs:
# Build and unit test # Build and unit test
build: build:
@ -57,6 +60,7 @@ jobs:
path: | path: |
test-cache test-cache
~/test-cache ~/test-cache
test-restore: test-restore:
needs: test-save needs: test-save
strategy: strategy:
@ -104,6 +108,7 @@ jobs:
with: with:
key: test-proxy-${{ github.run_id }} key: test-proxy-${{ github.run_id }}
path: test-cache path: test-cache
test-proxy-restore: test-proxy-restore:
needs: test-proxy-save needs: test-proxy-save
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -16,7 +16,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c
1. [Fork][fork] and clone the repository 1. [Fork][fork] and clone the repository
2. Configure and install the dependencies: `npm install` 2. Configure and install the dependencies: `npm install`
3. Make sure the tests pass on your machine: `npm run test` 3. Make sure the tests pass on your machine: `npm run test`
4. Create a new branch: `git checkout -b my-branch-name` 4. Create a new branch: `git switch -c my-branch-name`
5. Make your change, add tests, and make sure the tests still pass 5. Make your change, add tests, and make sure the tests still pass
6. Push to your fork and [submit a pull request][pr] 6. Push to your fork and [submit a pull request][pr]
7. Pat your self on the back and wait for your pull request to be reviewed and merged. 7. Pat your self on the back and wait for your pull request to be reviewed and merged.

View File

@ -123,11 +123,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: ${{ runner.os }}-primes key: ${{ runner.os }}-primes
@ -154,11 +154,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Restore cached Primes - name: Restore cached Primes
id: cache-primes-restore id: cache-primes-restore
uses: actions/cache/restore@v4 uses: actions/cache/restore@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -169,7 +169,7 @@ jobs:
. .
- name: Save Primes - name: Save Primes
id: cache-primes-save id: cache-primes-save
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -224,7 +224,7 @@ A cache key can include any of the contexts, functions, literals, and operators
For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change. For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -242,7 +242,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash shell: bash
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: path/to/dependencies path: path/to/dependencies
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }} key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}
@ -262,9 +262,9 @@ Example:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache@v4 - uses: actions/cache@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -292,11 +292,11 @@ jobs:
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: primes key: primes
@ -307,7 +307,7 @@ jobs:
- name: Cache Numbers - name: Cache Numbers
id: cache-numbers id: cache-numbers
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: numbers path: numbers
key: primes key: primes
@ -319,11 +319,11 @@ jobs:
build-windows: build-windows:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: primes key: primes

View File

@ -1,5 +1,28 @@
# Releases # Releases
## How to prepare a release
> [!NOTE]
> Relevant for maintainers with write access only.
1. Switch to a new branch from `main`.
1. Run `npm test` to ensure all tests are passing.
1. Update the version in [`package.json`](package.json).
1. Run `npm run build` to update the compiled files.
1. Update this [`RELEASES.md`](RELEASES.md) with the new version and changes in the `## Changelog` section.
1. Run `licensed cache` to update the license report.
1. Run `licensed status` and resolve any warnings by updating the [`.licensed.yml`](.licensed.yml) file with the exceptions.
1. Commit your changes and push your branch upstream.
1. Open a pull request against `main` and get it reviewed and merged.
1. Draft a new release https://github.com/actions/cache/releases use the same version number used in `package.json`
1. Create a new tag with the version number.
1. Auto generate release notes and update them to match the changes you made in `RELEASES.md`.
1. Toggle the set as the latest release option.
1. Publish the release.
1. Navigate to https://github.com/actions/cache/actions/workflows/release-new-action-version.yml
1. There should be a workflow run queued with the same version number.
1. Approve the run to publish the new version and update the major tags for this action.
## Changelog ## Changelog
### 5.0.3 ### 5.0.3

View File

@ -12,7 +12,7 @@ This document lists some of the strategies (and example workflows if possible) w
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
key: ${{ some-metadata }}-cache key: ${{ some-metadata }}-cache
``` ```
@ -24,7 +24,7 @@ In your workflows, you can use different strategies to name your key depending o
One of the most common use case is to use hash for lockfile as key. This way, same cache will be restored for a lockfile until there's a change in dependencies listed in lockfile. One of the most common use case is to use hash for lockfile as key. This way, same cache will be restored for a lockfile until there's a change in dependencies listed in lockfile.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -37,7 +37,7 @@ One of the most common use case is to use hash for lockfile as key. This way, sa
If cache is not found matching the primary key, restore keys can be used to download the closest matching cache that was recently created. This ensures that the build/install step will need to additionally fetch just a handful of newer dependencies, and hence saving build time. If cache is not found matching the primary key, restore keys can be used to download the closest matching cache that was recently created. This ensures that the build/install step will need to additionally fetch just a handful of newer dependencies, and hence saving build time.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -54,7 +54,7 @@ The restore keys can be provided as a complete name, or a prefix, read more [her
In case of workflows with matrix running for multiple Operating Systems, the caches can be stored separately for each of them. This can be used in combination with hashfiles in case multiple caches are being generated per OS. In case of workflows with matrix running for multiple Operating Systems, the caches can be stored separately for each of them. This can be used in combination with hashfiles in case multiple caches are being generated per OS.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -73,7 +73,7 @@ Caches scoped to the particular workflow run id or run attempt can be stored and
On similar lines, commit sha can be used to create a very specialized and short lived cache. On similar lines, commit sha can be used to create a very specialized and short lived cache.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -86,7 +86,7 @@ On similar lines, commit sha can be used to create a very specialized and short
Cache key can be formed by combination of more than one metadata, evaluated info. Cache key can be formed by combination of more than one metadata, evaluated info.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -146,9 +146,9 @@ In case you are using a centralized job to create and save your cache that can b
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -171,9 +171,9 @@ You can use the output of this action to exit the workflow on cache miss. This w
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -194,7 +194,7 @@ steps:
If you want to avoid re-computing the cache key again in `save` action, the outputs from `restore` action can be used as input to the `save` action. If you want to avoid re-computing the cache key again in `save` action, the outputs from `restore` action can be used as input to the `save` action.
```yaml ```yaml
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: restore-cache id: restore-cache
with: with:
path: | path: |
@ -204,7 +204,7 @@ If you want to avoid re-computing the cache key again in `save` action, the outp
. .
. .
. .
- uses: actions/cache/save@v4 - uses: actions/cache/save@v5
with: with:
path: | path: |
path/to/dependencies path/to/dependencies
@ -219,7 +219,7 @@ On the other hand, the key can also be explicitly re-computed while executing th
Let's say we have a restore step that computes key at runtime Let's say we have a restore step that computes key at runtime
```yaml ```yaml
uses: actions/cache/restore@v4 uses: actions/cache/restore@v5
id: restore-cache id: restore-cache
with: with:
key: cache-${{ hashFiles('**/lockfiles') }} key: cache-${{ hashFiles('**/lockfiles') }}
@ -228,7 +228,7 @@ with:
Case 1: Where an user would want to reuse the key as it is Case 1: Where an user would want to reuse the key as it is
```yaml ```yaml
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
key: ${{ steps.restore-cache.outputs.cache-primary-key }} key: ${{ steps.restore-cache.outputs.cache-primary-key }}
``` ```
@ -236,7 +236,7 @@ with:
Case 2: Where the user would want to re-evaluate the key Case 2: Where the user would want to re-evaluate the key
```yaml ```yaml
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
key: npm-cache-${{hashfiles(package-lock.json)}} key: npm-cache-${{hashfiles(package-lock.json)}}
``` ```
@ -253,12 +253,12 @@ In case of multi-module projects, where the built artifact of one project needs
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Build - name: Build
run: ./build-parent-module.sh run: ./build-parent-module.sh
- uses: actions/cache/save@v4 - uses: actions/cache/save@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -269,9 +269,9 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies

View File

@ -45,7 +45,7 @@
## Bun ## Bun
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.bun/install/cache ~/.bun/install/cache
@ -55,7 +55,7 @@
### Windows ### Windows
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~\.bun ~\.bun
@ -67,7 +67,7 @@
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ~/.nuget/packages path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@ -76,10 +76,10 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
``` ```
Depending on the environment, huge packages might be pre-installed in the global cache folder. Depending on the environment, huge packages might be pre-installed in the global cache folder.
With `actions/cache@v4` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns) From `actions/cache@v3` onwards, you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.nuget/packages ~/.nuget/packages
@ -96,7 +96,7 @@ Or you could move the cache folder like below.
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ${{ github.workspace }}/.nuget/packages path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@ -108,7 +108,7 @@ steps:
```yaml ```yaml
- name: Cache lein project dependencies - name: Cache lein project dependencies
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: ~/.m2/repository path: ~/.m2/repository
key: ${{ runner.os }}-clojure-${{ hashFiles('**/project.clj') }} key: ${{ runner.os }}-clojure-${{ hashFiles('**/project.clj') }}
@ -122,7 +122,7 @@ steps:
### POSIX ### POSIX
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ~/.dub path: ~/.dub
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }} key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }}
@ -133,7 +133,7 @@ steps:
### Windows ### Windows
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ~\AppData\Local\dub path: ~\AppData\Local\dub
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }} key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }}
@ -146,7 +146,7 @@ steps:
### Linux ### Linux
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.deno ~/.deno
@ -157,7 +157,7 @@ steps:
### macOS ### macOS
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.deno ~/.deno
@ -168,7 +168,7 @@ steps:
### Windows ### Windows
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~\.deno ~\.deno
@ -179,7 +179,7 @@ steps:
## Elixir - Mix ## Elixir - Mix
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
deps deps
@ -191,7 +191,7 @@ steps:
## Erlang - Rebar3 ## Erlang - Rebar3
```yaml ```yaml
- uses: actions/cache@v2 - uses: actions/cache@v5
with: with:
path: | path: |
~/.cache/rebar3 ~/.cache/rebar3
@ -206,7 +206,7 @@ steps:
### Linux ### Linux
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.cache/go-build ~/.cache/go-build
@ -219,7 +219,7 @@ steps:
### macOS ### macOS
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/Library/Caches/go-build ~/Library/Caches/go-build
@ -232,7 +232,7 @@ steps:
### Windows ### Windows
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~\AppData\Local\go-build ~\AppData\Local\go-build
@ -248,7 +248,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
```yaml ```yaml
- name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle - name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: | path: |
~/.cabal/packages ~/.cabal/packages
@ -263,14 +263,14 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
### Linux or macOS ### Linux or macOS
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
name: Cache ~/.stack name: Cache ~/.stack
with: with:
path: ~/.stack path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }} key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-stack-global- ${{ runner.os }}-stack-global-
- uses: actions/cache@v4 - uses: actions/cache@v5
name: Cache .stack-work name: Cache .stack-work
with: with:
path: .stack-work path: .stack-work
@ -282,7 +282,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
### Windows ### Windows
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
name: Cache %APPDATA%\stack %LOCALAPPDATA%\Programs\stack name: Cache %APPDATA%\stack %LOCALAPPDATA%\Programs\stack
with: with:
path: | path: |
@ -291,7 +291,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }} key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-stack-global- ${{ runner.os }}-stack-global-
- uses: actions/cache@v4 - uses: actions/cache@v5
name: Cache .stack-work name: Cache .stack-work
with: with:
path: .stack-work path: .stack-work
@ -305,7 +305,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
> **Note** Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons. > **Note** Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.gradle/caches ~/.gradle/caches
@ -319,7 +319,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
```yaml ```yaml
- name: Cache local Maven repository - name: Cache local Maven repository
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: ~/.m2/repository path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@ -355,7 +355,7 @@ After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-depr
`Get npm cache directory` step can then be used with `actions/cache` as shown below `Get npm cache directory` step can then be used with `actions/cache` as shown below
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with: with:
path: ${{ steps.npm-cache-dir.outputs.dir }} path: ${{ steps.npm-cache-dir.outputs.dir }}
@ -368,7 +368,7 @@ After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-depr
```yaml ```yaml
- name: restore lerna - name: restore lerna
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: '**/node_modules' path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
@ -382,7 +382,7 @@ The yarn cache directory will depend on your operating system and version of `ya
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4 - uses: actions/cache@v5
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -400,7 +400,7 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4 - uses: actions/cache@v5
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -415,7 +415,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
```yaml ```yaml
- name: Restore Cache - name: Restore Cache
id: restore-cache id: restore-cache
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: _export path: _export
key: ${{ runner.os }}-esy-${{ hashFiles('esy.lock/index.json') }} key: ${{ runner.os }}-esy-${{ hashFiles('esy.lock/index.json') }}
@ -444,7 +444,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
id: composer-cache id: composer-cache
run: | run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -465,7 +465,7 @@ Locations:
### Simple example ### Simple example
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ~/.cache/pip path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -478,7 +478,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
### Multiple OS's in a workflow ### Multiple OS's in a workflow
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
if: startsWith(runner.os, 'Linux') if: startsWith(runner.os, 'Linux')
with: with:
path: ~/.cache/pip path: ~/.cache/pip
@ -486,7 +486,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
restore-keys: | restore-keys: |
${{ runner.os }}-pip- ${{ runner.os }}-pip-
- uses: actions/cache@v4 - uses: actions/cache@v5
if: startsWith(runner.os, 'macOS') if: startsWith(runner.os, 'macOS')
with: with:
path: ~/Library/Caches/pip path: ~/Library/Caches/pip
@ -494,7 +494,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
restore-keys: | restore-keys: |
${{ runner.os }}-pip- ${{ runner.os }}-pip-
- uses: actions/cache@v4 - uses: actions/cache@v5
if: startsWith(runner.os, 'Windows') if: startsWith(runner.os, 'Windows')
with: with:
path: ~\AppData\Local\pip\Cache path: ~\AppData\Local\pip\Cache
@ -520,7 +520,7 @@ jobs:
- os: windows-latest - os: windows-latest
path: ~\AppData\Local\pip\Cache path: ~\AppData\Local\pip\Cache
steps: steps:
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ${{ matrix.path }} path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -539,7 +539,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache - name: pip cache
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: ${{ steps.pip-cache.outputs.dir }} path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -553,11 +553,11 @@ jobs:
- name: Set up Python - name: Set up Python
# The actions/cache step below uses this id to get the exact python version # The actions/cache step below uses this id to get the exact python version
id: setup-python id: setup-python
uses: actions/setup-python@v2 uses: actions/setup-python@v6
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: ~/.local/share/virtualenvs path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }} key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
@ -584,7 +584,7 @@ For renv, the cache directory will vary by OS. The `RENV_PATHS_ROOT` environment
cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "") cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
shell: Rscript {0} shell: Rscript {0}
- name: Restore Renv package cache - name: Restore Renv package cache
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: ${{ env.RENV_PATHS_ROOT }} path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }} key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }}
@ -610,7 +610,7 @@ whenever possible:
## Rust - Cargo ## Rust - Cargo
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: | path: |
~/.cargo/bin/ ~/.cargo/bin/
@ -625,7 +625,7 @@ whenever possible:
```yaml ```yaml
- name: Cache SBT - name: Cache SBT
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: | path: |
~/.ivy2/cache ~/.ivy2/cache
@ -636,7 +636,7 @@ whenever possible:
## Swift, Objective-C - Carthage ## Swift, Objective-C - Carthage
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: Carthage path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
@ -647,7 +647,7 @@ whenever possible:
## Swift, Objective-C - CocoaPods ## Swift, Objective-C - CocoaPods
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: Pods path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
@ -658,7 +658,7 @@ whenever possible:
## Swift - Swift Package Manager ## Swift - Swift Package Manager
```yaml ```yaml
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: .build path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
@ -673,7 +673,7 @@ env:
MINT_PATH: .mint/lib MINT_PATH: .mint/lib
MINT_LINK_PATH: .mint/bin MINT_LINK_PATH: .mint/bin
steps: steps:
- uses: actions/cache@v4 - uses: actions/cache@v5
with: with:
path: .mint path: .mint
key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }} key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
@ -689,7 +689,7 @@ steps:
```yaml ```yaml
- name: Cache Bazel - name: Cache Bazel
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: | path: |
~/.cache/bazel ~/.cache/bazel
@ -703,7 +703,7 @@ steps:
```yaml ```yaml
- name: Cache Bazel - name: Cache Bazel
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: | path: |
/private/var/tmp/_bazel_runner/ /private/var/tmp/_bazel_runner/

View File

@ -35,9 +35,9 @@ If you are using separate jobs to create and save your cache(s) to be reused by
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -64,12 +64,12 @@ In case of multi-module projects, where the built artifact of one project needs
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Build - name: Build
run: /build-parent-module.sh run: /build-parent-module.sh
- uses: actions/cache/save@v4 - uses: actions/cache/save@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -80,9 +80,9 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -107,9 +107,9 @@ To fail if there is no cache hit for the primary key, leave `restore-keys` empty
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: actions/cache/restore@v4 - uses: actions/cache/restore@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies

View File

@ -23,7 +23,7 @@ If you are using separate jobs for generating common artifacts and sharing them
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Install Dependencies - name: Install Dependencies
run: /install.sh run: /install.sh
@ -31,7 +31,7 @@ steps:
- name: Build artifacts - name: Build artifacts
run: /build.sh run: /build.sh
- uses: actions/cache/save@v4 - uses: actions/cache/save@v5
id: cache id: cache
with: with:
path: path/to/dependencies path: path/to/dependencies
@ -47,7 +47,7 @@ Let's say we have a restore step that computes a key at runtime.
#### Restore a cache #### Restore a cache
```yaml ```yaml
uses: actions/cache/restore@v4 uses: actions/cache/restore@v5
id: restore-cache id: restore-cache
with: with:
key: cache-${{ hashFiles('**/lockfiles') }} key: cache-${{ hashFiles('**/lockfiles') }}
@ -55,7 +55,7 @@ with:
#### Case 1 - Where a user would want to reuse the key as it is #### Case 1 - Where a user would want to reuse the key as it is
```yaml ```yaml
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
key: ${{ steps.restore-cache.outputs.cache-primary-key }} key: ${{ steps.restore-cache.outputs.cache-primary-key }}
``` ```
@ -63,7 +63,7 @@ with:
#### Case 2 - Where the user would want to re-evaluate the key #### Case 2 - Where the user would want to re-evaluate the key
```yaml ```yaml
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
key: npm-cache-${{hashfiles(package-lock.json)}} key: npm-cache-${{hashfiles(package-lock.json)}}
``` ```
@ -91,11 +91,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Restore cached Prime Numbers - name: Restore cached Prime Numbers
id: cache-prime-numbers-restore id: cache-prime-numbers-restore
uses: actions/cache/restore@v4 uses: actions/cache/restore@v5
with: with:
key: ${{ runner.os }}-prime-numbers key: ${{ runner.os }}-prime-numbers
path: | path: |
@ -107,7 +107,7 @@ jobs:
- name: Always Save Prime Numbers - name: Always Save Prime Numbers
id: cache-prime-numbers-save id: cache-prime-numbers-save
if: always() && steps.cache-prime-numbers-restore.outputs.cache-hit != 'true' if: always() && steps.cache-prime-numbers-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4 uses: actions/cache/save@v5
with: with:
key: ${{ steps.cache-prime-numbers-restore.outputs.cache-primary-key }} key: ${{ steps.cache-prime-numbers-restore.outputs.cache-primary-key }}
path: | path: |

View File

@ -12,7 +12,7 @@ A cache today is immutable and cannot be updated. But some use cases require the
```yaml ```yaml
- name: update cache on every commit - name: update cache on every commit
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: prime-numbers path: prime-numbers
key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well