Skip to content

Commit

Permalink
chore: migrate before deployment (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 authored Nov 23, 2023
1 parent 954e0e7 commit bb91bfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit bb91bfc

Please sign in to comment.