Skip to content

Commit

Permalink
Update auto-deployment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
wwingyou authored Mar 24, 2024
1 parent dd655fa commit fb66582
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/auto-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,30 @@ jobs:
chmod 755 gradlew
./gradlew bootJar
./gradlew jarDir
- name: Prepare SSH private key
- name: Prepare SSH connect
env:
private_key: ${{ secrets.EC2_PRIVATE_KEY }}
run: |
echo "$private_key" > private_key.pem
chmod 400 private_key.pem
eval "$(ssh-agent)"
ssh-add private_key.pem
ssh-keyscan -t rsa $host > ~/.ssh/known_hosts
- name: Upload deployment scripts
run: scp -r deploy "${username}@${host}:~/deploy"
- name: Kill current running Spring process
run: ssh -o StrictHostKeyChecking=no -i private_key.pem "${username}@${host}" 'kill $(sudo lsof -t -i :8080)'
run: |
ssh "${username}@${host}" << EOF
sudo chmod 755 deploy/shutdown.sh
./deploy/shutdown.sh
EOF
- name: Send jar file to EC2
run: |
jarPath=$(./gradlew -q jarPath)
scp -i private_key.pem $jarPath "${username}@${host}:~/server.jar"
scp -i private_key.pem "deployment/runner.sh" "${username}@${host}:~/runner.sh"
scp $jarPath "${username}@${host}:~/server.jar"
- name: Run new uploaded jar
run: |
sudo chmod 755 runner.sh
./runner.sh server.jar
ssh "${username}@${host}" << EOF
sudo chmod 755 deploy/runner.sh
./deploy/runner.sh server.jar
EOF

0 comments on commit fb66582

Please sign in to comment.