@@ -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