-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[.github] - feat(workflows): regional build args (#9386)
* [.github/k8s] - feature: regional configuration and deployment workflow update - Add Europe and US regional-specific configurations for the front-end - Refactor the front-edge deployment workflow to use a temporary cloud build script - Remove the dust-client-facing-url argument in the deployment script as it's now region-specific * [k8s] - refactor: streamline substitutions in cloud build script - Remove _CONFIG_FILE substitution as it's no longer needed - Update env variable extraction to use a region-specific config file in build step
- Loading branch information
1 parent
43eea9e
commit 0a06d78
Showing
5 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
env: | ||
NEXT_PUBLIC_VIZ_URL: "https://viz.dust.tt" | ||
NEXT_PUBLIC_GA_TRACKING_ID: "G-K9HQ2LE04G" | ||
NEXT_PUBLIC_DUST_CLIENT_FACING_URL: "https://eu-front-edge.dust.tt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
env: | ||
NEXT_PUBLIC_VIZ_URL: "https://viz.dust.tt" | ||
NEXT_PUBLIC_GA_TRACKING_ID: "G-K9HQ2LE04G" | ||
NEXT_PUBLIC_DUST_CLIENT_FACING_URL: "https://front-edge.dust.tt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Default values | ||
SCRIPT_DIR="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)" | ||
WORKING_DIR="" | ||
IMAGE_NAME="" | ||
DOCKERFILE_PATH="" | ||
REGION="" | ||
GCLOUD_IGNORE_FILE="" | ||
|
||
# Parse command-line arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--working-dir=*) | ||
WORKING_DIR="${1#*=}" | ||
shift | ||
;; | ||
--image-name=*) | ||
IMAGE_NAME="${1#*=}" | ||
shift | ||
;; | ||
--dockerfile-path=*) | ||
DOCKERFILE_PATH="${1#*=}" | ||
shift | ||
;; | ||
--region=*) | ||
REGION="${1#*=}" | ||
shift | ||
;; | ||
--gcloud-ignore-file=*) | ||
GCLOUD_IGNORE_FILE="${1#*=}" | ||
shift | ||
;; | ||
*) | ||
echo "Error: Unknown argument $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Validate required arguments | ||
if [ -z "$WORKING_DIR" ] || [ -z "$IMAGE_NAME" ] || [ -z "$DOCKERFILE_PATH" ] || [ -z "$REGION" ]; then | ||
echo "Error: --working-dir, --image-name, --region and --dockerfile-path are required" | ||
exit 1 | ||
fi | ||
|
||
# Change to working directory | ||
cd "$WORKING_DIR" | ||
|
||
# Load region-specific config | ||
CONFIG_FILE=".github/config/${REGION}.yaml" | ||
if [ ! -f "$CONFIG_FILE" ]; then | ||
echo "Error: Config file not found: $CONFIG_FILE" | ||
exit 1 | ||
fi | ||
|
||
# Prepare the build command | ||
BUILD_CMD=(gcloud builds submit --quiet --config "${SCRIPT_DIR}/cloudbuild_tmp.yaml") | ||
|
||
if [ -n "$GCLOUD_IGNORE_FILE" ]; then | ||
BUILD_CMD+=(--ignore-file="$GCLOUD_IGNORE_FILE") | ||
fi | ||
|
||
# Add substitutions | ||
BUILD_CMD+=(--substitutions="_REGION=$REGION,_IMAGE_NAME=$IMAGE_NAME,_DOCKERFILE_PATH=$DOCKERFILE_PATH,SHORT_SHA=$(git rev-parse --short HEAD)" .) | ||
|
||
# Execute the build | ||
"${BUILD_CMD[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
steps: | ||
- id: 'Build Container Image' | ||
name: 'ghcr.io/depot/cli:latest' | ||
script: | | ||
# Extract env variables for build args | ||
yq e '.env' .github/config/${_REGION}.yaml > build-args.env | ||
depot build \ | ||
--project 3vz0lnf16v \ | ||
--provenance=false \ | ||
-t ${_REGION}-docker.pkg.dev/${PROJECT_ID}/dust-images/${_IMAGE_NAME}:${SHORT_SHA} \ | ||
-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 \ | ||
--push \ | ||
. | ||
secretEnv: | ||
- "DEPOT_TOKEN" | ||
|
||
timeout: 1200s | ||
|
||
availableSecrets: | ||
secretManager: | ||
- versionName: projects/$PROJECT_ID/secrets/DEPOT_TOKEN/versions/latest | ||
env: DEPOT_TOKEN | ||
|
||
options: | ||
automapSubstitutions: true | ||
logging: CLOUD_LOGGING_ONLY |