Skip to content

Commit

Permalink
๐Ÿ“ฆ๏ธ Chore: S3-CloudFront CICD Settings ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyeongjang authored Sep 2, 2024
1 parent cac3ad7 commit 56cc257
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,34 @@ name: Deploy to S3 and CloudFront

on:
push:
branches:
- dev
branches: [dev]

env:
CI: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Checkout source code
uses: actions/checkout@v2 # workflow์—์„œ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋„๋ก ์ €์žฅ์†Œ๋ฅผ ์ฒดํฌ์•„์›ƒ

- name: Install dependencies
run: npm install
run: yarn install

- name: Build project
run: npm run build
- name: Build
run: yarn build

- name: Deploy to S3
uses: aws-actions/s3-sync@v1.0.4
with:
source-dir: 'build'
destination-bucket: ${{ secrets.AWS_S3_BUCKET }}
destination-region: 'ap-northeast-2'
delete-removed: true
- name: S3 Deploy
run: aws s3 sync ./build s3://bobpience-s3-bucket/ --acl bucket-owner-full-control # ํ˜„์žฌ build๋œ ํด๋”์— ์ ‘๊ทผ ํ›„ s3 ๋ฒ„ํ‚ท์— build ํŒŒ์ผ ์—…๋กœ๋“œ
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Invalidate CloudFront
uses: aws-actions/cloudfront-invalidate@v1.0.1
with:
distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
paths: '/*'
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Invalidate CloudFront Cache # ์ƒˆ๋กœ ๋ฆฌ์†Œ์Šค๋ฅผ ์—…๋ฐ์ดํŠธํ•  ๋•Œ ๊ธฐ์กด ์บ์‹œ ๋ฌดํšจํ™”
uses: chetan/invalidate-cloudfront-action@master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DISTRIBUTION: ${{ secrets.AWS_DISTRIBUTION_ID }}
PATHS: '/index.html'
continue-on-error: true

0 comments on commit 56cc257

Please sign in to comment.