Skip to content

Commit

Permalink
Merge pull request #12 from delicious-algorithme/dev
Browse files Browse the repository at this point in the history
ci-cd 구축, dev merge to main
  • Loading branch information
Songhyejeong authored Aug 18, 2024
2 parents 4669433 + 6e60a4d commit d4d6554
Show file tree
Hide file tree
Showing 4 changed files with 18,865 additions and 18,805 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy React to EC2 using S3 and CodeDeploy

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

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

- 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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '21.1.0' # Node.js 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: 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
10 changes: 10 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 0.0
os: linux
files:
- source: /
destination: /home
hooks:
AfterInstall:
- location: scripts/restart_nginx.sh
timeout: 60
runas: root
Loading

0 comments on commit d4d6554

Please sign in to comment.