-
Notifications
You must be signed in to change notification settings - Fork 68
/
fabfile.py
58 lines (46 loc) · 1.37 KB
/
fabfile.py
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
# -*- coding: utf-8 -*-
from fabric.api import hosts
from fabric.context_managers import cd
from fabric.operations import local, put, run
def deploy(build, project_root):
if build == 'prod':
local('npm run build')
elif build == 'staging':
local('npm run build-staging')
else:
print("Please deploy in specific mode like staging or production.")
return
with cd(project_root):
run('mkdir deploy', quiet=True)
put('dist', 'deploy')
run('rm -rf dist_bak')
run('mv dist dist_bak', quiet=True)
run('rm -rf dist')
run('mv deploy/dist dist')
run('rm -rf deploy')
@hosts('[email protected]:29179')
def deploy_prod(build='prod'):
"""部署到生产环境
# 发布前编译
fab deploy_prod:build=prod
fab deploy_prod:prod
fab deploy_prod
# 不编译
fab deploy_prod:build=no
fab deploy_prod:no
"""
project_root = '/data/www/vue-admin-vuetify/'
deploy(build, project_root)
@hosts('[email protected]:29179')
def deploy_staging(build='staging'):
"""部署到 staging 环境
# 发布前编译
fab deploy_staging:build=staging
fab deploy_staging:staging
fab deploy_staging
# 不编译
fab deploy_staging:build=no
fab deploy_staging:no
"""
project_root = '/data/www/vue-admin-vuetify/'
deploy(build, project_root)