Skip to content

Commit 261f1fb

Browse files
committed
ensure to set GOOGLE_APPLICATION_CREDENTIALS
1 parent 8409093 commit 261f1fb

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
2020
WORKER_BIN_DIR=/usr/local/worker/bin \
2121
WORKER_ETC_DIR=/usr/local/worker/etc \
2222
# Add worker bin to PATH
23-
PATH=/usr/local/worker/bin:${PATH}
23+
PATH=/usr/local/worker/bin:${PATH} \
24+
# Default envs
25+
ACTORS_CLEANUP=false
2426

2527
# Set the shell with pipefail option
2628
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

lib/auth/gcp.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ gcp_authenticate() {
4343
# Use jq to create a valid JSON with the modified privateKey
4444
jq -n --arg clientEmail "$clientEmail" --arg privateKey "$privateKey" --arg projectId "$projectId" \
4545
'{client_email: $clientEmail, private_key: $privateKey, project_id: $projectId}' > "$temp_creds_file"
46+
47+
# Set GOOGLE_APPLICATION_CREDENTIALS if ACTORS_CLEANUP is false
48+
if [ "$ACTORS_CLEANUP" = false ]; then
49+
mkdir -p "$HOME/creds"
50+
echo $creds_content > "$HOME/creds/gcp_creds.json"
51+
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/creds/gcp_creds.json"
52+
fi
4653

4754
log_info "GCP Authentication" "Authenticating GCP service account..."
4855
if ! gcloud auth activate-service-account "$clientEmail" --key-file="$temp_creds_file" >/dev/null 2>&1; then

0 commit comments

Comments
 (0)