Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/scripts/e2e-prepare-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Writes non-secret env to $RUNNER_TEMP/e2e-env.sh and materializes secrets into temp files.
# Never echoes secret values.

set -euo pipefail

ENV_FILE="${RUNNER_TEMP}/e2e-env.sh"
: >"$ENV_FILE"

write_env() {
printf 'export %s=%q\n' "$1" "$2" >>"$ENV_FILE"
}

if [[ -n "${E2E_SSH_PRIVATE_KEY:-}" ]]; then
KEY_FILE="${RUNNER_TEMP}/e2e_ssh_key"
printf '%s\n' "$E2E_SSH_PRIVATE_KEY" >"$KEY_FILE"
chmod 600 "$KEY_FILE"
write_env SSH_PRIVATE_KEY "$KEY_FILE"
fi

if [[ -n "${E2E_SSH_PUBLIC_KEY:-}" ]]; then
PUB_FILE="${RUNNER_TEMP}/e2e_ssh_pub"
printf '%s\n' "$E2E_SSH_PUBLIC_KEY" >"$PUB_FILE"
chmod 644 "$PUB_FILE"
write_env SSH_PUBLIC_KEY "$PUB_FILE"
fi

if [[ -n "${E2E_CLUSTER_KUBECONFIG:-}" ]]; then
KC_FILE="${RUNNER_TEMP}/e2e_kubeconfig"
printf '%s' "$E2E_CLUSTER_KUBECONFIG" | base64 -d >"$KC_FILE"
chmod 600 "$KC_FILE"
write_env KUBE_CONFIG_PATH "$KC_FILE"
fi

write_env GOMODCACHE "${GOMODCACHE:-${RUNNER_TEMP}/e2e-gomodcache}"
write_env GOCACHE "${GOCACHE:-${RUNNER_TEMP}/e2e-gocache}"
write_env E2E_ARTIFACT_DIR "${E2E_ARTIFACT_DIR:-${RUNNER_TEMP}/e2e-artifacts}"

echo "e2e-env.sh prepared (secrets written to temp files only)"
Loading
Loading