Skip to content

[FE] github actions 으로 cd 를 구축한다. #7

[FE] github actions 으로 cd 를 구축한다.

[FE] github actions 으로 cd 를 구축한다. #7

Workflow file for this run

name: frontend-dev-cd
on:
pull_request:
branches:
- dev-fe
paths:
- "frontend/**"
push:
branches:
- dev-fe
paths:
- "frontend/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Generate .env File
working-directory: ./frontend
run: |
echo "API_ENV=${{ secrets.API_ENV }}"
echo "API_URL=${{ secrets.API_URL }}"
echo "REDIRECT_URI=${{ secrets.REDIRECT_URI }}"
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}"
echo "GA_ID=${{ secrets.GA_ID }}"
echo "KAKAO_MAP_KEY=${{ secrets.KAKAO_MAP_KEY }}"
echo "SENTRY_DSN_TOKEN=${{ secrets.SENTRY_DSN_TOKEN }}"
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
echo "SENTRY_ORG=${{ secrets.SENTRY_ORG }}"
echo "SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}"
echo "ANALYZE_BUNDLE=${{ secrets.ANALYZE_BUNDLE }}"
echo "CI=${{ secrets.CI }}"
echo "AMPLITUDE_API_KEY=${{ secrets.AMPLITUDE_API_KEY }}"
- name: Install Dependencies
working-directory: ./frontend
run: npm install
- name: Build for Dev
working-directory: ./frontend
run: npm run build:dev-fe
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Deploy to S3
working-directory: ./frontend/dist
run: |
aws s3 sync . s3://${{secrets.DEV_S3_BUCKET}} --delete
- name: Invalidate CloudFront Cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"