Files
a301_client/.github/workflows/ci.yml
tolelom 32d87d8151
Some checks failed
Client CI/CD / test (push) Waiting to run
Client CI/CD / deploy (push) Has been cancelled
Fix: CI에서 actions/checkout도 제거 — 모든 GitHub Action 의존 완전 제거
Gitea runner가 github.com clone에서 멈추는 문제.
actions/checkout@v4도 git fetch로 직접 대체.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 16:50:10 +09:00

83 lines
2.9 KiB
YAML

name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# ── 1. 린트 + 테스트 + 빌드 ────────────────────────────────────────────────
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
run: |
git config --global --add safe.directory /workspace/A301/a301_client
git init
git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git
git fetch --depth=1 origin $GITHUB_SHA
git checkout $GITHUB_SHA
- name: Setup Node.js
run: |
if ! command -v node &>/dev/null || [ "$(node -v | cut -d. -f1 | tr -d v)" -lt 22 ]; then
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
fi
node -v && npm -v
- 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:
- name: Checkout
run: |
git config --global --add safe.directory /workspace/A301/a301_client
git init
git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git
git fetch --depth=1 origin $GITHUB_SHA
git checkout $GITHUB_SHA
- name: Login to Gitea Registry
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.tolelom.xyz -u "${{ github.actor }}" --password-stdin
- name: Build and Push Docker Image
run: |
docker build \
--build-arg VITE_API_BASE_URL=https://a301.api.tolelom.xyz \
-t git.tolelom.xyz/${{ github.repository_owner }}/a301-web:latest \
.
docker push git.tolelom.xyz/${{ github.repository_owner }}/a301-web:latest
# ── 3. 서버 배포 ──────────────────────────────────────────────────────────
deploy:
needs: docker
runs-on: ubuntu-latest
steps:
- name: Deploy to Server
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
'export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:$HOME/.docker/bin && cd ~/server && docker compose pull web && docker compose up -d web'
rm -f ~/.ssh/deploy_key