Skip to content

Commit

Permalink
fix: CI/CD 파이프라인 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
gogo1414 committed Nov 19, 2024
1 parent fe786ce commit 4b7362f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
name: Deploy React to EC2 using S3 and CodeDeploy
name: Build & Deploy to AWS CloudFront

on:
push:
branches:
- main
- 88-fix/github-actions-workflows-cicd

jobs:
build-and-deploy:
name: Build And Deploy
runs-on: ubuntu-latest
env:
BUCKET: matal.store
DIST: build
REGION: ap-northeast-2
DIST_ID: E1EYXYPW1RLFM5

steps:
- name: Checkout code
Expand All @@ -16,33 +23,27 @@ jobs:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_FE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_FE_SECRET_ACCESS_KEY }}
aws-region: ${{env.REGION}}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '21.1.0' # Node.js 21.1.0 버전 사용
node-version: '21.1.0'

- name: Install dependencies
run: npm install

- name: Build React app
run: npm run build

- name: Zip build folder and appspec
run: zip -r react-app.zip build appspec.yml scripts/

- name: Upload the ZIP file to S3
run: aws s3 cp react-app.zip s3://matal-s3/
- name: Copy Build files to the production website with AWS CLI
run: |
aws s3 sync --delete $${{.env.DISTt}} s3://${{env.BUCKET}}
- name: Deploy to CodeDeploy
run: |
aws deploy create-deployment \
--application-name matal-codedeploy \
--deployment-group-name matal-codedeploy \
--deployment-config-name CodeDeployDefault.OneAtATime \
--description "Deploying React app from GitHub Actions" \
--file-exists-behavior OVERWRITE \
--s3-location bucket=matal-s3,key=react-app.zip,bundleType=zip
aws cloudfront create-invalidation \
--distribution-id ${{env.DIST_ID}} \
--paths "/*"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# testing
/coverage

# IntelliJ
.idea

# production
/build

Expand Down

0 comments on commit 4b7362f

Please sign in to comment.