-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.83 KB
/
test-migration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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}
DB_USERNAME: "postgres"
POSTGRES_DB: "postgres"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Authenticate with GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Use gcloud CLI
run: gcloud info
- name: Configure Docker to authenticate with GCR
run: |
gcloud auth configure-docker
- 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=$POSTGRES_PASSWORD: -e POSTGRES_DB=$POSTGRES_DB -p 5432:5432 gcr.io/$GCP_PROEJCT_ID/$DB_HOST:latest
- name: Install Sequelize CLI and dependencies
run: |
cd ./users-api/src
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:
DB_PASSWORD: "dMVZFeBWLOzYRV71" # ${POSTGRES_PASSWORD}
DB_NAME: "postgres"
run: |
cd ./users-api/src
npx sequelize-cli db:migrate
- name: Cleanup
run: docker stop $DB_HOST