feat: health check #5
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: Main-Application CI/CD | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'application/main-application/**' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Gradle 권한 부여 | |
run: chmod +x gradlew | |
- name: Gradle로 빌드 실행 | |
run: ./gradlew :application:main-application:bootJar | |
# 배포에 필요한 여러 설정 파일과 프로젝트 빌드파일을 zip 파일로 모아줍니다. | |
- name: zip file 생성 | |
run: | | |
mkdir deploy | |
cp ./application/main-application/docker/Dockerfile ./deploy/ | |
cp ./application/main-application/docker/docker-compose.minipc.yml ./deploy/ | |
cp ./application/main-application/scripts/minipc-docker-deploy.sh ./deploy/ | |
cp ./application/main-application/build/libs/*.jar ./deploy/ | |
chmod +x ./deploy/minipc-docker-deploy.sh | |
zip -r -qq -j ./yapp-main-application.zip ./deploy | |
# ZIP 파일 전송 | |
- name: Transfer ZIP file use SCP | |
uses: appleboy/scp-action@master | |
with: | |
username: ${{ secrets.SSH_USERNAME }} | |
host: ${{ secrets.SSH_HOST }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
source: "./yapp-main-application.zip" | |
target: "/home/hong/app/yapp-main-application" | |
# SSH 연결 후 배포 스크립트 실행 | |
- name: Execute SSH command on remote server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
REMOTE_DIR="/home/hong/app/yapp-main-application" | |
cd $REMOTE_DIR | |
unzip -o yapp-main-application.zip | |
./minipc-docker-deploy.sh | |