Skip to content

Commit 26c9769

Browse files
congsoonyclaude
andcommitted
chore: FE 자동 배포 워크플로우 추가 (S3 + CloudFront)
- develop push마다 Vite 빌드 → S3 sync → CloudFront 캐시 무효화 - VITE_API_BASE 등 설정값은 GitHub Secrets로 주입 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cf4999c commit 26c9769

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# =====================================================================
2+
# develop push → Vite 빌드 → S3 업로드 → CloudFront 캐시 무효화
3+
#
4+
# 필요한 GitHub Secrets (repo Settings > Secrets and variables > Actions):
5+
# AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY : S3+CloudFront 권한 IAM 키
6+
# S3_FRONTEND_BUCKET : 프론트 정적 호스팅 버킷 (예: studyflow-frontend)
7+
# CLOUDFRONT_DISTRIBUTION_ID : CloudFront 배포 ID
8+
# VITE_API_BASE : 백엔드 주소 (예: https://studyflow-api.duckdns.org)
9+
#
10+
# 자세한 절차는 BE repo의 DEPLOY.md 참고
11+
# =====================================================================
12+
name: Deploy Frontend to S3/CloudFront
13+
14+
on:
15+
push:
16+
branches: [develop]
17+
workflow_dispatch: {} # 수동 실행 버튼
18+
19+
jobs:
20+
build-and-deploy:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Build
37+
run: npm run build
38+
env:
39+
# 프로덕션 빌드는 VITE_API_BASE 미설정 시 의도적으로 실패한다 (src/api/config.js)
40+
VITE_API_BASE: ${{ secrets.VITE_API_BASE }}
41+
42+
- name: Configure AWS credentials
43+
uses: aws-actions/configure-aws-credentials@v4
44+
with:
45+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
46+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
47+
aws-region: ap-northeast-2
48+
49+
- name: Upload to S3
50+
run: aws s3 sync dist "s3://${{ secrets.S3_FRONTEND_BUCKET }}" --delete
51+
52+
- name: Invalidate CloudFront cache
53+
run: |
54+
aws cloudfront create-invalidation \
55+
--distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}" \
56+
--paths "/*"

0 commit comments

Comments
 (0)