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 13f6ced commit dd655fa
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/auto-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
env:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
private_key: ${{ secrets.EC2_PRIVATE_KEY }}

steps:
- uses: actions/checkout@v4.1.2
Expand All @@ -39,10 +38,20 @@ jobs:
chmod 755 gradlew
./gradlew bootJar
./gradlew jarDir
- name: Connect to EC2
- name: Prepare SSH private key
env:
private_key: ${{ secrets.EC2_PRIVATE_KEY }}
run: |
echo "$private_key" > private_key.pem
chmod 400 private_key.pem
ssh -o StrictHostKeyChecking=no -i private_key.pem "${username}@${host}" echo hello
- name: Env Test
run: echo $host
- name: Kill current running Spring process
run: ssh -o StrictHostKeyChecking=no -i private_key.pem "${username}@${host}" 'kill $(sudo lsof -t -i :8080)'
- 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"
- name: Run new uploaded jar
run: |
sudo chmod 755 runner.sh
./runner.sh server.jar

0 comments on commit dd655fa

Please sign in to comment.