-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (50 loc) · 1.95 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
49
50
51
52
53
54
55
56
name: Code deploy to local server
on:
push:
branches: ['main']
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Step to install dependencies and build your project
- name: Install and Build
run: |
npm install
CI=false npm run build
env:
REACT_APP_GA_TRACKING_ID: ${{ secrets.REACT_APP_GA_TRACKING_ID }}
# Step to clean the target directory on the server
- name: Clean target directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
rm -rf ${{ secrets.SERVER_PATH }}/nginx/build
# Step to copy the build directory to the server
- name: Copy build directory to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: './build/'
target: '${{ secrets.SERVER_PATH }}/nginx/'
# Step to restart the server using SSH
- name: Restart server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd ${{ secrets.SERVER_PATH }}
docker-compose down
git pull origin master
docker-compose up --build -d