Skip to content

Commit

Permalink
fix: 프론트 CI/CD 스크립트 전체 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
capDoYeonLee committed Nov 1, 2023
1 parent 1a8561c commit e31e1c3
Showing 1 changed file with 58 additions and 17 deletions.
75 changes: 58 additions & 17 deletions .github/workflows/frontendCICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,71 @@ on:
permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

jobs: # job 설정
react: # job id
name: 리액트 build & deploy
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./fe # 기본 워킹 디렉토리 설정
steps:
- name: Checkout source code.
uses: actions/checkout@master
- name: checkout Github Action
uses: actions/checkout@v3 # github actions 가상 환경에 해당 레포 소스 가져오기

- name: install npm dependencies
run: npm install

- name: Upload binary to S3 bucket
uses: jakejarvis/s3-sync-action@master
- name: React build
run: npm run build

# aws user 연결
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
args: --acl public-read --exclude '*' --include 'index.html'
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:
AWS_S3_BUCKET: ${{ secrets.BUCKET_NAME }}
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME}}
run: |
aws s3 sync \
./build s3://$BUCKET_NAME
- name: Invalidate cache CloudFront
uses: chetan/invalidate-cloudfront-action@master
# 업로드한 s3 파일을 각 CDN 캐시 무효화하여 리프레시 하기
- name: CloudFront Invalidation
env:
AWS_DISTRIBUTION_ID: ${{ secrets.AWS_DISTRIBUTION_ID }}
PATHS: '/index.html'
CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID}}
run: |
aws cloudfront create-invalidation \
--distribution-id $CLOUD_FRONT_ID --paths /*
#jobs:
# build:
# runs-on: ubuntu-latest
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_REGION: ${{ secrets.AWS_REGION }}
#
# steps:
# - name: Checkout source code.
# uses: actions/checkout@master
#
# - name: Upload binary to S3 bucket
# uses: jakejarvis/s3-sync-action@master
# with:
# args: --acl public-read --exclude '*' --include 'index.html'
# env:
# AWS_S3_BUCKET: ${{ secrets.BUCKET_NAME }}
#
# - name: Invalidate cache CloudFront
# uses: chetan/invalidate-cloudfront-action@master
# env:
# AWS_DISTRIBUTION_ID: ${{ secrets.AWS_DISTRIBUTION_ID }}
# PATHS: '/index.html'
# continue-on-error: true
#jobs:
# build:
Expand Down

0 comments on commit e31e1c3

Please sign in to comment.