Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate before deployment #52

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,16 @@ jobs:
script_stop: false
script: |
cd ${{ matrix.env }}
# Get the latest version (to apply migration next)
make pull
# Apply migrations
make migrate-db
# Launch new version
make up

- name: Check services are up
uses: appleboy/ssh-action@master
id: livecheck
if: ${{ always() }}
with:
host: ${{ env.SSH_HOST }}
Expand All @@ -162,6 +168,8 @@ jobs:
script_stop: false
script: |
cd ${{ matrix.env }}
# Let 10s to the API to be up
sleep 10
make livecheck

- name: Cleanup obsolete Docker objects
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ create_external_volumes:
@echo "🥫 Creating external volumes (production only) …"
docker volume create open_prices_postgres-data


migrate-db:
@echo "🥫 Migrating database …"
${DOCKER_COMPOSE} run --rm --no-deps api poetry run alembic upgrade head

#---------#
# Cleanup #
#---------#
Expand Down
Loading