From daeaaca902b4cdee4835cfdc9879f72525e949c2 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Wed, 18 Mar 2026 17:21:55 +0900 Subject: [PATCH] =?UTF-8?q?ci:=20npm=20test=20=EC=B6=94=EA=B0=80=20+=20Doc?= =?UTF-8?q?ker=20GHCR=20=EB=B9=8C=EB=93=9C/=ED=91=B8=EC=8B=9C=20+=20SSH=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test job: lint + vitest + build - docker job: main 머지 시 nginx 이미지 빌드/푸시 - deploy job: SSH로 docker compose pull web && up Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e144d5..4110e5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: CI/CD on: push: @@ -7,7 +7,8 @@ on: branches: [main] jobs: - build: + # ── 1. 린트 + 테스트 + 빌드 ──────────────────────────────────────────────── + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -23,7 +24,56 @@ jobs: - name: Lint run: npm run lint + - name: Test + run: npm test + - name: Build run: npm run build env: VITE_API_BASE_URL: https://a301.api.tolelom.xyz + + # ── 2. Docker 빌드 & GHCR 푸시 (main 머지 시만) ─────────────────────────── + docker: + needs: test + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/a301-web:latest + platforms: linux/arm64 + build-args: | + VITE_API_BASE_URL=https://a301.api.tolelom.xyz + cache-from: type=gha + cache-to: type=gha,mode=max + + # ── 3. 서버 배포 (Docker 푸시 완료 후) ──────────────────────────────────── + deploy: + needs: docker + runs-on: ubuntu-latest + steps: + - uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:$HOME/.docker/bin + cd ~/server + docker compose pull web + docker compose up -d web