Skip to content

Commit

Permalink
Merge pull request #1 from wafflestudio/develop
Browse files Browse the repository at this point in the history
ci: deploy.yml 추가
  • Loading branch information
jwchoi-kr authored Dec 28, 2024
2 parents 8dc9b89 + 25bd4c1 commit cdafcfd
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy to S3 and CloudFront

on:
push:
branches:
- main
- develop

jobs:
deploy:
runs-on: ubuntu-latest

steps:
# 1. Check out the repository
- name: Checkout Code
uses: actions/checkout@v3

# 2. Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 23 # Update this if your app uses a different version

# 3. Install dependencies
- name: Install Dependencies
run: yarn install

# 4. Build the app
- name: Build React App
run: yarn build

# 5. Deploy to Production S3 Bucket (main branch)
- name: Deploy to Production
if: github.ref == 'refs/heads/main'
uses: jakejarvis/[email protected]
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_PROD_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist

# 6. Deploy to Development S3 Bucket (develop branch)
- name: Deploy to Development
if: github.ref == 'refs/heads/develop'
uses: jakejarvis/[email protected]
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_DEV_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist

# 7. Invalidate CloudFront Cache (Production)
- name: Invalidate CloudFront Cache (Production)
if: github.ref == 'refs/heads/main'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_PROD_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'

# 8. Invalidate CloudFront Cache (Development)
- name: Invalidate CloudFront Cache (Development)
if: github.ref == 'refs/heads/develop'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_DEV_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'

0 comments on commit cdafcfd

Please sign in to comment.