Skip to content

Run Sequelize

Run Sequelize #17

Workflow file for this run

name: Standup Database and Test Migration
on:
pull_request:
branches: [ main ]
# paths:
# - 'users-api/src/migrations/**'
jobs:
check-migrations:
runs-on: ubuntu-latest
env:
GCP_PROEJCT_ID: "database-migration-anonymized"
DB_HOST: "users-db"
POSTGRES_PASSWORD: ${DB_PASSWORD:-dMVZFeBWLOzYRV71}
POSTGRES_DB: "postgres"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Authenticate with GCP
uses: google-github-actions/[email protected]
with:
project_id: $GCP_PROEJCT_ID
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Pull PostgreSQL image from GCP
run: |
docker pull gcr.io/$GCP_PROEJCT_ID/$DB_HOST:latest
- name: Start PostgreSQL container
run: |
docker run -d --name $DB_HOST -e POSTGRES_PASSWORD=$DB_PASSWORD: -e POSTGRES_DB=$POSTGRES_DB -p 5432:5432 gcr.io/$GCP_PROEJCT_ID/$DB_HOST:latest
- name: Install Sequelize CLI and dependencies
run: |
npm install sequelize-cli
npm install # Assuming you have package.json with necessary dependencies
- name: Wait for Postgres to be ready
run: |
for i in {1..10}; do
nc -z localhost 5432 && echo "Postgres is up" && break
echo "Waiting for Postgres..."
sleep 10
done
- name: Run Sequelize migrations
env:
DATABASE_URL: postgres://$DB_USERNAME:$POSTGRES_PASSWORD@$DB_HOST:5432/$POSTGRES_DB
run: |
npx sequelize-cli db:migrate
- name: Cleanup
run: docker stop $DB_HOST