-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (38 loc) · 1.33 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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