Skip to content

Commit

Permalink
update auto-deployment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
wwingyou committed Mar 25, 2024
1 parent 05e1050 commit 17addf0
Showing 1 changed file with 7 additions and 33 deletions.
40 changes: 7 additions & 33 deletions .github/workflows/auto-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected]
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/[email protected]
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/[email protected]
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"

0 comments on commit 17addf0

Please sign in to comment.