Skip to content

Commit

Permalink
Test Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
gunGeongun committed Nov 20, 2024
1 parent 61f429d commit 0269012
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,23 @@ jobs:
with:
name: campushelper
path: build/libs/
- name: Deploy to EC2

- name: Configure SSH
run: |
# SSH 설정 최적화
mkdir -p ~/.ssh
echo -e "Host *\n\
ControlMaster auto\n\
ControlPath ~/.ssh/cm_%r@%h:%p\n\
ControlPersist 10m\n\
Compression yes\n\
TCPKeepAlive yes\n\
ServerAliveInterval 60" > ~/.ssh/config

# Private key 설정
echo "${{ secrets.EC2_SSH_KEY }}" > private_key.pem
chmod 600 private_key.pem

# 압축 전송으로 파일 전송 속도 향상
scp -C -i private_key.pem -o StrictHostKeyChecking=no build/libs/campushelper-0.0.1-SNAPSHOT.jar ${{ secrets.EC2_USERNAME }}@${{ secrets.EC2_HOST }}:/home/${{ secrets.EC2_USERNAME }}/campushelper.jar

# 안전하고 효율적인 프로세스 관리
ssh -i private_key.pem -o StrictHostKeyChecking=no ${{ secrets.EC2_USERNAME }}@${{ secrets.EC2_HOST }} '
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/key.pem
chmod 600 ~/.ssh/key.pem
echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
- name: Deploy to EC2
run: |
scp -i ~/.ssh/key.pem build/libs/campushelper-0.0.1-SNAPSHOT.jar ${{ secrets.EC2_USERNAME }}@${{ secrets.EC2_HOST }}:/home/${{ secrets.EC2_USERNAME }}/campushelper.jar
ssh -i ~/.ssh/key.pem ${{ secrets.EC2_USERNAME }}@${{ secrets.EC2_HOST }} '
pid=$(pgrep java)
if [ -n "$pid" ]; then
kill $pid
for i in {1..10}; do
if ! ps -p $pid > /dev/null; then
break
fi
sleep 1
done
kill -15 $pid
sleep 5
fi
nohup java -jar /home/${{ secrets.EC2_USERNAME }}/campushelper.jar > app.log 2>&1 &
'
rm -f private_key.pem

0 comments on commit 0269012

Please sign in to comment.