-
Notifications
You must be signed in to change notification settings - Fork 57
84 lines (74 loc) · 2.64 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
77
78
79
80
81
82
83
84
name: Zuri calendar Deployment
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- develop
# - master
# pull_request:
# branches:
# - master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
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: calendar_frontend
#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 calendar_frontend
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_company_holiday_calendar
git stash
git fetch --all
git reset --hard origin/develop
git pull origin develop
cd calendar_frontend
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: 'calendar_frontend/build/'
remotePath: 'zc_plugin_company_holiday_calendar/calendar_frontend/build'
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy backend
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd zc_plugin_company_holiday_calendar
source venv/bin/activate
cd calendar_backend
python3 -m pip install -r requirements.txt
python3 manage.py collectstatic --no-input
pkill -u ${{secrets.USERNAME}} gunicorn
gunicorn --bind 0.0.0.0:8000 calendar_backend.wsgi --daemon