Skip to content

Commit

Permalink
Only warn when there are no authentications (#671)
Browse files Browse the repository at this point in the history
This fixes an issue where a warning message would be printed on systems
using ADC from the metadata server.

Fixes #670
  • Loading branch information
sethvargo authored Dec 21, 2023
1 parent f14c440 commit fd83cd9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
bestVersion,
installComponent,
installGcloudSDK,
isAuthenticated,
setProject,
} from '@google-github-actions/setup-cloud-sdk';
import {
Expand Down Expand Up @@ -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.`,
);
}

Expand Down
1 change: 1 addition & 0 deletions tests/setup-gcloud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const defaultMocks = (
}),

authenticateGcloudSDK: m.method(setupGcloud, 'authenticateGcloudSDK', () => {}),
isAuthenticated: m.method(setupGcloud, 'isAuthenticated', () => {}),
isInstalled: m.method(setupGcloud, 'isInstalled', () => {
return true;
}),
Expand Down

0 comments on commit fd83cd9

Please sign in to comment.