Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD build 실행 self-hosted-runner에서 하도록 변경 #269

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 22 additions & 33 deletions .github/workflows/backend_cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 백엔드 CD
name: Backend CD

on:
push:
Expand All @@ -7,38 +7,34 @@ on:
- main

jobs:
find-branch:
runs-on: self-hosted
steps:
- name: 브랜치명을 통해 개발 환경 알아내기
run: |
cd ${{ secrets.SCRIPT_DIRECTORY }}
bash find-env-by-branch.sh

build:
runs-on: ubuntu-latest
needs: find-branch
runs-on: self-hosted
steps:
- name: 체크아웃
uses: actions/checkout@v4

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


- name: gradle 캐싱
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
uses: gradle/actions/setup-gradle@v3

- name: bootJar로 jar 파일 생성
run: ./gradlew bootJar
run: |
./gradlew bootJar
mv build/libs/*.jar ${{ secrets.WORK_DIRECTORY }}/${{ env.ENVIRONMENT }}
working-directory: ./backend

- name: jar 파일 Artifact로 업로드
uses: actions/upload-artifact@v4
with:
name: code-zap-jar
path: backend/build/libs/*.jar


- name: 클린업
if: always()
run: rm -rf ../2024-code-zap/*

deploy:
needs: build
runs-on: self-hosted
Expand All @@ -48,25 +44,18 @@ jobs:
cd ${{ secrets.SCRIPT_DIRECTORY }}
bash find-env-by-branch.sh

- name: Artifact 다운로드
uses: actions/download-artifact@v4
with:
name: code-zap-jar
path: ${{ secrets.WORK_DIRECTORY }}/${{ env.ENVIRONMENT }}

- name: 실행 프로세스 확인
run: |
cd ${{ secrets.SCRIPT_DIRECTORY }}
bash check-old-pids.sh

- name: 배포 스크립트 실행
run: |
cd ${{ secrets.WORK_DIRECTORY }}
unzip -o code-zap-jar.zip
cd ${{ secrets.SCRIPT_DIRECTORY }}
RUNNER_TRACKING_ID="" && bash start.sh ${{ env.ENVIRONMENT }}

- name: 실행 프로세스 확인으로 배포 검증
run: |
cd ${{ secrets.SCRIPT_DIRECTORY }}
bash verify-deploy.sh

17 changes: 8 additions & 9 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: 백엔드 CI
name: Backend CI

on:
pull_request:
branches:
- dev/be
- develop
- main

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- name: 체크아웃
uses: actions/checkout@v4
Expand All @@ -23,13 +24,11 @@ jobs:
path: /h2-console
datasource:
url: jdbc:h2:mem:database" > backend/src/main/resources/application.yml

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

- name: 테스트 코드 실행
run: ./gradlew test
working-directory: ./backend

- name: 클린업
if: always()
run: rm -rf ../2024-code-zap/*