-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuddy.yml
192 lines (192 loc) · 7.34 KB
/
buddy.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
- pipeline: "saltedherring.design SilverStripe"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "master"
ref_type: "BRANCH"
target_site_url: "https://api.saltedherring.design/"
trigger_condition: "ALWAYS"
actions:
- action: "Execute: archive site"
type: "BUILD"
working_directory: "/buddy/saltedherring.design"
docker_image_name: "simonwinter/silverstripe_lamp_nz"
docker_image_tag: "4.0"
execute_commands:
- "if [ ! -d ./archives ]"
- "then"
- "\tmkdir ./archives"
- "fi"
- "if [ -d /buddy/saltedherring.design/vendor/silverstripe/graphql ]"
- "then"
- "\trm -rf /buddy/saltedherring.design/vendor/silverstripe/graphql"
- "fi"
- "composer update --optimize-autoloader"
- "# once composer update is complete, we need to overwrite the existing GrpahlQL controller:"
- "if [ -f ./vendor/silverstripe/graphql/src/Controller.php ]"
- "then"
- "\tcp -rfp ./overwrites/Controller.php ./vendor/silverstripe/graphql/src/Controller.php"
- "fi"
- "# remove oldest archive if we have more than 6"
- "count=$(ls -1tr ./archives | wc -l)"
- "if [ $count \\> 6 ] "
- "then"
- "\toldest=$(ls -1tr archives | head -n 1)"
- "\tif [ -f ./archives/$oldest ]"
- "\tthen"
- "\t\trm ./archives/$oldest"
- "\tfi"
- "fi"
- "# archive the site"
- "tar --exclude=archives --exclude=.git* --exclude=.env* --exclude=editorconfig -zvcf archives/deployment-${execution.id}.tgz ."
mount_filesystem_path: "/buddy/saltedherring.design"
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "Rsync to 120.138.18.50"
type: "RSYNC"
local_path: "archives/"
remote_path: "~/container/application/archives"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
archive: true
delete_extra_files: true
compress: true
deployment_excludes:
- "/.git/"
trigger_condition: "ALWAYS"
- action: "[120.138.18.50] Execute: unarchive latest"
type: "SSH_COMMAND"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
commands:
- "cd ~/container/application"
- "latest=$(ls -1t archives | head -n 1)"
- "if [ ! -d release ]"
- "then"
- "\tmkdir release"
- "else"
- "\trm -rf release"
- "\tmkdir release"
- "fi"
- "tar -xzvf archives/$latest -C ~/container/application/release"
run_as_script: true
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "[120.138.18.50] Execute: symlink internal folders"
type: "SSH_COMMAND"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
commands:
- "if [ ! -d ~/container/application/release ]"
- "then"
- "\texit 0"
- "fi"
- "cd ~/container/application/release/public"
- "if [ -d ./assets ]"
- "then"
- "\trm -rf ./assets"
- "fi"
- "ln -snf /var/www/html/shared/assets"
- "ln -snf /var/www/html/shared/silverstripe-cache"
- "cd ~/container/application/release"
- "ln -snf /var/www/html/shared/robots.txt"
- "ln -snf /var/www/html/shared/.env"
- "cd ~/container/application/release/app/_config"
- "ln -snf /var/www/html/shared/_config/live.yml"
- "#ln -snf /var/www/html/shared/silverstripe.log"
- "# cd ~/container/application/release/app/_config/"
- "# ln -snf /var/www/html/shared/_config/images.yml"
- "# if [ -f ~/container/application/release/app/_config/search-server.yml ]"
- "# then"
- "# \trm -f ~/container/application/release/app/_config/search-server.yml"
- "# fi"
- "# ln -snf /var/www/html/shared/_config/search-server.yml"
- "# ln -snf /var/www/html/shared/_config/live-site.yml"
run_as_script: true
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "[120.138.18.50] Execute: sake dev/build flush=all"
type: "SSH_COMMAND"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
commands:
- "if [ ! -d ~/container/application/release ]"
- "then"
- "\texit 0"
- "fi"
- "cd ~/container/application/release"
- "composer update --optimize-autoloader"
- "php vendor/silverstripe/framework/cli-script.php dev/build flush=all"
run_as_script: true
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "[120.138.18.50] Execute: move release"
type: "SSH_COMMAND"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
commands:
- "if [ ! -d ~/container/application/release ]"
- "then"
- "\texit 0"
- "fi"
- "cd ~/container/application"
- "mv release releases/${execution.id}"
- "rm -rf public"
- "ln -s releases/${execution.id} public"
run_as_script: true
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "Execute: clean up"
type: "SSH_COMMAND"
login: "saltydesign"
host: "120.138.18.50"
port: "22"
env_key: "secure!lC7WtI31Zd39h8CmPk8NbQ=="
authentication_mode: "ENV_KEY"
commands:
- "# remove old releases - i.e. more than 6."
- "cd ~/container/application"
- "count=$(ls -1tr ~/container/application/releases | wc -l)"
- "if [ $count \\> 6 ] "
- "then"
- "\toldest=$(ls -1tr ~/container/application/releases | head -n 1)"
- "\tif [ -d ~/container/application/releases/$oldest ]"
- "\tthen"
- "\t\trm -rf ~/container/application/releases/$oldest"
- "\tfi"
- "fi"
run_as_script: true
shell: "BASH"
trigger_condition: "ALWAYS"
- action: "Send notification to buddy channel"
type: "SLACK"
content: "[#$BUDDY_EXECUTION_ID] $BUDDY_PIPELINE_NAME execution by <$BUDDY_INVOKER_URL|$BUDDY_INVOKER_NAME>"
channel: "G5M1EEKFX"
channel_name: "buddy"
attachments:
- "{\"fallback\":\"$BUDDY_PIPELINE_NAME execution #$BUDDY_EXECUTION_ID\",\"color\":\"good\",\"fields\":[{\"title\":\"Successful execution\",\"value\":\"<$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\",\"short\":true},{\"title\":\"Pipeline\",\"value\":\"<$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\",\"short\":true},{\"title\":\"Branch\",\"value\":\"$BUDDY_EXECUTION_BRANCH\",\"short\":true},{\"title\":\"Project\",\"value\":\"<$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\",\"short\":true}]}"
trigger_condition: "ALWAYS"
integration_id: 2
- action: "Send notification to buddy channel"
type: "SLACK"
trigger_time: "ON_FAILURE"
content: "[#$BUDDY_EXECUTION_ID] $BUDDY_PIPELINE_NAME execution by <$BUDDY_INVOKER_URL|$BUDDY_INVOKER_NAME>"
channel: "G5M1EEKFX"
channel_name: "buddy"
attachments:
- "{\"fallback\":\"$BUDDY_PIPELINE_NAME execution #$BUDDY_EXECUTION_ID\",\"color\":\"danger\",\"fields\":[{\"title\":\"Failed execution\",\"value\":\"<$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\",\"short\":true},{\"title\":\"Pipeline\",\"value\":\"<$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\",\"short\":true},{\"title\":\"Branch\",\"value\":\"$BUDDY_EXECUTION_BRANCH\",\"short\":true},{\"title\":\"Project\",\"value\":\"<$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\",\"short\":true}]}"
trigger_condition: "ALWAYS"
integration_id: 2