Skip to content

Commit 87c0d63

Browse files
authored
Activate account when SERVICE_ACCOUNT_EMAIL is provided (#56)
* Activate account when SERVICE_ACCOUNT_EMAIL is provided
1 parent 7ea6832 commit 87c0d63

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/build-vm-image.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ function _register_gcloud_config() {
4242

4343

4444
if [[ -v SERVICE_ACCOUNT_EMAIL ]]; then
45+
declare -r active_account="$(gcloud auth list \
46+
--filter "status:ACTIVE" \
47+
--format "value(account)")"
48+
4549
_register_gcloud_config
50+
gcloud config set account "${active_account}"
4651
else
4752
# If the service account e-mail is not specified, check that the
4853
# key file is mounted.
@@ -58,7 +63,6 @@ fi
5863

5964
# Print environment variables.
6065
env
61-
6266
gcloud info
6367

6468
# Set default value for unset variables.

0 commit comments

Comments
 (0)