diff --git a/.gitignore b/.gitignore index a933f10..d963ba5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules/ .wrangler/ .dev.vars +.deploy-token +.envrc diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..760fb5b --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +# .deploy-token 파일에서 토큰을 읽거나, 환경변수에서 가져옴 +TOKEN_FILE="$(dirname "$0")/../.deploy-token" + +if [[ -f "$TOKEN_FILE" ]]; then + CLOUDFLARE_API_TOKEN="$(cat "$TOKEN_FILE" | tr -d '[:space:]')" +elif [[ -n "${CLOUDFLARE_API_TOKEN:-}" ]]; then + : # already set +else + echo "Error: .deploy-token 파일이 없고 CLOUDFLARE_API_TOKEN 환경변수도 없습니다." + echo " vault에서 토큰을 가져와 .deploy-token 에 저장하세요." + exit 1 +fi + +export CLOUDFLARE_API_TOKEN +exec npx wrangler deploy "$@"