Run database migrations on deploy before starting container (#264)
Migrations were never being run against production on deploy, causing schema mismatches when new columns are added. This adds a migration step using the PROD_DATABASE_URL secret before bringing up the new container, with set -e to abort the deploy if migrations fail. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2b680d7272
commit
89d52cca5e
1 changed files with 5 additions and 1 deletions
6
.github/workflows/deploy.yml
vendored
6
.github/workflows/deploy.yml
vendored
|
|
@ -138,16 +138,20 @@ jobs:
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
|
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
|
||||||
|
PROD_DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }}
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.DEPLOY_HOST }}
|
host: ${{ secrets.DEPLOY_HOST }}
|
||||||
port: ${{ secrets.DEPLOY_PORT }}
|
port: ${{ secrets.DEPLOY_PORT }}
|
||||||
username: ${{ secrets.DEPLOY_USER }}
|
username: ${{ secrets.DEPLOY_USER }}
|
||||||
key: ${{ secrets.DEPLOY_KEY }}
|
key: ${{ secrets.DEPLOY_KEY }}
|
||||||
envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY
|
envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY,PROD_DATABASE_URL
|
||||||
script: |
|
script: |
|
||||||
|
set -e
|
||||||
|
IMAGE="$CONTAINER_REGISTRY/brackt:latest"
|
||||||
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
||||||
cd brackt
|
cd brackt
|
||||||
docker compose pull
|
docker compose pull
|
||||||
|
docker run --rm -e DATABASE_URL="$PROD_DATABASE_URL" "$IMAGE" npx drizzle-kit migrate
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
sleep 10
|
sleep 10
|
||||||
if docker compose ps | grep -qE "Exit|exited"; then
|
if docker compose ps | grep -qE "Exit|exited"; then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue