Skip to content

[FIX] 누락 lock 파일 추가 (#488) #89

[FIX] 누락 lock 파일 추가 (#488)

[FIX] 누락 lock 파일 추가 (#488) #89

name: Frontend CD (Dev)
on:
workflow_dispatch:
push:
branches: [develop]
paths:
- "frontend/**"
- ".github/workflows/frontend-cd-dev.yml"
jobs:
deploy-production:
runs-on: ubuntu-latest
environment: production
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 25.2.1
cache: yarn
cache-dependency-path: frontend/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
- name: Lint
run: yarn lint
- name: Format check
run: yarn format:check
- name: Cache Next.js Build Cache
id: next-cache
uses: actions/cache@v4
with:
path: frontend/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('frontend/yarn.lock') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('frontend/yarn.lock') }}-
${{ runner.os }}-nextjs-
- name: Install Vercel CLI
run: npm install -g vercel
- name: Pull Vercel Environment
run: vercel pull --yes --environment=production --token=$VERCEL_TOKEN
- name: Build
run: vercel build --prod --token=$VERCEL_TOKEN
- name: Deploy to Production
id: deploy
run: |
URL=$(vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN)
echo "deploy_url=$URL" >> "$GITHUB_OUTPUT"
echo "### Deployed to Production" >> "$GITHUB_STEP_SUMMARY"
echo "$URL" >> "$GITHUB_STEP_SUMMARY"
- name: Health Check
id: healthcheck
run: |
PROD_URL="${{ steps.deploy.outputs.deploy_url }}"
echo "Checking $PROD_URL ..."
for i in 1 2 3 4 5; do
STATUS=$(curl -L -o /dev/null -s -w "%{http_code}" "$PROD_URL")
if [ "$STATUS" -eq 200 ]; then
echo "Health check passed (HTTP $STATUS)"
exit 0
fi
echo "Attempt $i: HTTP $STATUS — retrying..."
sleep 10
done
echo "Health check failed after 5 attempts"
exit 1
- name: Rollback on Failure
if: failure() && steps.healthcheck.outcome == 'failure'
run: |
echo "Health check failed. Rolling back..."
vercel rollback --token=$VERCEL_TOKEN --yes
echo "Rollback command executed."
- name: Cache KPI Summary
if: always()
run: |
echo "### Frontend CD Cache KPI" >> "$GITHUB_STEP_SUMMARY"
echo "- Next.js cache hit: ${{ steps.next-cache.outputs.cache-hit }}" >> "$GITHUB_STEP_SUMMARY"