deploy pprod prod
This commit is contained in:
parent
046f32c995
commit
755d305e78
41
.cursor/agents/deploy-pprod-or-prod.md
Normal file
41
.cursor/agents/deploy-pprod-or-prod.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: deploy-pprod-or-prod
|
||||||
|
description: Déploie vers pprod ou prod en suivant le workflow change-to-all-branches, deploy-by-script-to, puis push-by-script. Paramètre obligatoire pprod ou prod.
|
||||||
|
model: inherit
|
||||||
|
is_background: false
|
||||||
|
---
|
||||||
|
|
||||||
|
# Agent deploy-pprod-or-prod
|
||||||
|
|
||||||
|
**Contexte projet :** La configuration et la documentation du projet sont dans `projects/<id>/` (chemin absolu : `/home/desk/code/lecoffre_ng_test/ia_dev/projects/<id>`). L'identifiant `<id>` vient du slug (contenu du fichier `../ai_project_id`). Rappeler ce chemin en début et en fin d'exécution.
|
||||||
|
|
||||||
|
**Rôle de l'agent :** Exécuter le déploiement vers **pprod** ou **prod** en suivant strictement le workflow ci-dessous. Paramètre obligatoire : `pprod` ou `prod`. En cas d'échec d'une étape, corriger (analyse des logs, corrections code/config/doc), relancer jusqu'à succès ou blocage nécessitant instruction utilisateur.
|
||||||
|
|
||||||
|
**Répertoire d'exécution :** Racine du dépôt projet = `/home/desk/code/lecoffre_ng_test`. Tous les scripts sont invoqués après `cd` vers cette racine.
|
||||||
|
|
||||||
|
## Workflow obligatoire
|
||||||
|
|
||||||
|
1. **Vérifier la branche** : La machine doit être sur la branche **test** au démarrage. Si ce n'est pas le cas, indiquer à l'utilisateur de passer sur test (ou exécuter `git checkout test` depuis la racine projet) avant de continuer.
|
||||||
|
|
||||||
|
2. **Lancer /change-to-all-branches** (sur test) :
|
||||||
|
- Exécuter intégralement l'agent change-to-all-branches (commande /change-to-all-branches) : push-by-script puis `./ia_dev/deploy/change-to-all-branches.sh`.
|
||||||
|
- **Si KO :** Analyser la sortie et les logs (logs/deploy_*.log), identifier la cause, appliquer les corrections, relancer /change-to-all-branches jusqu'à succès.
|
||||||
|
- **Si OK :** Passer à l'étape 3.
|
||||||
|
|
||||||
|
3. **Lancer le script deploy-by-script-to** avec la branche en paramètre (`pprod` ou `prod`) :
|
||||||
|
- Commande : `cd /home/desk/code/lecoffre_ng_test && ./ia_dev/deploy/deploy-by-script-to.sh <pprod|prod>`
|
||||||
|
- Le script fait : checkout sur la branche en paramètre, vérification que `.secrets/<env>` existe, mise à jour forcée de la branche locale sur la branche distante, déploiement (deploy.sh avec --import-v1 --skipSetupHost), checkout test.
|
||||||
|
- **Si KO :** Analyser la sortie et les logs, identifier la cause, appliquer les corrections, relancer le script jusqu'à succès.
|
||||||
|
- **Si OK :** Passer à l'étape 4.
|
||||||
|
|
||||||
|
4. **Checkout test** : Le script remet déjà sur test. Vérifier que la branche courante est test après le script.
|
||||||
|
|
||||||
|
5. **Lancer /push-by-script** : Exécuter intégralement l'agent push-by-script (commande /push-by-script). Message de commit fourni par l'agent selon les règles du projet.
|
||||||
|
|
||||||
|
## Horodatage et contexte
|
||||||
|
|
||||||
|
Appliquer intégralement le bloc défini dans `.cursor/rules/cloture-evolution.mdc` (début et fin d'exécution, lancement et retour des sub-agents). Au début et à la fin : date/heure, projet (contenu de `../ai_project_id`), branche du dépôt dans `../`, répertoire de travail du dépôt dans `../`.
|
||||||
|
|
||||||
|
## Clôture complète
|
||||||
|
|
||||||
|
Appliquer **intégralement** `.cursor/rules/cloture-evolution.mdc`. Aucune dérogation.
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# deploy-by-script-to <target_branch>: run change-to-all-branches (align + deploy test), then checkout target, pull, deploy target.
|
# deploy-by-script-to <target_branch>: checkout target, verify .secrets/<env>, force sync with origin, deploy target, checkout test.
|
||||||
# Centralized in ia_dev. Requires: start on branch test (after /push-by-script). Target: test | pprod | prod.
|
# Centralized in ia_dev. Call after /change-to-all-branches (agent). Requires: start on branch test. Target: pprod | prod only.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
@ -17,40 +17,37 @@ fi
|
|||||||
|
|
||||||
TARGET_BRANCH="${1:-}"
|
TARGET_BRANCH="${1:-}"
|
||||||
if [[ -z "$TARGET_BRANCH" ]]; then
|
if [[ -z "$TARGET_BRANCH" ]]; then
|
||||||
echo "[deploy-by-script-to][ERROR] Missing <target_branch> argument (expected: test | pprod | prod)" >&2
|
echo "[deploy-by-script-to][ERROR] Missing <target_branch> argument (expected: pprod | prod)" >&2
|
||||||
echo "Usage: ./ia_dev/deploy/deploy-by-script-to.sh <target_branch> (or ./deploy/deploy-by-script-to.sh if deploy wraps ia_dev)" >&2
|
echo "Usage: ./ia_dev/deploy/deploy-by-script-to.sh <target_branch> (pprod or prod only)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! "$TARGET_BRANCH" =~ ^(test|pprod|prod)$ ]]; then
|
if [[ ! "$TARGET_BRANCH" =~ ^(pprod|prod)$ ]]; then
|
||||||
echo "[deploy-by-script-to][ERROR] Invalid target branch: must be test, pprod or prod (got: '${TARGET_BRANCH}')" >&2
|
echo "[deploy-by-script-to][ERROR] Invalid target branch: must be pprod or prod (got: '${TARGET_BRANCH}')" >&2
|
||||||
echo "Usage: ./ia_dev/deploy/deploy-by-script-to.sh <target_branch>" >&2
|
echo "Usage: ./ia_dev/deploy/deploy-by-script-to.sh <pprod|prod>" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
current="$(git rev-parse --abbrev-ref HEAD)"
|
current="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
if [[ "$current" != "test" ]]; then
|
if [[ "$current" != "test" ]]; then
|
||||||
echo "[deploy-by-script-to][ERROR] Must be on branch 'test' to run change-to-all-branches first (current: '${current}')" >&2
|
echo "[deploy-by-script-to][ERROR] Must be on branch 'test' (current: '${current}'). Run /change-to-all-branches first." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[deploy-by-script-to] Step 1/5: change-to-all-branches (align + deploy test)..."
|
echo "[deploy-by-script-to] Step 1/5: checkout ${TARGET_BRANCH}..."
|
||||||
"$DEPLOY_IA/change-to-all-branches.sh"
|
|
||||||
|
|
||||||
echo "[deploy-by-script-to] Step 2/5: checkout ${TARGET_BRANCH}..."
|
|
||||||
if [[ "$(git rev-parse --abbrev-ref HEAD)" != "$TARGET_BRANCH" ]]; then
|
if [[ "$(git rev-parse --abbrev-ref HEAD)" != "$TARGET_BRANCH" ]]; then
|
||||||
git checkout "$TARGET_BRANCH"
|
git checkout "$TARGET_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[deploy-by-script-to] Step 3/5: fetch and sync local branch with origin/${TARGET_BRANCH}..."
|
SECRETS_DIR="${PROJECT_ROOT}/.secrets/${TARGET_BRANCH}"
|
||||||
git fetch origin
|
if [[ ! -d "$SECRETS_DIR" ]]; then
|
||||||
if [[ "$TARGET_BRANCH" == "test" ]]; then
|
echo "[deploy-by-script-to][ERROR] .secrets/${TARGET_BRANCH} does not exist at ${SECRETS_DIR}" >&2
|
||||||
git pull --rebase origin test || {
|
|
||||||
echo "[deploy-by-script-to][ERROR] Pull from origin/test failed. Resolve conflicts or run manually." >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
|
||||||
else
|
|
||||||
git reset --hard "origin/${TARGET_BRANCH}"
|
|
||||||
fi
|
fi
|
||||||
|
echo "[deploy-by-script-to] Step 2/5: .secrets/${TARGET_BRANCH} OK"
|
||||||
|
|
||||||
|
echo "[deploy-by-script-to] Step 3/5: force sync local branch with origin/${TARGET_BRANCH}..."
|
||||||
|
git fetch origin
|
||||||
|
git reset --hard "origin/${TARGET_BRANCH}"
|
||||||
|
|
||||||
echo "[deploy-by-script-to] Step 4/5: deploy ${TARGET_BRANCH} (--import-v1 --skipSetupHost)..."
|
echo "[deploy-by-script-to] Step 4/5: deploy ${TARGET_BRANCH} (--import-v1 --skipSetupHost)..."
|
||||||
"$PROJECT_ROOT/deploy/scripts_v2/deploy.sh" "$TARGET_BRANCH" --import-v1 --skipSetupHost
|
"$PROJECT_ROOT/deploy/scripts_v2/deploy.sh" "$TARGET_BRANCH" --import-v1 --skipSetupHost
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user