-
Notifications
You must be signed in to change notification settings - Fork 84
Use core.getBooleanInput()
to retrieve boolean input values
#223
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?
Use core.getBooleanInput()
to retrieve boolean input values
#223
Conversation
@parkerbxyz PTAL~ |
@@ -7,6 +7,7 @@ process.env.STATE_token = "secret123"; | |||
// inputs are set as environment variables with the prefix INPUT_ | |||
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs | |||
process.env["INPUT_GITHUB-API-URL"] = "https://api.github.com"; | |||
process.env["INPUT_SKIP-TOKEN-REVOKE"] = "false"; |
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.
Is it necessary to set these explicitly? Shouldn't it default to false? I think it's a good idea to have it set explicitly in one of the tests, but by default I would not set it at all.
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.
Yes, we need to set it explicitly. The post-*.test.js
files do not run as part of GitHub Actions, so environment variables are not automatically populated. Even if we define default values in action.yml
, they won't apply here — we have to set them manually.
I understand your suggestion, but in this case, explicit configuration is necessary. You can confirm this by fetching this change and commenting out the variable — the test will fail.
GitHub Actions uses the default values defined in action.yml
only when the workflow runs via Actions. You can refer to this link to see how that works.
This PR switches from evaluating values passed to
skip-token-revoke
as true if they are truthy in JavaScript, to usinggetBooleanInput
. This change ensures that only proper YAML boolean values are recognized, preventing unintended evaluations to true.getBooleanInput
is here: definition ofcore#getBooealnInput
is here: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/core/src/core.ts#L188-L208The documentation states,
"If truthy, the token will not be revoked when the current job is complete"
, so this change could be considered a breaking change. This means that if there are users who rely ontruthy
and expect values like whitespace or"false"
to be evaluated as true (though this is likely rare), it would be a breaking change.Boolean(" ")
andBoolean("false")
are both evaluated as true.Alternatively, it can simply be considered a fix. How to handle this is up to the maintainer.
Resolve #216