Skip to content

Commit

Permalink
pull request : ci-cd
Browse files Browse the repository at this point in the history
[TOONPICK] v 0.1.1
  • Loading branch information
ImGdevel authored Feb 3, 2025
2 parents 0009815 + 6821182 commit 023a541
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 34 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/backend-build.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/backend-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: TOONPICK CD (Docker Hub)

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: 저장소 체크아웃
uses: actions/checkout@v3

- name: Docker Build 및 Push (Docker Hub)
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
REPOSITORY: "toonpick-service-app"
run: |
docker build -t $DOCKER_HUB_USERNAME/$REPOSITORY:latest ./backend
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
docker push $DOCKER_HUB_USERNAME/$REPOSITORY:latest
- name: EC2에 SSH 접속하여 배포 실행
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
# 기존 컨테이너 중지 및 삭제
docker stop toonpick-service-app || true
docker rm toonpick-service-app || true
# 최신 이미지 다운로드
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/toonpick-service-app:latest
# 새 컨테이너 실행
docker run -d --name toonpick-service-app -p 8080:8080 ${{ secrets.DOCKER_HUB_USERNAME }}/toonpick-service-app:latest
41 changes: 41 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: TOONPICK Backend CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: 저장소 체크아웃
uses: actions/checkout@v3

- name: JDK 17 설정
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Gradle 캐시 설정 (빌드 속도 최적화)
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Gradle 실행 권한 추가
run: chmod +x backend/gradlew

- name: Gradle 빌드
run: |
cd backend
./gradlew clean build -x test --no-daemon --parallel --configure-on-demand

0 comments on commit 023a541

Please sign in to comment.