Use our custom boolean parsing (#478)

Fixes GH-477
This commit is contained in:
Seth Vargo 2025-04-24 08:53:29 -07:00 committed by GitHub
parent 71f986410d
commit b011f3988e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View File

@ -56,7 +56,7 @@ inputs:
description: |- description: |-
If true, the action will securely generate a credentials file which can be If true, the action will securely generate a credentials file which can be
used for authentication via gcloud and Google Cloud SDKs. used for authentication via gcloud and Google Cloud SDKs.
default: true default: 'true'
required: false required: false
export_environment_variables: export_environment_variables:
description: |- description: |-
@ -79,7 +79,7 @@ inputs:
If false, the action will not export any environment variables, meaning If false, the action will not export any environment variables, meaning
future steps are unlikely to be automatically authenticated to Google future steps are unlikely to be automatically authenticated to Google
Cloud. Cloud.
default: true default: 'true'
required: false required: false
token_format: token_format:
description: |- description: |-
@ -113,7 +113,7 @@ inputs:
If true, the action will remove any created credentials from the If true, the action will remove any created credentials from the
filesystem upon completion. This only applies if "create_credentials_file" filesystem upon completion. This only applies if "create_credentials_file"
is true. is true.
default: true default: 'true'
required: false required: false
# access token params # access token params
@ -175,7 +175,7 @@ inputs:
generated token. If true, the token will contain "email" and generated token. If true, the token will contain "email" and
"email_verified" claims. This is only valid when "token_format" is "email_verified" claims. This is only valid when "token_format" is
"id_token". "id_token".
default: false default: 'false'
required: false required: false
outputs: outputs:

View File

@ -16,7 +16,6 @@ import { join as pathjoin } from 'path';
import { import {
exportVariable, exportVariable,
getBooleanInput,
getIDToken, getIDToken,
getInput, getInput,
setFailed, setFailed,
@ -29,6 +28,7 @@ import {
isEmptyDir, isEmptyDir,
isPinnedToHead, isPinnedToHead,
parseMultilineCSV, parseMultilineCSV,
parseBoolean,
parseDuration, parseDuration,
pinnedToHeadWarning, pinnedToHeadWarning,
} from '@google-github-actions/actions-utils'; } from '@google-github-actions/actions-utils';
@ -79,8 +79,8 @@ export async function run(logger: Logger) {
const oidcTokenAudience = const oidcTokenAudience =
getInput(`audience`) || `https://iam.googleapis.com/${workloadIdentityProvider}`; getInput(`audience`) || `https://iam.googleapis.com/${workloadIdentityProvider}`;
const credentialsJSON = getInput(`credentials_json`); const credentialsJSON = getInput(`credentials_json`);
const createCredentialsFile = getBooleanInput(`create_credentials_file`); const createCredentialsFile = parseBoolean(getInput(`create_credentials_file`));
const exportEnvironmentVariables = getBooleanInput(`export_environment_variables`); const exportEnvironmentVariables = parseBoolean(getInput(`export_environment_variables`));
const tokenFormat = getInput(`token_format`); const tokenFormat = getInput(`token_format`);
const delegates = parseMultilineCSV(getInput(`delegates`)); const delegates = parseMultilineCSV(getInput(`delegates`));
const universe = getInput(`universe`); const universe = getInput(`universe`);
@ -301,7 +301,7 @@ export async function run(logger: Logger) {
logger.debug(`Creating id token`); logger.debug(`Creating id token`);
const idTokenAudience = getInput('id_token_audience', { required: true }); const idTokenAudience = getInput('id_token_audience', { required: true });
const idTokenIncludeEmail = getBooleanInput('id_token_include_email'); const idTokenIncludeEmail = parseBoolean(getInput('id_token_include_email'));
// Ensure a service_account was provided if using WIF. // Ensure a service_account was provided if using WIF.
if (!serviceAccount) { if (!serviceAccount) {

View File

@ -12,21 +12,21 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { getBooleanInput, setFailed } from '@actions/core'; import { getInput, setFailed } from '@actions/core';
import { errorMessage, forceRemove } from '@google-github-actions/actions-utils'; import { errorMessage, forceRemove, parseBoolean } from '@google-github-actions/actions-utils';
import { Logger } from './logger'; import { Logger } from './logger';
export async function run(logger: Logger) { export async function run(logger: Logger) {
try { try {
const createCredentials = getBooleanInput('create_credentials_file'); const createCredentials = parseBoolean(getInput('create_credentials_file'));
if (!createCredentials) { if (!createCredentials) {
logger.info(`Skipping credential cleanup - "create_credentials_file" is false.`); logger.info(`Skipping credential cleanup - "create_credentials_file" is false.`);
return; return;
} }
const cleanupCredentials = getBooleanInput('cleanup_credentials'); const cleanupCredentials = parseBoolean(getInput('cleanup_credentials'));
if (!cleanupCredentials) { if (!cleanupCredentials) {
logger.info(`Skipping credential cleanup - "cleanup_credentials" is false.`); logger.info(`Skipping credential cleanup - "cleanup_credentials" is false.`);
return; return;