Staging to Production #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Staging to Production | |
on: | |
workflow_run: | |
workflows: ["Push to Staging"] | |
types: | |
- completed | |
jobs: | |
e2e-tests: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
# Vérifier le code | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# Installer Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
# Installer Docker compose | |
- name: Install Docker compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
# Lancer les conteneurs avec Docker Compose | |
- name: Start Containers | |
run: | | |
cd app/ | |
docker-compose up -d | |
# Attendre que les conteneurs soient prêts | |
- name: Wait for Containers | |
run: | | |
sleep 10 | |
# Naviguer dans le dossier frontend et installer les dépendances | |
- name: Install Frontend Dependencies | |
run: | | |
cd app/frontend | |
npm install | |
# Exécuter les tests E2E avec Cypress dans le dossier frontend | |
- name: Run Cypress E2E Tests | |
run: | | |
cd app/frontend | |
npx cypress run | |
# Arrêter et supprimer les conteneurs | |
- name: Stop Containers | |
run: | | |
cd app/ | |
docker-compose down | |
# Configurer Git pour push sur une autre branche | |
- name: Set up Git for Push | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Pousser les changements vers la branche production (master) | |
- name: Push to Production Branch | |
if: success() | |
run: | | |
git fetch origin | |
git checkout staging | |
git branch -f master | |
git push origin master --force |