{"action":"opened","issue":{"url":"https://api.github.com/repos/deployphp/recipes/issues/150","repository_url":"https://api.github.com/repos/deployphp/recipes","labels_url":"https://api.github.com/repos/deployphp/recipes/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/deployphp/recipes/issues/150/comments","events_url":"https://api.github.com/repos/deployphp/recipes/issues/150/events","html_url":"https://github.com/deployphp/recipes/issues/150","id":265203035,"number":150,"title":"A simpler way for notifying chats?","user":{"login":"Xethron","id":1497338,"avatar_url":"https://avatars1.githubusercontent.com/u/1497338?v=4","gravatar_id":"","url":"https://api.github.com/users/Xethron","html_url":"https://github.com/Xethron","followers_url":"https://api.github.com/users/Xethron/followers","following_url":"https://api.github.com/users/Xethron/following{/other_user}","gists_url":"https://api.github.com/users/Xethron/gists{/gist_id}","starred_url":"https://api.github.com/users/Xethron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xethron/subscriptions","organizations_url":"https://api.github.com/users/Xethron/orgs","repos_url":"https://api.github.com/users/Xethron/repos","events_url":"https://api.github.com/users/Xethron/events{/privacy}","received_events_url":"https://api.github.com/users/Xethron/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-13T08:06:34Z","updated_at":"2017-10-13T08:06:34Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The idea around these recipes is to make tedious tasks easier, and the idea around chat integration is to notify everyone on the team when someone is doing something to production.\r\n\r\nThe 5 steps that should go into a chatroom is: Starting deploy, Successful deploy, Failed deploy, Attempting Rollback, Successful Rollback.\r\n\r\nWe've had a custom setup for notifying Hipchat for the above stages. This was a simple 22 lines of code, everything in the deploy.php file. Now, using the recipe for Hipchat, the simplest solution I could find increases that to 32 lines of code, and that excludes the part doing the notification. This is what I've ended up with:\r\n\r\n```php\r\n// Hipchat\r\nset('hipchat_token', '##########');\r\nset('hipchat_room_id', 'RoomId');\r\nset('hipchat_url', 'https://our.internal.hipchat.url.com/v1/rooms/message');\r\n\r\ntask('hipchat:prepare', function() {\r\n    set('hipchat_color', 'yellow');\r\n    set('hipchat_message', 'STARTING: {{user}} started deploying {{application}} from {{branch}} to {{target}}');\r\n});\r\nbefore('deploy:prepare', 'hipchat:prepare');\r\nafter('hipchat:prepare', 'hipchat:notify');\r\n\r\ntask('hipchat:success', function() {\r\n    set('hipchat_color', 'green');\r\n    set('hipchat_message', 'SUCCESS: {{user}} successfully deployed {{application}} from {{branch}} to {{target}}');\r\n});\r\nafter('success', 'hipchat:success');\r\nafter('hipchat:success', 'hipchat:notify');\r\n\r\ntask('hipchat:fail', function() {\r\n    set('hipchat_color', 'red');\r\n    set('hipchat_message', 'FAILED: {{user}} failed to deploy {{application}} from {{branch}} to {{target}}');\r\n});\r\nafter('deploy:failed', 'hipchat:fail');\r\nafter('hipchat:fail', 'hipchat:notify');\r\n\r\ntask('hipchat:rolling-back', function() {\r\n    set('hipchat_color', 'red');\r\n    set('hipchat_message', 'ROLLING BACK: {{user}} is rolling back {{application}} on {{target}}');\r\n});\r\nbefore('rollback', 'hipchat:rolling-back');\r\nafter('hipchat:rolling-back', 'hipchat:notify');\r\n\r\ntask('hipchat:rolled-back', function() {\r\n    set('hipchat_color', 'purple');\r\n    set('hipchat_message', 'ROLLED BACK: {{user}} successfully rolled back {{application}} on {{target}}');\r\n});\r\nafter('rollback', 'hipchat:rolled-back');\r\nafter('hipchat:rolled-back', 'hipchat:notify');\r\n```\r\n\r\nAm I missing something, or can we work together to find a way to make this simpler?\r\n\r\nA few ideas I had was, allowing to set env vars when calling before/after:\r\n```php\r\nbefore('deploy:prepare', 'hipchat:notify', [\r\n    'hipchat_color' => 'green',\r\n    'hipchat_message' => 'SUCCESS: {{user}} successfully deployed {{application}} from {{branch}} to {{target}}',\r\n]);\r\n```\r\n\r\nAnother idea is to setup these 5 functions in the recipe, with maybe an env var of: `set('hipchat_notify_all');`\r\n\r\nLet me know what you think, will be happy to help implement these."}}
{"actor":{"display_login":"Xethron"}}