From 9d52f28062b26bdccc1ed3d115f92388e944d2f1 Mon Sep 17 00:00:00 2001 From: Vishal <321vishalds@gmail.com> Date: Sun, 28 Jul 2024 08:39:23 +0530 Subject: [PATCH] Fixed deployment actions script (#3) piped the password to sudo command with `-S` flag and fixed the restart error in the script --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1383b28..3b7abec 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,7 +9,6 @@ env: jobs: build: - runs-on: ubuntu-22.04 steps: @@ -25,11 +24,12 @@ jobs: run: sudo apt-get install sshpass rsync - name: write changes to server run: | - sshpass -p ${{ secrets.VPS_PASSWORD }} rsync -avz -e 'ssh -o StrictHostKeyChecking=no' target/release/ vishalds@${{ secrets.VPS_HOST }}:/home/vishalds/server/; sshpass -p ${{ secrets.VPS_PASSWORD }} rsync -avz -e 'ssh -o StrictHostKeyChecking=no' scripts/ vishalds@${{ secrets.VPS_HOST }}:/home/vishalds/scripts/ + sshpass -p ${{ secrets.VPS_PASSWORD }} rsync -avz -e 'ssh -o StrictHostKeyChecking=no' target/release/ vishalds@${{ secrets.VPS_HOST }}:/home/vishalds/server/ + sshpass -p ${{ secrets.VPS_PASSWORD }} rsync -avz -e 'ssh -o StrictHostKeyChecking=no' scripts/ vishalds@${{ secrets.VPS_HOST }}:/home/vishalds/scripts/ env: VPS_PASSWORD: ${{ secrets.VPS_PASSWORD }} - name: restart server run: | - sshpass -p ${{ secrets.VPS_PASSWORD }} ssh -o StrictHostKeyChecking=no vishalds@${{ secrets.VPS_HOST }} 'sudo systemctl restart zitefy.service' + sshpass -p ${{ secrets.VPS_PASSWORD }} ssh -o StrictHostKeyChecking=no vishalds@${{ secrets.VPS_HOST }} 'echo ${{ secrets.VPS_PASSWORD }} | sudo -S systemctl restart zitefy.service' env: VPS_PASSWORD: ${{ secrets.VPS_PASSWORD }} \ No newline at end of file