Only warn when there are no authentications

This fixes an issue where a warning message would be printed on systems using ADC from the metadata server.
This commit is contained in:
Seth Vargo 2023-12-20 22:27:55 -05:00
parent f14c440264
commit fd8eeaa9fc
Failed to extract signature
3 changed files with 6 additions and 3 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -21,6 +21,7 @@ import {
bestVersion,
installComponent,
installGcloudSDK,
isAuthenticated,
setProject,
} from '@google-github-actions/setup-cloud-sdk';
import {
@ -102,9 +103,10 @@ export async function run(): Promise<void> {
if (credFile) {
await authenticateGcloudSDK(credFile);
core.info('Successfully authenticated');
} else {
} else if (!(await isAuthenticated())) {
core.warning(
'No authentication found for gcloud, authenticate with `google-github-actions/auth`.',
`The gcloud CLI is not authenticated. Authenticate by adding the ` +
`"google-github-actions/auth" step prior this one.`,
);
}

View file

@ -64,6 +64,7 @@ const defaultMocks = (
}),
authenticateGcloudSDK: m.method(setupGcloud, 'authenticateGcloudSDK', () => {}),
isAuthenticated: m.method(setupGcloud, 'isAuthenticated', () => {}),
isInstalled: m.method(setupGcloud, 'isInstalled', () => {
return true;
}),