|
| 1 | +# GITHUB ACTIONS - WORKFLOW |
| 2 | + |
| 3 | +name: Test DB Migration Build |
| 4 | + |
| 5 | +on: |
| 6 | + # Allows you to run this workflow manually from the Actions tab |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + exportDumpAsSQL: |
| 10 | + description: 'Save PostgreSQL Debug Dump' |
| 11 | + default: false |
| 12 | + required: true |
| 13 | + type: boolean |
| 14 | + |
| 15 | +jobs: |
| 16 | + migrate: |
| 17 | + name: Migrate MySQL to PostgreSQL DB |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: ghcr.io/ietf-tools/datatracker-app-base:latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + services: |
| 24 | + db: |
| 25 | + image: ghcr.io/ietf-tools/datatracker-db:latest |
| 26 | + volumes: |
| 27 | + - mariadb-data:/var/lib/mysql |
| 28 | + env: |
| 29 | + MYSQL_ROOT_PASSWORD: ietf |
| 30 | + MYSQL_DATABASE: ietf_utf8 |
| 31 | + MYSQL_USER: django |
| 32 | + MYSQL_PASSWORD: RkTkDPFnKpko |
| 33 | + pgdb: |
| 34 | + image: postgres:14.5 |
| 35 | + volumes: |
| 36 | + - /pgdata:/var/lib/postgresql/data |
| 37 | + env: |
| 38 | + POSTGRES_PASSWORD: RkTkDPFnKpko |
| 39 | + POSTGRES_USER: django |
| 40 | + POSTGRES_DB: ietf |
| 41 | + POSTGRES_HOST_AUTH_METHOD: trust |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v3 |
| 44 | + with: |
| 45 | + ref: 'feat/pg-migrations' |
| 46 | + |
| 47 | + - name: Migrate |
| 48 | + uses: nick-fields/retry@v2 |
| 49 | + with: |
| 50 | + timeout_minutes: 30 |
| 51 | + max_attempts: 3 |
| 52 | + command: | |
| 53 | + chmod +x ./docker/scripts/db-pg-migrate.sh |
| 54 | + sh ./docker/scripts/db-pg-migrate.sh |
| 55 | + on_retry_command: | |
| 56 | + psql -U django -h pgdb -d ietf -v ON_ERROR_STOP=1 -c '\x' -c 'DROP SCHEMA ietf_utf8 CASCADE;' |
| 57 | + rm -f cast.load |
| 58 | + |
| 59 | + - name: Upload DB Dump |
| 60 | + uses: actions/upload-artifact@v3 |
| 61 | + with: |
| 62 | + name: dump |
| 63 | + path: ietf.dump |
| 64 | + |
| 65 | + - name: Export as SQL (Debug) |
| 66 | + if: ${{ github.event.inputs.exportDumpAsSQL == 'true' }} |
| 67 | + run: pg_dump -h pgdb -U django ietf > ietf.sql |
| 68 | + |
| 69 | + - name: Upload SQL DB Dump (Debug) |
| 70 | + if: ${{ github.event.inputs.exportDumpAsSQL == 'true' }} |
| 71 | + uses: actions/upload-artifact@v3 |
| 72 | + with: |
| 73 | + name: dumpsql |
| 74 | + path: ietf.sql |
| 75 | + |
| 76 | + build: |
| 77 | + name: Build PostgreSQL Docker Images |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: [migrate] |
| 80 | + permissions: |
| 81 | + contents: read |
| 82 | + packages: write |
| 83 | + |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v3 |
| 86 | + with: |
| 87 | + ref: 'feat/pg-migrations' |
| 88 | + |
| 89 | + - name: Download DB Dump |
| 90 | + uses: actions/download-artifact@v3 |
| 91 | + with: |
| 92 | + name: dump |
| 93 | + |
| 94 | + - name: Set up QEMU |
| 95 | + uses: docker/setup-qemu-action@v2 |
| 96 | + |
| 97 | + - name: Set up Docker Buildx |
| 98 | + uses: docker/setup-buildx-action@v2 |
| 99 | + |
| 100 | + - name: Login to GitHub Container Registry |
| 101 | + uses: docker/login-action@v2 |
| 102 | + with: |
| 103 | + registry: ghcr.io |
| 104 | + username: ${{ github.actor }} |
| 105 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + |
| 107 | + - name: Docker Build & Push |
| 108 | + uses: docker/build-push-action@v4 |
| 109 | + with: |
| 110 | + context: . |
| 111 | + file: docker/db-pg.Dockerfile |
| 112 | + platforms: linux/amd64,linux/arm64 |
| 113 | + push: true |
| 114 | + tags: ghcr.io/ietf-tools/datatracker-db-pg:migrate-test |
| 115 | + provenance: false |
0 commit comments