From 0fb7d72e8aef80680bbc5306a5fb99a3fbefc711 Mon Sep 17 00:00:00 2001 From: Ankan Saha Date: Sun, 7 Apr 2024 15:25:17 +0530 Subject: [PATCH] Fix deployment script to delete App folder if it exists before copying code to VM --- .github/workflows/deploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c4c8c50..a92228e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,10 +22,14 @@ jobs: run: | echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key.pem chmod 600 private_key.pem - + + - name: Check if App folder exists and delete if it does + run: | + ssh -i private_key.pem ${{ secrets.USERNAME }}@${{ secrets.VM_IP }} '[ -d ~/App ] && rm -rf ~/App || true' + - name: Copy code to VM run: | - sudo scp -o StrictHostKeyChecking=no -i private_key.pem -r ./* ${{ secrets.USERNAME }}@${{ secrets.VM_IP }}:~/ # Copies all files and directories to the home directory of the user on VM + sudo scp -o StrictHostKeyChecking=no -i private_key.pem -r ./* ${{ secrets.USERNAME }}@${{ secrets.VM_IP }}:~/App # Copies all files and directories to the home directory of the user on VM - name: Clean Up run: |