remove: 프론트 CD 주석 삭제 #17
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Node.js CI/CD | |
on: | |
push: | |
branches: [ "infra" ] | |
pull_request: | |
branches: [ "infra" ] | |
permissions: | |
contents: read | |
jobs: # job 설정 | |
react: # job id | |
name: 리액트 build & deploy | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./fe # 기본 워킹 디렉토리 설정 | |
steps: | |
- name: checkout Github Action | |
uses: actions/checkout@v3 # github actions 가상 환경에 해당 레포 소스 가져오기 | |
- name: install npm dependencies | |
run: npm install | |
- name: React build | |
run: npm run build | |
# aws user 연결 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY_ID }} | |
aws-region: ap-northeast-2 | |
# react 빌드한 /build를 s3로 업로드 | |
- name: Upload to S3 | |
env: | |
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME}} | |
run: | | |
aws s3 sync \ | |
./build s3://$BUCKET_NAME | |
# 업로드한 s3 파일을 각 CDN 캐시 무효화하여 리프레시 하기 | |
- name: CloudFront Invalidation | |
env: | |
CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID}} | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id $CLOUD_FRONT_ID --paths /* | |