Aller au contenu

Déployer La Webapp En Staging

Objectif

Déployer heymoov-web sur https://app.staging.heymoov.com via la chaîne GitHub Actions existante.

L'automation exécutable vit dans heymoov-platform. Ce runbook centralise l'ordre opérateur et les décisions de configuration.

État À Préparer

Au moment de la préparation de ce runbook, staging avait déjà :

  • nginx et le proxy backend pour app.staging.heymoov.com ;
  • l'API staging exposée derrière /v1/ ;
  • Hydra staging sur auth.staging.heymoov.com ;
  • Mercure staging sur mercure.staging.heymoov.com.

Il restait à créer :

  • le webroot /var/www/app.staging.heymoov.com ;
  • l'utilisateur local gha-heymoov-web-staging ;
  • l'environnement GitHub staging dans LSO-Labs/heymoov-web ;
  • le runner self-hosted labellisé heymoov-web-deploy-staging.

Pré-requis

  • accès SSH opérateur à ls2i-staging ;
  • gh auth status fonctionnel avec accès admin à LSO-Labs/heymoov-web et LSO-Labs/heymoov-landing ;
  • clé Turnstile autorisant app.staging.heymoov.com, à renseigner manuellement dans GitHub après création du placeholder ;
  • repository local heymoov-platform à jour.

Bootstrap

Toutes les commandes suivantes se lancent depuis heymoov-platform.

  1. Vérifier la topologie :
make topology-env ENV=staging CHECK=1
  1. Préparer la cible webapp staging :
make bootstrap-webapp-heymoov-staging DRY_RUN=1
make bootstrap-webapp-heymoov-staging
  1. Remplacer RUNTIME_TURNSTILE_SITE_KEY dans l'environnement GitHub staging de LSO-Labs/heymoov-web si la variable contient encore le placeholder.

  2. Vérifier la cible complète :

make verify-webapp-staging-readiness

Les étapes détaillées restent disponibles si une seule phase doit être relancée.

  1. Préparer le webroot statique et l'utilisateur runner :
make bootstrap-webapp-target-heymoov-staging DRY_RUN=1
make bootstrap-webapp-target-heymoov-staging
  1. Créer ou mettre à jour l'environnement GitHub staging :
make bootstrap-webapp-github-env-heymoov-staging DRY_RUN=1
make bootstrap-webapp-github-env-heymoov-staging

Cette commande pose les variables générables et crée RUNTIME_TURNSTILE_SITE_KEY avec un placeholder si la variable manque. Le placeholder doit être remplacé manuellement dans l'environnement GitHub avant la suite.

  1. Installer et enregistrer le runner GitHub staging :
make bootstrap-webapp-runner-heymoov-staging DRY_RUN=1
make bootstrap-webapp-runner-heymoov-staging
  1. Vérifier la cible complète :
make verify-webapp-staging-readiness

Variables GitHub Attendues

L'environnement staging de LSO-Labs/heymoov-web doit contenir :

WEB_DEPLOY_ROOT=/var/www/app.staging.heymoov.com
WEB_DEPLOY_URL=https://app.staging.heymoov.com
WEB_KEEP_RELEASES=5
RUNTIME_API_BASE_URL=https://app.staging.heymoov.com
RUNTIME_API_PREFIX_AUTH=/v1/web/auth
RUNTIME_API_PREFIX_PUBLIC=/v1/public
RUNTIME_API_PREFIX_API=/v1/web/api
RUNTIME_MERCURE_URL=https://mercure.staging.heymoov.com
RUNTIME_MERCURE_TOPIC_PREFIX=https://app.staging.heymoov.com
RUNTIME_UPLOAD_BASE_URL=https://app.staging.heymoov.com/uploads
RUNTIME_TURNSTILE_SITE_KEY=replace-with-staging-turnstile-site-key
RUNTIME_HUGO_URL=https://staging.heymoov.com

RUNTIME_MERCURE_TOPIC_PREFIX n'a pas de slash final. Le helper frontend ajoute le séparateur de chemin. La variable backend MERCURE_TOPICS_PREFIX conserve, elle, son slash final.

RUNTIME_TURNSTILE_SITE_KEY est un prérequis manuel : le placeholder doit être remplacé par la clé de site staging avant make verify-webapp-staging-readiness et avant tout déploiement.

Déploiement Applicatif

Une fois la readiness validée :

  1. promouvoir le commit voulu de heymoov-web vers la branche staging ;
  2. laisser le workflow Web CI construire et déployer ;
  3. vérifier :
curl -fsS https://app.staging.heymoov.com/runtime-config.js
curl -fsS https://app.staging.heymoov.com/

Après Déploiement

Quand app.staging.heymoov.com sert la webapp, mettre à jour les variables staging de heymoov-landing via heymoov-platform :

make bootstrap-landing-github-env-heymoov-staging DRY_RUN=1
make bootstrap-landing-github-env-heymoov-staging

Cette commande pose aussi les autres variables générables de la landing staging et préserve HUGO_TURNSTILE_KEY si la variable existe déjà.

Puis redéployer la landing staging.