From 17addf0f6a5237f3a4d25a03fea3442d8611b86e Mon Sep 17 00:00:00 2001 From: wingyou Date: Mon, 25 Mar 2024 23:46:36 +0900 Subject: [PATCH] update auto-deployment.yml --- .github/workflows/auto-deployment.yml | 40 +++++---------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/.github/workflows/auto-deployment.yml b/.github/workflows/auto-deployment.yml index 1e665a3..5462d22 100644 --- a/.github/workflows/auto-deployment.yml +++ b/.github/workflows/auto-deployment.yml @@ -31,9 +31,8 @@ jobs: - name: Build Jar run: | - chmod 755 gradlew - ./gradlew bootJar - working-directory: JWT + chmod 755 JWT/gradlew + JWT/gradlew bootJar - name: Prepare SSH connect env: @@ -43,50 +42,25 @@ jobs: chmod 400 private_key.pem mkdir ~/.ssh ssh-keyscan -t rsa $host > ~/.ssh/known_hosts - working-directory: JWT - name: Upload deployment scripts run: | - scp -i private_key.pem -r deploy "${username}@${host}:~" - working-directory: JWT + sudo chmod 755 JWT/deploy/* + scp -i private_key.pem -r JWT/deploy "${username}@${host}:~" - name: Kill current running Spring process - uses: fifsky/ssh-action@v0.0.6 - with: - command: | - sudo chmod 755 deploy/* - deploy/shutdown.sh - deploy/backup.sh - host: ${{ secrets.EC2_HOST }} - user: ${{ secrets.EC2_USERNAME }} - key: ${{ secrets.EC2_PRIVATE_KEY }} + run: ssh -i private_key.pem "${username}@${host}" "deploy/shutdown.sh; deploy/backup.sh" - name: Send jar file to EC2 run: | jarPath=$(./gradlew -q jarPath) scp -i private_key.pem $jarPath "${username}@${host}:~/server.jar" - working-directory: JWT - name: Startup new uploaded jar - uses: fifsky/ssh-action@v0.0.6 - with: - command: | - sudo chmod 755 deploy/* - deploy/startup.sh - host: ${{ secrets.EC2_HOST }} - user: ${{ secrets.EC2_USERNAME }} - key: ${{ secrets.EC2_PRIVATE_KEY }} + run: ssh -i private_key.pem "${username}@${host}" "deploy/startup.sh" - name: Wait 30 seconds for server to startup run: sleep 30 - name: Check and Recover - uses: fifsky/ssh-action@v0.0.6 - with: - command: | - sudo chmod 755 deploy/* - deploy/check_and_recover.sh - host: ${{ secrets.EC2_HOST }} - user: ${{ secrets.EC2_USERNAME }} - key: ${{ secrets.EC2_PRIVATE_KEY }} - + run: ssh -i private_key.pem "${username}@${host}" "deploy/check_and_recover.sh"