[CHORE] 미동작 CI 수정 #19
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: CI | |
on: | |
push: | |
branches: | |
- 'fe/**' # fe/로 시작하는 모든 브랜치에 대해 푸시 이벤트 트리거 | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] # Node.js 버전을 18.x와 20.x로 업데이트 | |
# PR의 소스 브랜치가 fe/로 시작하는 경우에만 실행 | |
if: > | |
startsWith(github.head_ref, 'fe/') || | |
(github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'fe/')) | |
steps: | |
# 1. 리포지토리 체크아웃 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # 전체 히스토리를 가져옵니다. | |
# 2. frontend 디렉토리 내용 확인 (디버깅용) | |
- name: List frontend directory (Debug) | |
run: | | |
echo "Listing frontend directory:" | |
ls -la frontend/ | |
echo "Checking yarn.lock:" | |
ls -la frontend/yarn.lock | |
# 3. Node.js 설정 (Yarn 캐싱 비활성화) | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# 4. Yarn 캐시 설정 (frontend/yarn.lock 기반) | |
- name: Cache Yarn dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/yarn | |
key: ${{ runner.os }}-yarn-${{ hashFiles('frontend/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
# 5. 의존성 설치 | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
working-directory: frontend | |
# 6. ESLint 실행 | |
- name: Run ESLint | |
run: yarn lint | |
working-directory: frontend | |
# 7. Prettier 자동 수정 및 커밋 | |
- name: Run Prettier and fix issues | |
run: | | |
yarn prettier --write "src/**/*.{js,jsx,ts,tsx,css,scss,md}" | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Fix Prettier formatting issues" || echo "No changes to commit" | |
git push | |
working-directory: frontend | |
# 8. 타입 체크 | |
- name: Type Check | |
run: yarn type-check | |
working-directory: frontend | |
# 9. 테스트 실행 | |
- name: Run Tests | |
run: yarn test --coverage | |
working-directory: frontend | |
# 10. 빌드 실행 | |
- name: Build | |
run: yarn build | |
working-directory: frontend | |
# 11. 빌드 아티팩트 업로드 | |
- name: Upload Artifacts | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts | |
path: frontend/build/ |