Skip to content

Add cache-write input for read-only cache mode#1284

Open
salmanmkc wants to merge 2 commits intoactions:mainfrom
salmanmkc:feature/cache-read-only
Open

Add cache-write input for read-only cache mode#1284
salmanmkc wants to merge 2 commits intoactions:mainfrom
salmanmkc:feature/cache-read-only

Conversation

@salmanmkc
Copy link
Contributor

Right now if you use cache: pip (or pipenv/poetry) in a PR workflow, the action restores and saves the cache. There's no way to get read-only mode where you benefit from existing caches without writing back. This matters for cache poisoning — an untrusted PR could plant bad packages in the cache that later get picked up by pushes to main.

This adds a cache-write input (defaults to true, no breaking change). Set it to false to skip the post-step save.

Usage:

- uses: actions/setup-python@v6
  with:
    python-version: "3.12"
    cache: pip
    cache-write: ${{ github.event_name != 'pull_request' }}

What changed:

  • action.yml — new cache-write input
  • src/cache-save.ts — early return when cache-write is false
  • dist/ — rebuilt

Same change going into setup-node, setup-go, setup-java, setup-dotnet.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants