Skip to content

Staging to Production #31

Staging to Production

Staging to Production #31

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
# Configurer DVC avec l'action officielle
- name: Setup DVC
uses: iterative/setup-dvc@v2
# Init un dépôt DVC
- name: Check DVC Repository
run: |
dvc init --no-scm
# Configurer le remote Azure pour DVC
- name: Configure DVC Azure Remote
run: |
dvc remote add -d azure-remote azure://${{ secrets.AZURE_BLOB_STORAGE }}
dvc remote modify azure-remote account_name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}
dvc remote modify azure-remote account_key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }}
# Pull le modèle via DVC
- name: Pull Gradient Boosting Model
run: |
dvc pull app/backend/model/gradient_boosting.pkl.dvc
# 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: |
until curl -X GET http://localhost/api/; do
echo "Waiting for app to start...";
sleep 5;
done
# 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