Skip to content

Update check-migrations.yml #6

Update check-migrations.yml

Update check-migrations.yml #6

name: Test migrations and draw DB schema
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
env:
DOCKER_LOCALHOST: 172.17.0.1
POSTGRESQL_IMAGE: postgres:15.5
LIQUIBASE_IMAGE: liquibase/liquibase:4.19.0
TBLS_IMAGE: ghcr.io/k1low/tbls:v1.72.0
POSTGRESQL_DB: fintech
MIGRATIONS_FOLDER: migrations
LIQUIBASE_CHANGELOG_FILE: changelog.xml
jobs:
main:
runs-on: ubuntu-latest
#services:
# postgresql:
# image: ${{env.POSTGRESQL_IMAGE}}
# env:
# POSTGRES_DB: ${{env.POSTGRESQL_DB}}
# POSTGRES_HOST_AUTH_METHOD: trust
# ports:
# - 5432:5432
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Run PostgreSQL service
run: docker run --rm --name postgresql -p 5432:5432 -e POSTGRES_DB=${{env.POSTGRESQL_DB}} -e POSTGRES_HOST_AUTH_METHOD=true --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -d ${{env.POSTGRESQL_IMAGE}}
- name: Wait for PostgreSQL run and headlthy
run: until docker inspect --format "{{json .State.Health.Status }}" postgresql|grep -m 1 "healthy"; do sleep 5 ; done
- name: Run migrations
run: docker run --rm -v "$(pwd)/${{env.MIGRATIONS_FOLDER}}":/app --network "host" ${{env.LIQUIBASE_IMAGE}} update --changelog-file=/app/${{env.LIQUIBASE_CHANGELOG_FILE}} --url=jdbc:postgresql://${{env.DOCKER_LOCALHOST}}:5432/${{env.POSTGRESQL_DB}}