Skip to content

Commit f4fd470

Browse files
committed
test
1 parent 4c1577d commit f4fd470

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

β€Ž.github/workflows/_atlas-migrations-reusable.ymlβ€Ž

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
- name: Start Cloud SQL Proxy
150150
if: inputs.use_cloud_sql
151151
run: |
152-
cloud-sql-proxy ${{ inputs.cloud_sql_instance }} --port 5432 &
152+
cloud-sql-proxy ${{ inputs.cloud_sql_instance }} --port 15432 &
153153
sleep 10 # Wait for proxy to start
154154
echo "Cloud SQL Proxy started for instance: ${{ inputs.cloud_sql_instance }}"
155155
@@ -241,17 +241,15 @@ jobs:
241241
- name: Apply migrations to ${{ inputs.environment_name }} (Cloud SQL)
242242
if: inputs.action == 'deploy' && inputs.use_cloud_sql
243243
run: |
244-
# Get access token for IAM authentication
245-
ACCESS_TOKEN=$(gcloud auth print-access-token)
244+
# Set PostgreSQL environment variables for authentication
245+
export PGUSER="${{ inputs.cloud_sql_user }}"
246+
export PGPASSWORD=$(gcloud auth print-access-token)
246247
247-
# URL encode the username (replace @ with %40)
248-
ENCODED_USER=$(echo "${{ inputs.cloud_sql_user }}" | sed 's/@/%40/g')
248+
# Clean connection URL without credentials
249+
export CLOUD_SQL_URL="postgresql://localhost:15432/${{ inputs.cloud_sql_database }}?sslmode=disable"
249250
250-
# Build Cloud SQL connection URL with encoded username
251-
CLOUD_SQL_URL="postgresql://${ENCODED_USER}:${ACCESS_TOKEN}@localhost:5432/${{ inputs.cloud_sql_database }}?sslmode=disable"
252-
253-
echo "πŸ”— Connecting to Cloud SQL with user: ${{ inputs.cloud_sql_user }}"
254-
echo "πŸ”— Encoded user: ${ENCODED_USER}"
251+
echo "πŸ”— Connecting to Cloud SQL as user: $PGUSER"
252+
echo "πŸ”— Using connection URL: $CLOUD_SQL_URL"
255253
256254
atlas migrate apply \
257255
--config "file://${{ inputs.atlas_config_path }}" \
@@ -275,9 +273,9 @@ jobs:
275273
else
276274
# Determine the database URL to use
277275
if [ "${{ inputs.use_cloud_sql }}" = "true" ]; then
278-
ACCESS_TOKEN=$(gcloud auth print-access-token)
279-
ENCODED_USER=$(echo "${{ inputs.cloud_sql_user }}" | sed 's/@/%40/g')
280-
DB_URL="postgresql://${ENCODED_USER}:${ACCESS_TOKEN}@localhost:5432/${{ inputs.cloud_sql_database }}?sslmode=disable"
276+
export PGUSER="${{ inputs.cloud_sql_user }}"
277+
export PGPASSWORD=$(gcloud auth print-access-token)
278+
DB_URL="postgresql://localhost:15432/${{ inputs.cloud_sql_database }}?sslmode=disable"
281279
echo "πŸ“Š Checking Cloud SQL migration status..."
282280
else
283281
DB_URL="$DATABASE_URL"

0 commit comments

Comments
Β (0)