not to use docker compose for examples #51
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SQLDef Preview Example | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| postgresql-preview: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: testdb | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Preview PostgreSQL schema changes | |
| uses: ./ | |
| with: | |
| command: psqldef | |
| version: latest | |
| baseline-schema-file: examples/psqldef-current.sql | |
| schema-file: examples/psqldef-desired.sql | |
| pg-user: postgres | |
| pg-password: postgres | |
| pg-host: localhost | |
| pg-port: 5432 | |
| pg-database: testdb | |
| mysql-preview: | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: testpass | |
| MYSQL_DATABASE: testdb | |
| options: >- | |
| --health-cmd "mysqladmin ping -h localhost -u root -ptestpass" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| ports: | |
| - 3306:3306 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Preview MySQL schema changes | |
| uses: ./ | |
| with: | |
| command: mysqldef | |
| version: latest | |
| baseline-schema-file: examples/mysqldef-current.sql | |
| schema-file: examples/mysqldef-desired.sql | |
| mysql-user: root | |
| mysql-password: testpass | |
| mysql-host: 127.0.0.1 | |
| mysql-port: 3306 | |
| mysql-database: testdb | |
| sqlite-preview: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Preview SQLite schema changes | |
| uses: ./ | |
| with: | |
| command: sqlite3def | |
| version: latest | |
| baseline-schema-file: examples/sqlite3def-current.sql | |
| schema-file: examples/sqlite3def-desired.sql | |
| sqlite-database: test.db | |
| mssql-preview: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Start MSSQL | |
| run: | | |
| docker run -d \ | |
| --name mssql \ | |
| -e "ACCEPT_EULA=Y" \ | |
| -e "SA_PASSWORD=Passw0rd" \ | |
| -p 1433:1433 \ | |
| mcr.microsoft.com/mssql/server:2022-latest | |
| - name: Wait for MSSQL | |
| run: | | |
| # Install sqlcmd tools | |
| sudo apt-get update && sudo apt-get install -y curl gnupg | |
| curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc | |
| curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
| sudo apt-get update | |
| sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 | |
| # Wait for MSSQL to be ready | |
| for i in {1..60}; do | |
| if /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P "Passw0rd" -Q "SELECT 1" -C >/dev/null 2>&1; then | |
| echo "MSSQL is ready" | |
| break | |
| fi | |
| echo "Waiting for MSSQL..." | |
| sleep 3 | |
| done | |
| # Create the test database | |
| /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P "Passw0rd" -Q "CREATE DATABASE testdb;" -C | |
| - name: Preview MSSQL schema changes | |
| uses: ./ | |
| with: | |
| command: mssqldef | |
| version: latest | |
| baseline-schema-file: examples/mssqldef-current.sql | |
| schema-file: examples/mssqldef-desired.sql | |
| mssql-user: SA | |
| mssql-password: Passw0rd | |
| mssql-host: localhost | |
| mssql-port: 1433 | |
| mssql-database: testdb | |
| - name: Stop MSSQL | |
| if: always() | |
| run: docker stop mssql && docker rm mssql |