Skip to content

Commit fd83cd9

Browse files
authored
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 #670
1 parent f14c440 commit fd83cd9

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
bestVersion,
2222
installComponent,
2323
installGcloudSDK,
24+
isAuthenticated,
2425
setProject,
2526
} from '@google-github-actions/setup-cloud-sdk';
2627
import {
@@ -102,9 +103,10 @@ export async function run(): Promise<void> {
102103
if (credFile) {
103104
await authenticateGcloudSDK(credFile);
104105
core.info('Successfully authenticated');
105-
} else {
106+
} else if (!(await isAuthenticated())) {
106107
core.warning(
107-
'No authentication found for gcloud, authenticate with `google-github-actions/auth`.',
108+
`The gcloud CLI is not authenticated. Authenticate by adding the ` +
109+
`"google-github-actions/auth" step prior this one.`,
108110
);
109111
}
110112

tests/setup-gcloud.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const defaultMocks = (
6464
}),
6565

6666
authenticateGcloudSDK: m.method(setupGcloud, 'authenticateGcloudSDK', () => {}),
67+
isAuthenticated: m.method(setupGcloud, 'isAuthenticated', () => {}),
6768
isInstalled: m.method(setupGcloud, 'isInstalled', () => {
6869
return true;
6970
}),

0 commit comments

Comments
 (0)