gradle/gradle-build-action "cache write not permitted" on fork PRs
On fork PRs GitHub issues a read-only token, so the Actions cache cannot be written. gradle-build-action detects this and disables cache writes, which is expected, not a bug.
What this error means
On a fork PR the Gradle step logs "Cache write is not permitted in this context" and saves nothing.
Cache write is not permitted in this context.
Gradle User Home cache will be read-only.Common causes
Read-only token on fork PRs
Fork-originated pull_request runs get a read-only token that cannot write cache entries.
Cache write intentionally disabled
The action disables writes to avoid cache poisoning from untrusted forks.
How to fix it
Accept read-only on forks; warm the cache on trusted branches
- Let fork PRs run read-only; treat the message as informational.
- Populate the cache from pushes to your default branch so PRs read a warm cache.
- Use a separate trusted workflow if writes on PRs are required.
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: gradle/actions/setup-gradle@v4How to prevent it
- Warm caches on default-branch pushes so fork PRs benefit read-only.
- Do not expect cache writes from untrusted fork PRs.