diff --git a/.github/workflows/stripe-to-invoice.yml b/.github/workflows/stripe-to-invoice.yml index b2ac901..3811b7c 100644 --- a/.github/workflows/stripe-to-invoice.yml +++ b/.github/workflows/stripe-to-invoice.yml @@ -155,9 +155,11 @@ jobs: if [[ "$ENV" == "prod" ]]; then USER="$PROD_POSTGRES_USER" PASS="$PROD_POSTGRES_PASSWORD" + RUNTIME_SECRET=postgres-prod else USER="$DEV_POSTGRES_USER" PASS="$DEV_POSTGRES_PASSWORD" + RUNTIME_SECRET=postgres-dev fi DATABASE_URL="postgres://${USER}:${PASS}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?sslmode=disable" @@ -247,6 +249,21 @@ jobs: echo "POSTGRES_DB=stripe_invoice" >> $GITHUB_ENV fi + - name: Wait for Postgres TCP + run: | + set -e + for i in {1..30}; do + if nc -z "$POSTGRES_HOST" 5432; then + echo "Postgres is accepting connections" + exit 0 + fi + echo "Waiting for Postgres ($i/30)..." + sleep 5 + done + echo "Postgres never became ready" + exit 1 + + - name: Run migrations run: | set -e