Merge pull request #23 from Cleanwalk-org-QNSCNT/main #15
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: Deploy to VPS | |
on: | |
push: | |
branches: | |
- release # Déclencher le déploiement uniquement sur la branche release | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SECRET_KEY }} # Utilisation de la clé SSH | |
- name: Backup current state | |
env: | |
VPS_IP: ${{ secrets.VPS_IP }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$VPS_IP ' | |
rm -rf /home/cleanwalk-backup && | |
cp -r /home/cleanwalk-org-v2 /home/cleanwalk-backup | |
' | |
- name: Deploy to VPS | |
env: | |
VPS_IP: ${{ secrets.VPS_IP }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$VPS_IP ' | |
cd /home/cleanwalk-org-v2 && | |
git pull origin release && | |
docker compose -f docker-compose.prod.yml down && | |
docker compose -f docker-compose.prod.yml up -d --build | |
' | |
- name: Cleanup backup | |
if: success() | |
env: | |
VPS_IP: ${{ secrets.VPS_IP }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$VPS_IP ' | |
rm -rf /home/cleanwalk-backup | |
' | |
- name: Rollback (if needed) | |
if: failure() | |
env: | |
VPS_IP: ${{ secrets.VPS_IP }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$VPS_IP ' | |
cd /home/cleanwalk-backup && | |
docker compose -f docker-compose.prod.yml up -d --build | |
' |