Only warn when there are no authentications (#671)

This fixes an issue where a warning message would be printed on systems
using ADC from the metadata server.

Fixes https://github.com/google-github-actions/setup-gcloud/issues/670
This commit is contained in:
Seth Vargo 2023-12-20 22:31:37 -05:00 committed by GitHub
parent f14c440264
commit fd83cd9564
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;
}),