Update deploy.yml #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Frontend CI/CD | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # 프로젝트에서 사용하는 Node.js 버전 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm test | |
- name: Build project | |
run: npm run build | |
env: | |
VITE_API_URL_MEMBER: ${{ secrets.API_URL_MEMBER }} # 환경 변수 설정 (맴버 API) | |
VITE_API_URL_PARTNER: ${{ secrets.API_URL_PARTNER }} # 환경 변수 설정 (파트너 API) | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 # 사용하는 AWS 리전 | |
- name: Deploy to S3 | |
run: | | |
aws s3 sync build/ s3://${{ secrets.S3_BUCKET }} --delete | |
- name: Invalidate CloudFront cache | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |