- Docker registry: ghcr.io → git.tolelom.xyz - 로그인: GITEA_TOKEN 사용 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
77 lines
2.2 KiB
YAML
77 lines
2.2 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
# ── 1. 린트 + 테스트 + 빌드 ────────────────────────────────────────────────
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --legacy-peer-deps
|
|
|
|
- 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 빌드 & Gitea 레지스트리 푸시 (main 머지 시만) ───────────────
|
|
docker:
|
|
needs: test
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: git.tolelom.xyz
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: git.tolelom.xyz/${{ 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. 서버 배포 ──────────────────────────────────────────────────────────
|
|
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
|