-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from wafflestudio/develop
ci: deploy.yml 추가
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '/*' |