-
Notifications
You must be signed in to change notification settings - Fork 644
Add cache-write input for read-only cache mode #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,14 @@ process.on('uncaughtException', e => { | |
|
|
||
| export async function run(earlyExit?: boolean) { | ||
| try { | ||
| const cacheWriteEnabled = core.getInput('cache-write'); | ||
| if (cacheWriteEnabled === 'false') { | ||
| core.info( | ||
| 'Cache write is disabled (read-only mode). Skipping cache save.' | ||
| ); | ||
| return; | ||
| } | ||
|
Comment on lines
+21
to
+27
|
||
|
|
||
| const cacheInput = core.getBooleanInput('cache'); | ||
| if (cacheInput) { | ||
| await cachePackages(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache-writeis being read viacore.getInput()and compared to the string'false', which is case-sensitive and inconsistent with the rest of the action’s boolean inputs (e.g.,cacheusesgetBooleanInput). Consider usingcore.getBooleanInput('cache-write')and checkingif (!cacheWriteEnabled) ...to correctly handle boolean-y values and avoid accidental cache saves when the input is set to something likeFalse/FALSE/0/empty string.Also, consider evaluating
cachefirst and returning early when caching is disabled, before parsing/acting oncache-write, so a misconfiguredcache-writevalue can’t affect workflows wherecache: false(and to avoid logging “cache write disabled” when caching itself is off).See below for a potential fix: