fix stripe image build
Build & Push / Pipeline Tests (push) Successful in 1m45s
Test / Type Check (all packages) (push) Successful in 53s
Build & Push / Build & Push Docker Image (push) Failing after 33s
Test / API Unit Tests (push) Successful in 1m7s
Test / Homepage Unit Tests (push) Successful in 50s
Test / Carplace Unit Tests (push) Successful in 47s
Test / Admin Unit Tests (push) Successful in 43s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m6s
Build & Push / Pipeline Tests (push) Successful in 1m45s
Test / Type Check (all packages) (push) Successful in 53s
Build & Push / Build & Push Docker Image (push) Failing after 33s
Test / API Unit Tests (push) Successful in 1m7s
Test / Homepage Unit Tests (push) Successful in 50s
Test / Carplace Unit Tests (push) Successful in 47s
Test / Admin Unit Tests (push) Successful in 43s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m6s
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
apply-env-secret-overrides.sh <env-file> <KEY> [KEY...]
|
||||
|
||||
For each KEY, this script reads KEY_B64 from the environment, base64-decodes it,
|
||||
and upserts KEY=<decoded value> in <env-file>. Empty KEY_B64 values are ignored.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
env_file="$1"
|
||||
shift
|
||||
|
||||
if [[ ! -f "${env_file}" ]]; then
|
||||
echo "Missing env file: ${env_file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upsert_env_value() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
local tmp_file
|
||||
|
||||
tmp_file="$(mktemp "${env_file}.tmp.XXXXXX")"
|
||||
awk -v key="${key}" -v value="${value}" '
|
||||
BEGIN {
|
||||
updated = 0
|
||||
}
|
||||
/^[[:space:]]*#/ || index($0, "=") == 0 {
|
||||
print
|
||||
next
|
||||
}
|
||||
{
|
||||
name = $1
|
||||
sub(/=.*/, "", name)
|
||||
sub(/^[[:space:]]*export[[:space:]]+/, "", name)
|
||||
gsub(/^[[:space:]]+|[[:space:]]+$/, "", name)
|
||||
if (name == key) {
|
||||
print key "=" value
|
||||
updated = 1
|
||||
next
|
||||
}
|
||||
print
|
||||
}
|
||||
END {
|
||||
if (!updated) {
|
||||
print key "=" value
|
||||
}
|
||||
}
|
||||
' "${env_file}" > "${tmp_file}"
|
||||
|
||||
mv "${tmp_file}" "${env_file}"
|
||||
}
|
||||
|
||||
for key in "$@"; do
|
||||
encoded_var="${key}_B64"
|
||||
encoded_value="${!encoded_var:-}"
|
||||
|
||||
if [[ -z "${encoded_value}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! decoded_value="$(printf '%s' "${encoded_value}" | base64 -d)"; then
|
||||
echo "Invalid base64 value in ${encoded_var}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upsert_env_value "${key}" "${decoded_value}"
|
||||
done
|
||||
@@ -228,8 +228,8 @@ validate_prod_env_file() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${stripe_api_key}" != sk_* && "${stripe_api_key}" != rk_* ]]; then
|
||||
echo "Invalid STRIPE_API_KEY in ${ENV_FILE}. It must start with sk_ or rk_." >&2
|
||||
if [[ "${stripe_api_key}" != sk_live_* && "${stripe_api_key}" != rk_live_* ]]; then
|
||||
echo "Invalid STRIPE_API_KEY in ${ENV_FILE}. It must start with sk_live_ or rk_live_ for production billing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user