Skip to content

Commit

Permalink
Fix edge case when gcloud is not installed at all (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Dec 21, 2023
1 parent fd83cd9 commit 191b97b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ export async function run(): Promise<void> {
if (credFile) {
await authenticateGcloudSDK(credFile);
core.info('Successfully authenticated');
} else if (!(await isAuthenticated())) {
core.warning(
`The gcloud CLI is not authenticated. Authenticate by adding the ` +
`"google-github-actions/auth" step prior this one.`,
);
} else {
let authed;
try {
authed = await isAuthenticated();
} catch {
authed = false;
}

if (!authed) {
core.warning(
`The gcloud CLI is not authenticated (or it is not installed). ` +
`Authenticate by adding the "google-github-actions/auth" step ` +
`prior this one.`,
);
}
}

// Set the project ID, if given.
Expand Down

0 comments on commit 191b97b

Please sign in to comment.