Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: #270 Github Actions를 통해 AWS 자동 배포 설정 #280

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: deploy-workflow

on:
push:
branches:
- main
workflow_dispatch:

jobs:
aws-deploy:
runs-on: ubuntu-latest
steps:
# Github workspace 로컬 다운로드
- name: Checkout branch
uses: actions/checkout@v4

# NodeJS 설치
- name: Setup Node.js environment v20
uses: actions/setup-node@v4
with:
node-version: 20

# Yarn 의존성 설치
- name: Install yarn dependencies
run: yarn install

# 빌드용 환경 변수 .env 파일 생성
- name: Create .env file for Vite
run: |
echo "VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}" >> .env
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" >> .env
shell: bash

# 프로젝트 빌드
- name: Build the project
run: yarn build

# AWS IAM credentials 설정
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

# S3에 빌드 파일 배포
- name: Deploy file to S3
run: |
aws s3 sync --delete --region ${{ secrets.AWS_REGION }} ./dist ${{ secrets.AWS_S3_BUCKET }}

# CloudFront 캐시 무효화
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"