-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Test and Deploy to VPS # Nom de l'action | ||
|
||
on: | ||
pull_request: | ||
branches: ['master', 'main'] # Déclenche lors de pull requests vers "master" ou "main" | ||
paths-ignore: ['docs/**'] # Ignore les changements dans "docs" | ||
|
||
push: | ||
branches: ['master', 'main'] # Déclenche lors des pushs vers "master" ou "main" | ||
paths-ignore: ['docs/**'] # Ignore les changements dans "docs" | ||
|
||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} # Gère la concurrence pour éviter les doublons | ||
cancel-in-progress: true # Annule les jobs en cours si un nouveau est déclenché | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest # Exécution sur Ubuntu | ||
strategy: | ||
max-parallel: 2 # Limite à 2 jobs en parallèle | ||
matrix: | ||
python-version: [3.9, 3.11] # Test sur Python 3.9, 3.11 | ||
|
||
steps: | ||
- name: Checkout Code Repository # Étape pour récupérer le code du dépôt | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python Version ${{ matrix.python-version }} # Configure la version Python à tester | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} # Utilise les versions Python du matrix | ||
|
||
- name: Install Dependencies # Installe les dépendances Python | ||
run: | | ||
python -m pip install --upgrade pip # Met à jour pip | ||
pip install -r requirements.txt # Installe les paquets à partir du fichier requirements.txt | ||
- name: Run Tests # Exécute les tests unitaires | ||
run: | | ||
python -m unittest discover -s tests # Exécute tous les tests dans le dossier "tests" | ||
deploy: | ||
runs-on: ubuntu-latest # Exécute sur Ubuntu | ||
needs: build # Le déploiement ne s'exécute que si tous les tests de build sont réussis | ||
steps: | ||
- name: Checkout Code Repository # Récupère à nouveau le code source | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install SSH Client # Installe le client SSH | ||
run: sudo apt-get install -y sshpass | ||
|
||
- name: Copy files to VPS # Copie les fichiers du projet vers le VPS | ||
env: | ||
SSH_PASS: ${{ secrets.VPS_SSH_PASS }} # Mot de passe SSH depuis les secrets | ||
run: | | ||
sshpass -p "$SSH_PASS" scp -o StrictHostKeyChecking=no -r ./* root@${{ secrets.VPS_IP }}:/var/www/efficient-research/ # Copie tous les fichiers sur le VPS | ||
- name: Run deployment script on VPS # Exécute le script de déploiement sur le VPS | ||
env: | ||
SSH_PASS: ${{ secrets.VPS_SSH_PASS }} # Mot de passe SSH depuis les secrets | ||
run: | | ||
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no root@${{ secrets.VPS_IP }} 'bash -s' < ./run.sh # Exécute le script "deploy.sh" sur le VPS |