Disable automatic caching for sensitive events (#992)

## Summary

- disable `enable-cache: auto` for `pull_request_target`,
`workflow_run`, and `release` events
- disable automatic caching for tag pushes while leaving branch pushes
unchanged
- preserve explicit `enable-cache: true` as an override
- run a `workflow_run` integration fixture with `act` in pull request CI
and verify caching is disabled
- document the behavior and update the published bundles

## Testing

- `npm run all`
- `actionlint .github/workflows/test.yml
__tests__/workflows/workflow-run.yml`
- `uvx zizmor __tests__/workflows/workflow-run.yml`

Closes #984

Refs: pi-session 019fec42-9b26-714e-a359-830ac4401ecd
This commit is contained in:
Kevin Stillhammer
2026-08-10 18:12:08 +02:00
committed by GitHub
parent b68407c192
commit f45168497b
9 changed files with 181 additions and 6 deletions
Generated Vendored
+14 -1
View File
@@ -98255,7 +98255,20 @@ function getVenvPath(workingDirectory, activateEnvironment2) {
function getEnableCache() {
const enableCacheInput = getInput("enable-cache");
if (enableCacheInput === "auto") {
return process.env.RUNNER_ENVIRONMENT === "github-hosted";
if (process.env.RUNNER_ENVIRONMENT !== "github-hosted") {
return false;
}
const eventName = process.env.GITHUB_EVENT_NAME;
const isTagPush = eventName === "push" && process.env.GITHUB_REF?.startsWith("refs/tags/");
if (isTagPush) {
info2("Caching is disabled for tag pushes");
return false;
}
if (eventName === "pull_request_target" || eventName === "workflow_run" || eventName === "release") {
info2(`Caching is disabled for the ${eventName} event`);
return false;
}
return true;
}
return enableCacheInput === "true";
}