Skip to content

Commit

Permalink
Force authentication if GOOGLE_GHA_CREDS_PATH is set
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Nov 10, 2022
1 parent 5c6749c commit 7de6e2f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/setup-gcloud.ts
Expand Up @@ -17,6 +17,7 @@
import * as core from '@actions/core';
import * as toolCache from '@actions/tool-cache';
import {
authenticateGcloudSDK,
getLatestGcloudSDKVersion,
installComponent,
installGcloudSDK,
Expand Down Expand Up @@ -60,6 +61,17 @@ export async function run(): Promise<void> {
await installComponent(components.split(',').map((comp) => comp.trim()));
}

// Authenticate - this comes from google-github-actions/auth
const credFile = process.env.GOOGLE_GHA_CREDS_PATH;
if (credFile) {
await authenticateGcloudSDK(credFile);
core.info('Successfully authenticated');
} else {
core.warning(
'No authentication found for gcloud, authenticate with `google-github-actions/auth`.',
);
}

// Set the project ID, if given.
const projectId = core.getInput('project_id');
if (projectId) {
Expand Down

0 comments on commit 7de6e2f

Please sign in to comment.