-
Notifications
You must be signed in to change notification settings - Fork 4
47 lines (40 loc) ยท 1.12 KB
/
deploy-frontend.yml
File metadata and controls
47 lines (40 loc) ยท 1.12 KB
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 React Frontend to EC2
on:
push:
branches: [ "develop" ]
paths:
- 'frontend/**'
- '.github/workflows/deploy-frontend.yml'
pull_request:
branches: [ "develop" ]
paths:
- 'frontend/**'
- '.github/workflows/deploy-frontend.yml'
jobs:
deploy-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build React
run: |
cd frontend
npm ci
npm run build
- name: Upload build to EC2
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
source: frontend/build/**
target: /home/ubuntu/deploy-temp/frontend
- name: Deploy on EC2
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
rm -rf /home/ubuntu/frontend/build
mv /home/ubuntu/deploy-temp/frontend /home/ubuntu/frontend/build