Skip to content

fix: local, dev에서만 debug 옵션 추가 #26

fix: local, dev에서만 debug 옵션 추가

fix: local, dev에서만 debug 옵션 추가 #26

name: Baguni Test Batch-Module CI/CD
on:
push:
branches:
- 'be-develop' # 배포 대상 브랜치
paths:
- 'backend/baguni-core/**'
- 'backend/baguni-batch/**'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
docker-hub-username: 'minkyeu'
docker-hub-repo: 'baguni' # TODO: change to baguni
module-name: 'baguni-batch'
steps:
# 저장소 Checkout
- name: Checkout source code
uses: actions/checkout@v4
# Gradle 실행 권한 부여
- name: Grant execute permission to gradlew
run: chmod +x ./backend/gradlew
# JDK 설치
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'
# Spring boot application, Docker image 빌드
- name: Build and Deploy ${{ env.module-name }} Module
run: |
./backend/gradlew -p backend/${{ env.module-name }} clean build -x test
docker build -t ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }} backend/${{ env.module-name }}
- # Docker hub 로그인
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.docker-hub-username }}
password: ${{ secrets.DOCKERHUB_REPO_BAGUNI_TOKEN }}
- # Docker hub 업로드
name: Publish to docker hub
run: docker push ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }}
- name: Deploy on Test-Server
uses: appleboy/ssh-action@master
with:
host: minlife.me
port: 4242
username: root
password: ${{ secrets.SSH_TEST_SERVER_KYEU_PASSWORD }}
script: |
echo "login docker hub for private repository access ..."
echo ${{ secrets.DOCKERHUB_REPO_BAGUNI_TOKEN }} | docker login -u ${{ env.docker-hub-username }} --password-stdin
echo "docker - pulling..."
docker pull ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }}
echo "docker - changing image name and tag ..."
docker tag ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }} ${{ env.docker-hub-repo }}:${{ env.module-name }}-staging
echo "moving to project directory..."
cd /home/project/baguni/develop
echo "restarting container..."
docker compose down ${{ env.module-name }}
docker compose up ${{ env.module-name }} -d
- name: Discord Webhook Notification
uses: sarisia/[email protected]
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
status: ${{ job.status }}
title: 'TEST BATCH SERVER DEPLOY'
color: 0xff91a4
url: 'https://github.com/sarisia/actions-status-discord'
username: GitHub Actions