[Refactor]: CategoryServiceImplTest 단위 테스트 -> 통합 테스트로 변경 #252
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ dev ] # dev 브랜치에 push될 때 실행 | |
| pull_request: | |
| branches: [ dev ] # dev 브랜치로 PR 생성 시 실행 | |
| jobs: | |
| build: | |
| runs-on: pickify # self-hosted runner | |
| steps: | |
| - uses: actions/checkout@v4 # 저장소 코드 체크아웃 | |
| with: | |
| fetch-depth: 0 # 전체 Git 기록을 가져옴 | |
| - name: Set up JDK 21 # Java 개발 킷 설정 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| # Gradle 캐싱 - 빌드 시간 향상 | |
| - name: Gradle Caching | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Make application.yml # application.yml 파일 생성 | |
| run: | | |
| cd ./src/main/resources | |
| echo "${{ secrets.APPLICATION_YML }}" > ./application.yml | |
| shell: bash | |
| - name: Grant execute permission for gradlew # gradlew 실행 권한 부여 | |
| run: chmod +x gradlew | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Run build | |
| run: ./gradlew build | |
| env: | |
| DB_URL: ${{ secrets.DB_URL }} | |
| DB_HOST_NAME: ${{ secrets.DB_HOST_NAME }} | |
| DB_HOST_PASSWORD: ${{ secrets.DB_HOST_PASSWORD }} | |
| JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
| JWT_EXPIRATION_TIME: ${{ secrets.JWT_EXPIRATION_TIME }} | |
| - name: Move JAR file to EC2 directory | |
| run: | | |
| mkdir -p /home/ubuntu/ | |
| mv /home/ubuntu/actions-runner/_work/backend/backend/build/libs/pickyfy-0.0.1-SNAPSHOT.jar /home/ubuntu/pickify-spring.jar | |
| shell: bash | |
| deploy: | |
| needs: build # build 작업이 성공적으로 완료된 후 실행 | |
| runs-on: pickify # self-hosted runner에서 실행 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 전체 Git 기록 가져오기 | |
| - name: Check for merge commit # Merge commit 확인 | |
| id: check-merge | |
| run: | | |
| if [[ "$(git log -1 --pretty=%B)" != *"Merge pull request"* ]]; then | |
| echo "Not a merge commit. Skipping deployment." | |
| echo "skip-deployment=true" >> $GITHUB_ENV | |
| else | |
| echo "skip-deployment=false" >> $GITHUB_ENV | |
| fi | |
| - name: Stop Existing Application # 기존 Java 애플리케이션 종료 | |
| if: env.skip-deployment != 'true' # skip-deployment가 false일 때만 실행 | |
| run: | | |
| sudo systemctl stop pickify || true | |
| - name: Start Application # 새로운 JAR 실행 | |
| if: env.skip-deployment != 'true' # skip-deployment가 false일 때만 실행 | |
| run: | | |
| sudo systemctl daemon-reload | |
| sudo systemctl restart pickify |