ci: add dev-db-migrations-test.yml workflow
This commit is contained in:
parent
1425c15355
commit
b5f9601852
115
.github/workflows/dev-db-migrations-test.yml
vendored
Normal file
115
.github/workflows/dev-db-migrations-test.yml
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
# GITHUB ACTIONS - WORKFLOW
|
||||
|
||||
name: Test DB Migration Build
|
||||
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
exportDumpAsSQL:
|
||||
description: 'Save PostgreSQL Debug Dump'
|
||||
default: false
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
migrate:
|
||||
name: Migrate MySQL to PostgreSQL DB
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/ietf-tools/datatracker-app-base:latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
services:
|
||||
db:
|
||||
image: ghcr.io/ietf-tools/datatracker-db:latest
|
||||
volumes:
|
||||
- mariadb-data:/var/lib/mysql
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: ietf
|
||||
MYSQL_DATABASE: ietf_utf8
|
||||
MYSQL_USER: django
|
||||
MYSQL_PASSWORD: RkTkDPFnKpko
|
||||
pgdb:
|
||||
image: postgres:14.5
|
||||
volumes:
|
||||
- /pgdata:/var/lib/postgresql/data
|
||||
env:
|
||||
POSTGRES_PASSWORD: RkTkDPFnKpko
|
||||
POSTGRES_USER: django
|
||||
POSTGRES_DB: ietf
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 'feat/pg-migrations'
|
||||
|
||||
- name: Migrate
|
||||
uses: nick-fields/retry@v2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
command: |
|
||||
chmod +x ./docker/scripts/db-pg-migrate.sh
|
||||
sh ./docker/scripts/db-pg-migrate.sh
|
||||
on_retry_command: |
|
||||
psql -U django -h pgdb -d ietf -v ON_ERROR_STOP=1 -c '\x' -c 'DROP SCHEMA ietf_utf8 CASCADE;'
|
||||
rm -f cast.load
|
||||
|
||||
- name: Upload DB Dump
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dump
|
||||
path: ietf.dump
|
||||
|
||||
- name: Export as SQL (Debug)
|
||||
if: ${{ github.event.inputs.exportDumpAsSQL == 'true' }}
|
||||
run: pg_dump -h pgdb -U django ietf > ietf.sql
|
||||
|
||||
- name: Upload SQL DB Dump (Debug)
|
||||
if: ${{ github.event.inputs.exportDumpAsSQL == 'true' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dumpsql
|
||||
path: ietf.sql
|
||||
|
||||
build:
|
||||
name: Build PostgreSQL Docker Images
|
||||
runs-on: ubuntu-latest
|
||||
needs: [migrate]
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 'feat/pg-migrations'
|
||||
|
||||
- name: Download DB Dump
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: dump
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker Build & Push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: docker/db-pg.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ghcr.io/ietf-tools/datatracker-db-pg:migrate-test
|
||||
provenance: false
|
Loading…
Reference in a new issue