Skip to content

Commit 850555c

Browse files
committed
Fix Cloud Run env sync JSON encoding
1 parent 0e7ab89 commit 850555c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/sync-cloud-run-env.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@ jobs:
240240
run: |
241241
set -euo pipefail
242242
243+
join_by_delimiter() {
244+
local delimiter="$1"
245+
shift
246+
local output=""
247+
local item
248+
for item in "$@"; do
249+
if [ -z "${output}" ]; then
250+
output="${item}"
251+
else
252+
output="${output}${delimiter}${item}"
253+
fi
254+
done
255+
printf '%s' "${output}"
256+
}
257+
243258
env_pairs=(
244259
"GLOBAL_TELEGRAM_CHAT_ID=${GLOBAL_TELEGRAM_CHAT_ID}"
245260
"NOTIFY_LANG=${NOTIFY_LANG}"
@@ -324,7 +339,7 @@ jobs:
324339
run services update "${CLOUD_RUN_SERVICE}"
325340
--region "${CLOUD_RUN_REGION}"
326341
--remove-env-vars "$(IFS=,; echo "${remove_env_vars[*]}")"
327-
--update-env-vars "$(IFS=,; echo "${env_pairs[*]}")"
342+
--update-env-vars "^|^$(join_by_delimiter "|" "${env_pairs[@]}")"
328343
)
329344
330345
if [ "${#remove_secret_vars[@]}" -gt 0 ]; then

tests/test_sync_cloud_run_env_workflow.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ grep -Fq '"LONGBRIDGE_FRACTIONAL_SHARES_ENABLED"' "$workflow_file"
8888
grep -Fq '"LONGBRIDGE_ORDER_QUANTITY_STEP"' "$workflow_file"
8989
grep -Fq '"LONGBRIDGE_MIN_ORDER_NOTIONAL_USD"' "$workflow_file"
9090
grep -Fq '"SERVICE_NAME"' "$workflow_file"
91+
grep -Fq 'join_by_delimiter()' "$workflow_file"
9192
grep -Fq 'gcloud_args+=(--remove-secrets "$(IFS=,; echo "${remove_secret_vars[*]}")")' "$workflow_file"
9293
grep -Fq 'gcloud_args+=(--update-secrets "$(IFS=,; echo "${secret_pairs[*]}")")' "$workflow_file"
94+
grep -Fq -- '--update-env-vars "^|^$(join_by_delimiter "|" "${env_pairs[@]}")"' "$workflow_file"
9395

9496
if grep -Fq 'SERVICE_NAME: ${{ vars.SERVICE_NAME }}' "$workflow_file"; then
9597
echo "unexpected SERVICE_NAME env wiring still present" >&2

0 commit comments

Comments
 (0)