Skip to content

Commit

Permalink
fix: remove enable option (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinho1011 authored Feb 8, 2024
1 parent ac72441 commit 8c74cf2
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CD

on:
push:
branches:
- main

jobs:
build:
name: build & deploy
runs-on: ubuntu-latest
steps:
- name: checkout Github Action
uses: actions/checkout@v3

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: install yarn dependencies
run: yarn install

- name: react build
run: yarn run build

# aws에 접근하기 위한 권한을 받아옵니다.
- 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_KEY }}
aws-region: ap-northeast-2

# S3에 build 파일을 올립니다.
- name: Upload to S3
env:
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME}}
run: |
aws s3 sync \
./build s3://$BUCKET_NAME
# cloudfront로 배포되는 파일은 기본설정 상 24시간동안 캐시가 유지됩니다.
# 배포 후 S3에는 최신 정적리소스가 올라가있지만 엣지로케이션엔 이전 파일이 올라가있는 상태라는 의미입니다.
# 바로 변화가 반영되길 바란다면 invalidation을 해주면 됩니다.
# 해당 부분은 과금될 수 있으니 확인 후 사용하세요!
- name: CloudFront Invalidation
env:
CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID}}
run: |
aws cloudfront create-invalidation \
--distribution-id $CLOUD_FRONT_ID --paths /*

0 comments on commit 8c74cf2

Please sign in to comment.