Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoon0221 authored Nov 23, 2024
1 parent 4c10cc4 commit 4f2a666
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ jobs:
run: chmod +x ./gradlew

- name: Build project
env:
SERVER_SSL_KEY_STORE: ${{ secrets.SERVER_SSL_KEY_STORE }}
SERVER_SSL_KEY_STORE_PASSWORD: ${{ secrets.SERVER_SSL_KEY_STORE_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: ./gradlew clean build

- name: Copy JAR to remote server
Expand All @@ -38,9 +47,18 @@ jobs:
scp build/libs/demo-0.0.1-SNAPSHOT.jar mykeyhost:~/
- name: Deploy application
env:
SERVER_SSL_KEY_STORE: ${{ secrets.SERVER_SSL_KEY_STORE }}
SERVER_SSL_KEY_STORE_PASSWORD: ${{ secrets.SERVER_SSL_KEY_STORE_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
set -x # 명령어를 실행할 때마다 출력
ssh mykeyhost << 'EOF'
sudo pkill -f 'java -jar' || true
sudo nohup java -jar ~/demo-0.0.1-SNAPSHOT.jar --server.port=443 > app.log 2>&1 &
sudo pkill -f 'java -jar' || true # 기존 실행 중인 서버 프로세스 종료
sudo nohup java -jar ~/demo-0.0.1-SNAPSHOT.jar --server.port=443 --server.ssl.key-store=$SERVER_SSL_KEY_STORE --server.ssl.key-store-password=$SERVER_SSL_KEY_STORE_PASSWORD --jwt.secret-key=$JWT_SECRET_KEY --spring.datasource.url=$DATABASE_URL --spring.datasource.username=$DATABASE_USERNAME --spring.datasource.password=$DATABASE_PASSWORD --cloud.aws.credentials.accessKey=$AWS_ACCESS_KEY_ID --cloud.aws.credentials.secretKey=$AWS_SECRET_ACCESS_KEY > app.log 2>&1 & # 새로 배포된 애플리케이션 실행
EOF

0 comments on commit 4f2a666

Please sign in to comment.