-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
executable file
·78 lines (61 loc) · 1.56 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import os
from fabric.contrib.project import rsync_project
from fabric.api import env, put, local, task, hosts, sudo
import yaml
env.user = 'deploy'
env.hosts = ['penguin.gtalug.org']
env.remote_dir = '/srv/www/org_gtalug_board/html/'
env.use_ssh_config = True
with open('_config.yml') as f:
env.config = yaml.load(f)
@task
@hosts('localhost')
def run():
"""
Run the development web server so you could view your changes.
"""
jekyll('serve --watch')
@task
@hosts('localhost')
def build():
"""
This will build the website.
"""
clean()
jekyll('build')
@task
@hosts('penguin.gtalug.org')
def deploy():
"""
This will deploy the web site to the GTALUG web space.
"""
build()
rsync_project(
local_dir=os.path.abspath(env.config['destination']) + "/",
remote_dir=env.remote_dir,
delete=True,
extra_opts='--exclude=".DS_Store"',
)
@task
@hosts('penguin.gtalug.org')
def update_nginx_config():
"""
This will update the Nginx configuration file on the remote host.
"""
put(
local_path=os.path.join(os.path.abspath('./_etc'), 'nginx.conf'),
remote_path='/etc/nginx/sites-available/org_gtalug_board',
use_sudo=True
)
sudo('/etc/init.d/nginx restart')
def jekyll(directives=''):
"""
A simple wrapper around the jekyll command.
"""
local('bundle exec jekyll %s' % directives)
def clean():
"""
This will clean the site directory.
"""
local('rm -fr %s' % os.path.abspath(env.config['destination']))