ci(deploy): back up before migrating and run migrations explicitly (#9)
CD — Deployment / deploy (push) Successful in 23s

- dump the database to ./backups before applying migrations
- run the one-shot migrate service on every deploy instead of relying only on
  the api depends_on, so a migration is never skipped
- translate the workflow comments to English

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #9
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #9.
This commit is contained in:
Gitea Actions
2026-10-17 12:34:56 +00:00
committed by Esiah
co-authored by Esiah
parent bcbb5030ec
commit 4d725d9a3b
38 changed files with 1517 additions and 521 deletions
+12 -6
View File
@@ -1,4 +1,4 @@
name: CD — Déploiement
name: CD — Deployment
on:
push:
@@ -20,19 +20,25 @@ jobs:
deploy:
runs-on: self-hosted
steps:
- name: Récupérer puis reconstruire
- name: Fetch latest code and rebuild
env:
# Chemin du dépôt sur le serveur. Défini via le secret DEPLOY_DIR si
# besoin ; sinon la valeur par défaut ci-dessous est utilisée.
# Repository path on the server. Set it through the DEPLOY_DIR
# secret when needed; otherwise the default below is used.
DEPLOY_DIR: ${{ secrets.DEPLOY_DIR }}
run: |
set -eu
dir="${DEPLOY_DIR:-/srv/apps/cohaise-cloud/CoHaiSe-CLOUD}"
cd "$dir"
git pull --ff-only origin main
# Le build des images compile et typecheck chaque workspace (tsc) :
# aucune toolchain Node n'est requise sur l'hote.
# Image builds compile and typecheck every workspace (tsc): no Node
# toolchain is required on the host.
docker compose build api migrate nginx
# Back up the database before a potentially destructive migration.
# Dumps land in ./backups on the host, never in the repository.
make backup
# Run migrations explicitly: the one-shot service must execute on
# every deploy, not only when its image happens to change.
docker compose run --rm migrate
make front
docker compose up -d api nginx
docker image prune -f