Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update auto-deployment.yml #21

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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"
Loading