Skip to content

Commit

Permalink
[k8s] - refactor: update build-arg extraction method for container im…
Browse files Browse the repository at this point in the history
…age (#9393)

- Replace `yq` and redirection with a bash loop to dynamically populate the build_args array
 - Ensure removal of surrounding quotes from the extracted values to clean up build arguments
  • Loading branch information
JulesBelveze authored Dec 16, 2024
1 parent 3831df7 commit 9f31109
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions k8s/cloudbuild_tmp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ steps:
- id: 'Build Container Image'
name: 'ghcr.io/depot/cli:latest'
script: |
# Extract env variables for build args
yq e '.env' .github/configs/${_REGION}.yaml > build-args.env
#!/usr/bin/env bash
build_args=()
while IFS=': ' read -r key value; do
# Remove surrounding quotes from value
value=$(echo "$value" | sed 's/^"\(.*\)"$/\1/')
if [[ -n "$key" ]]; then
build_args+=(--build-arg "${key}=${value}")
fi
done < <(yq e '.env' .github/configs/us-central1.yaml)
depot build \
--project 3vz0lnf16v \
Expand All @@ -12,9 +21,10 @@ steps:
-t ${_REGION}-docker.pkg.dev/${PROJECT_ID}/dust-images/${_IMAGE_NAME}:latest \
-f ${_DOCKERFILE_PATH} \
--build-arg COMMIT_HASH=${SHORT_SHA} \
--build-arg-file=build-args.env \
"${build_args[@]}" \
--push \
.
secretEnv:
- "DEPOT_TOKEN"

Expand Down

0 comments on commit 9f31109

Please sign in to comment.