-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (37 loc) · 1.22 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
name: Deploy Chit Chat to EC2
on:
push:
branches:
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code từ GitHub repo
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Cài đặt Node.js để build ứng dụng
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
# Step 3: Cài đặt Yarn
- name: Install Yarn
run: npm install -g yarn
# Step 4: Cài đặt các dependencies
- name: Install dependencies
run: yarn install
# Step 5: Build ứng dụng React
- name: Build the app
run: yarn build
# # Step 6: Thiết lập SSH để kết nối đến EC2
# - name: Add SSH key
# uses: webfactory/ssh-agent@v0.5.3
# with:
# ssh-private-key: ${{ secrets.EC2_SSH_KEY }}
# # Step 7: Copy build files lên EC2
# - name: Copy files via SCP
# run: scp -r ./build/* ec2-user@your-ec2-public-ip:/var/www/html
# # Step 8: SSH vào EC2 để khởi động lại Nginx (nếu cần)
# - name: Restart Nginx
# run: ssh ec2-user@your-ec2-public-ip 'sudo systemctl restart nginx'