feat:CD 프로퍼티 실행 변수 수정2 #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD to Ubuntu Server | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
env: | |
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
- name: Copy files via SCP | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_IP }} | |
username: ${{ secrets.SSH_ID }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{secrets.SSH_PORT}} | |
source: "target/*.jar" | |
target: "~/" | |
rm: false | |
timeout: '30s' | |
command_timeout: '10m' | |
use_insecure_cipher: false | |
debug: true | |
# 앱 포트로 실행된 jar 파일 종료 | |
- name: Stop existing Spring Boot application | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_IP }} | |
username: ${{ secrets.SSH_ID }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
echo "Stopping existing application..." | |
pid=$(lsof -t -i:${{ secrets.COUPON_PORT }}) && kill -9 $pid || echo "No application running on port ${{ secrets.COUPON_PORT }}" | |
#앱 포트로 배포 한 jar 파일 실행 | |
- name: execute shell script | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_IP }} | |
username: ${{ secrets.SSH_ID }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script_stop: true | |
script: | | |
echo "Starting new application..." | |
source ~/.bashrc | |
nohup java -jar ~/target/BOOK-STORE-COUPON.jar --spring.profiles.active=prod --server.port=${{ secrets.COUPON_PORT }} --spring.datasource.password=${{ secrets.MYSQL_PASSWORD }} --spring.redis.password=${{ secrets.REDIS_PASSWORD }} > coupon.log 2>&1 & | |
echo "New application started. Check app.log for details." |