-
Notifications
You must be signed in to change notification settings - Fork 29
/
gcr-auth.yml
54 lines (45 loc) · 1.74 KB
/
gcr-auth.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
description: >
Configure Docker to use gcloud as a credential helper. Using this command requires the use of a 'machine' executor.
parameters:
gcloud-service-key:
type: env_var_name
default: GCLOUD_SERVICE_KEY
description: The gcloud service key
google-project-id:
type: env_var_name
default: GOOGLE_PROJECT_ID
description: >
Environment variable name for the Google project ID to connect with
via the gcloud CLI
google-compute-zone:
type: env_var_name
default: GOOGLE_COMPUTE_ZONE
description: >
The Google compute zone to connect with via the gcloud CLI
google-compute-region:
type: env_var_name
default: GOOGLE_COMPUTE_REGION
description: >
The Google compute region to connect with via the gcloud CLI
steps:
- gcp-cli/install
- gcp-cli/initialize:
google-project-id: <<parameters.google-project-id>>
google-compute-zone: <<parameters.google-compute-zone>>
google-compute-region: <<parameters.google-compute-region>>
gcloud-service-key: <<parameters.gcloud-service-key>>
- run:
name: gcloud auth configure-docker
command: |
# Set sudo to work whether logged in as root user or non-root user
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
# configure Docker to use gcloud as a credential helper
mkdir -p "$HOME/.docker"
gcloud auth configure-docker --quiet --project $<<parameters.google-project-id>>
# if applicable, provide user access to the docker config file
if [[ -d "$HOME/.docker" ]]; then
$SUDO chown "$USER:$USER" "$HOME/.docker" -R
fi
if [[ -d "$HOME/.config" ]]; then
$SUDO chown "$USER:$USER" "$HOME/.config" -R
fi