This repository was archived by the owner on Apr 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,14 @@ require 'vendor/deployphp/recipes/recipes/slack.php';
14
14
15
15
You can provide also other configuration options:
16
16
17
- - * message* - default is ** Deployment to '{$host}' on * {$prod}* was successful\n({$releasePath})**
17
+ - * message* - default is ** Deployment to ` {{host}} ` on * {{stage}}* was successful\n({{release_path}})**
18
+ - the available placeholders for the message parameter are:
19
+ - {{release_path}}
20
+ - {{host}}
21
+ - {{stage}}
22
+ - {{user}}
23
+ - {{branch}}
24
+ - {{app_name}}
18
25
- * channel* - default is ** #general**
19
26
- * icon* - default is ** :sunny : **
20
27
- * username* - default is ** Deploy**
@@ -26,6 +33,7 @@ You can provide also other configuration options:
26
33
set('slack', [
27
34
'token' => 'xoxp-...',
28
35
'team' => 'team name',
36
+ 'app' => 'app name',
29
37
]);
30
38
```
31
39
Original file line number Diff line number Diff line change 14
14
$ config = get ('slack ' , []);
15
15
16
16
if (!isset ($ config ['message ' ])) {
17
- $ releasePath = env ('release_path ' );
18
- $ host = env ('server.host ' );
19
- $ stage = env ('stages ' )[0 ];
20
- $ config ['message ' ] = "Deployment to ' {$ host }' on * {$ stage }* was successful \n( $ releasePath) " ;
17
+ $ config ['message ' ] = "Deployment to `{{host}}` on *{{stage}}* was successful \n({{release_path}}) " ;
21
18
}
22
19
20
+ $ server = \Deployer \Task \Context::get ()->getServer ()->getConfiguration ();
21
+ $ host = $ server ->getHost ();
22
+ $ user = !$ server ->getUser () ? null : $ server ->getUser ();
23
+ $ messagePlaceHolders = [
24
+ '{{release_path}} ' => env ('release_path ' ),
25
+ '{{host}} ' => env ('server.host ' ),
26
+ '{{stage}} ' => env ('stages ' )[0 ],
27
+ '{{user}} ' => $ user ,
28
+ '{{branch}} ' => env ('branch ' ),
29
+ '{{app_name}} ' => isset ($ config ['app ' ]) ? ['app ' ] : 'app-name ' ,
30
+ ];
31
+ $ config ['message ' ] = strtr ($ config ['message ' ], $ messagePlaceHolders );
32
+
23
33
$ defaultConfig = [
24
34
'channel ' => '#general ' ,
25
35
'icon ' => ':sunny: ' ,
26
36
'username ' => 'Deploy ' ,
37
+ 'message ' => "Deployment to `{{host}}` on *{{stage}}* was successful \n({{release_path}}) " ,
27
38
];
28
39
29
40
$ config = array_merge ($ defaultConfig , $ config );
50
61
}
51
62
52
63
$ url = 'https://slack.com/api/chat.postMessage? ' . http_build_query ($ urlParams );
53
-
54
64
$ result = @file_get_contents ($ url );
55
65
56
66
if (!$ result ) {
You can’t perform that action at this time.
0 commit comments