Skip to content

deploy-workflow

deploy-workflow #4

Workflow file for this run

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
echo "VITE_KAKAO_URL=${{ secrets.VITE_KAKAO_URL }}" >> .env
echo "VITE_GOOGLE_URL=${{ secrets.VITE_GOOGLE_URL }}" >> .env
echo "VITE_STORAGE_SECRET_KEY=${{ secrets.VITE_STORAGE_SECRET_KEY }}" >> .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 "/*"