-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·102 lines (69 loc) · 2.4 KB
/
deploy.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
set -x -e
destination_root="www"
local_part="z03-db"
create_switch_page=""
if [ "X${local_part}" != "X" ]; then
destination_dir="${destination_root}/${local_part}"
create_switch_page="1"
else
destination_dir="${destination_root}"
fi
suffix=""
dont_push=""
while [ "$#" -gt "0" ]; do
if [ "$1" == "test" ]; then
suffix="-test"
fi
if [ "$1" == "--dont-push" ]; then
dont_push="1"
fi
shift
done
git checkout deploy
git pull
master_version_file=master-version${suffix}
touch ${master_version_file}
new_master=$(git rev-parse master)
current_master=$(cat ${master_version_file})
if [ "${new_master}" == "${current_master}" ]; then
echo "latest master version already deployed"
git checkout master
exit 0
fi
echo "${new_master}" > ${master_version_file}
git add ${master_version_file}
# Generate favicon.ico
git cat-file blob master:images/favicon.ico >"${destination_root}/favicon.ico"
git add "${destination_root}/favicon.ico"
# Generate document root
html_file=index${suffix}.html
mkdir -p "${destination_dir}"
mkdir -p "${destination_dir}/images"
git cat-file blob master:entry.html >"${destination_dir}/${html_file}"
git cat-file blob master:images/logo-moto-crc-1451.png >"${destination_dir}/images/logo-moto-crc-1451.png"
git add "${destination_dir}/${html_file}"
git add "${destination_dir}/images/logo-moto-crc-1451.png"
# General image directory in destination root (this is currently used by jinja-generated result pages)
mkdir -p "${destination_root}/images"
git cat-file blob master:images/logo-moto-crc-1451.png >"${destination_root}/images/logo-moto-crc-1451.png"
git add "${destination_root}/images/logo-moto-crc-1451.png"
# Generate switch page if necessary
if [ "X${create_switch_page}" != "X" ]; then
git cat-file blob master:switch.html >"${destination_root}/index.html"
git add "${destination_root}/index.html"
fi
# Generate WSGI directory
mkdir -p wsgi-scripts
git cat-file blob master:server/store_data.py >wsgi-scripts/store_data.wsgi
git add wsgi-scripts
git add wsgi-scripts/store_data.wsgi
mkdir -p "${destination_root}/templates"
git cat-file blob master:templates/success.html.jinja2 >"${destination_root}/templates/success.html.jinja2"
git add "${destination_root}/templates"
git add "${destination_root}/templates/success.html.jinja2"
git commit -m "pre-deploy${suffix} commit "
if [ "X${dont_push}" == "X" ]; then
git push
fi
git checkout master