-
Notifications
You must be signed in to change notification settings - Fork 14
72 lines (69 loc) · 2.15 KB
/
migration_check.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
69
70
71
72
---
name: Migration validation
on:
workflow_dispatch:
inputs:
heroku_app:
description: 'Heroku app name[pola-app/pola-staging]'
required: true
default: 'pola-app'
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_ORGANIZATION: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEROKU_APP: ${{ github.event.inputs.heroku_app }}
jobs:
say_hello:
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }} ( ${{ github.sha }} )
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Login to Github Docker Registry
run: ./scripts/docker_login_github.py
- name: Copy .env.example to .env
run: cp .env.example .env
- name: Build image
run: ./scripts/ci-docker-image/build_image.sh
- name: Clear volumes
run: docker compose down --volumes
- name: Start PostgresSQL
run: docker compose up --detach --no-deps postgres
- name: Download database backup
run: heroku pg:backups:download --app "${HEROKU_APP}" --output /tmp/latest.dump
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
- name: Load production dump
run: |
set -x;
docker cp /tmp/latest.dump pola-backend_postgres_1:/tmp/latest.dump;
docker exec \
-i \
pola-backend_postgres_1 \
pg_restore \
--verbose \
--clean \
--no-acl \
--no-owner \
-h localhost \
-U pola_app \
-d pola_app /tmp/latest.dump || \
docker exec \
-i \
pola-backend_postgres_1 \
pg_restore \
--verbose \
--clean \
--no-acl \
--no-owner \
-h localhost \
-U pola_app \
-d pola_app /tmp/latest.dump
- name: Migrate database
run: docker compose run --no-deps --rm web /app/manage.py migrate
- name: Remove all data
run: |
set -x;
rm /tmp/latest.dump;
docker compose down --volumes