-
Notifications
You must be signed in to change notification settings - Fork 56
76 lines (68 loc) · 2.2 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Deploy to server
on:
push:
branches:
- dev
# - main
# pull_request:
# branches:
# - main
jobs:
build:
runs-on: ubuntu-latest
name: yarn build
steps:
- name: Checkout
uses: actions/checkout@v2
# This job is to cache the node modules in order to reduce the time it would take to run
- name: Use cached node_modules
uses: c-hive/gha-yarn-cache@v2
with:
directory: server
#this job installs intalls yarn dependencies on the github runner
#and also to build the static files that would be transferred to server later
- name: install Dependencies
run: |
cd client
export CI=false
yarn install
yarn build
# in the server your normal workflow except omitting yarn build
- name: Git Pull on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd zc_plugin_tools
pwd
git stash
git fetch --all
git reset --hard origin/dev
git pull origin dev
cd server
yarn install
# this job copies the build folder from GitHub runners to the server with sftp, make sure the paths are correct
- name: copy build to server
uses: Creepios/[email protected]
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.HOST }}
password: ${{ secrets.PASSWORD }}
localPath: 'client/build/'
remotePath: 'zc_plugin_tools/client/build'
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd zc_plugin_tools/
pwd
pm2 restart all