Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: deploy.yml 추가 #1

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '/*'
Loading