Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into midweste
Browse files Browse the repository at this point in the history
* origin/master: (23 commits)
  Magento 2: Only set maintenance mode once if needed (deployphp#3469)
  Adds Comments to magento2 recipe and modifies DocGen, to be able to explain artifact deployment (deployphp#3510)
  Added missing deploy task to recipe/common (deployphp#3526)
  Added support for ntfy.sh notifications, contrib/ntfy (deployphp#3522)
  Teams, Telegram, Slack contrib recipe no longer fails silently if no webhook is configured (deployphp#3523)
  [automatic] Update docs with bin/docgen
  Contrib supervisord monitor (deployphp#3486)
  Doc update about new default value of writable_recursive (deployphp#3521)
  Added a note about missing ssh-option. Fixes issue deployphp/deployer… (deployphp#3520)
  Fix branch deploy for clone strategy
  Shopware Flex has no `build.sh` anymore (deployphp#3513)
  Fixed bin/console calls in shopware recipe (deployphp#3512)
  fix typo in magento recipe (deployphp#3498)
  Add PUT to Httpie.php (deployphp#3497)
  Add remote option to update_code_strategy to rename remote to repository (deployphp#3466)
  Prevent type errors when supplied timeout options are not numeric (deployphp#3484)
  Magento: allow subdirectory and create variable for bin/magento (deployphp#3460)
  docs(github-action): improve & update (deployphp#3482)
  docs(selector): correct env config option to array (deployphp#3481)
  Fixes deployphp#3472 (deployphp#3473)
  ...
  • Loading branch information
midwestE authored and midwestE committed Mar 7, 2023
2 parents f37c72d + f9b5c1e commit 8bfa895
Show file tree
Hide file tree
Showing 26 changed files with 1,304 additions and 267 deletions.
5 changes: 4 additions & 1 deletion contrib/ms-teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
2. Navigate to Teams section
3. Select existing or create new team
4. Select existing or create new channel
5. Hover over channel to get tree dots, click, in menu select "Connectors"
5. Hover over channel to get three dots, click, in menu select "Connectors"
6. Search for and configure "Incoming Webhook"
7. Confirm/create and copy your Webhook URL
8. Setup deploy.php
Expand Down Expand Up @@ -92,6 +92,7 @@
desc('Notifies Teams');
task('teams:notify', function () {
if (!get('teams_webhook', false)) {
warning('No MS Teams webhook configured');
return;
}

Expand All @@ -106,6 +107,7 @@
desc('Notifies Teams about deploy finish');
task('teams:notify:success', function () {
if (!get('teams_webhook', false)) {
warning('No MS Teams webhook configured');
return;
}

Expand All @@ -120,6 +122,7 @@
desc('Notifies Teams about deploy failure');
task('teams:notify:failure', function () {
if (!get('teams_webhook', false)) {
warning('No MS Teams webhook configured');
return;
}

Expand Down
158 changes: 158 additions & 0 deletions contrib/ntfy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php
/*
## Installing
Require ntfy.sh recipe in your `deploy.php` file:
Setup:
1. Setup deploy.php
Add in header:
```php
require 'contrib/ntfy.php';
set('ntfy_topic', 'ntfy.sh/mytopic');
```
Add in content:
```php
before('deploy', 'ntfy:notify');
after('deploy:success', 'ntfy:notify:success');
after('deploy:failed', 'ntfy:notify:failure');
```
9.) Sip your coffee
## Configuration
- `ntfy_server` – ntfy server url, default `ntfy.sh`
```
set('ntfy_server', 'ntfy.sh');
```
- `ntfy_topic` – ntfy topic, **required**
```
set('ntfy_topic', 'mysecrettopic');
```
- `ntfy_title` – the title of the message, default `{{application}}`
- `ntfy_text` – notification message template
```
set('ntfy_text', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
```
- `ntfy_tags` – notification message tags / emojis (comma separated)
```
set('ntfy_tags', `information_source`);
```
- `ntfy_priority` – notification message priority (integer)
```
set('ntfy_priority', 5);
```
- `ntfy_success_text` – success template, default:
```
set('ntfy_success_text', 'Deploy to *{{target}}* successful');
```
- `ntfy_success_tags` – success tags / emojis (comma separated)
```
set('ntfy_success_tags', `white_check_mark,champagne`);
```
- `ntfy_success_priority` – success notification message priority
- `ntfy_failure_text` – failure template, default:
```
set('ntfy_failure_text', 'Deploy to *{{target}}* failed');
```
- `ntfy_failure_tags` – failure tags / emojis (comma separated)
```
set('ntfy_failure_tags', `warning,skull`);
```
- `ntfy_failure_priority` – failure notification message priority
## Usage
If you want to notify only about beginning of deployment add this line only:
```php
before('deploy', 'ntfy:notify');
```
If you want to notify about successful end of deployment add this too:
```php
after('deploy:success', 'ntfy:notify:success');
```
If you want to notify about failed deployment add this too:
```php
after('deploy:failed', 'ntfy:notify:failure');
```
*/
namespace Deployer;

use Deployer\Utility\Httpie;

set('ntfy_server', 'ntfy.sh');

// Title of project
set('ntfy_title', function () {
return get('application', 'Project');
});

// Deploy message
set('ntfy_text', '_{{user}}_ deploying `{{branch}}` to *{{target}}*');
set('ntfy_success_text', 'Deploy to *{{target}}* successful');
set('ntfy_failure_text', 'Deploy to *{{target}}* failed');

// Message tags
set('ntfy_tags', '');
set('ntfy_success_tags', '');
set('ntfy_failure_tags', '');

desc('Notifies ntfy server');
task('ntfy:notify', function () {
if (!get('ntfy_topic', false)) {
warning('No ntfy topic configured');
return;
}

Httpie::post(get('ntfy_server'))->jsonBody([
"topic" => get('ntfy_topic'),
"title" => get('ntfy_title'),
"message" => get('ntfy_text'),
"tags" => explode(",", get('ntfy_tags')),
"priority" => get('ntfy_priority'),
])->send();
})
->once()
->hidden();

desc('Notifies ntfy server about deploy finish');
task('ntfy:notify:success', function () {
if (!get('ntfy_topic', false)) {
warning('No ntfy topic configured');
return;
}

Httpie::post(get('ntfy_server'))->jsonBody([
"topic" => get('ntfy_topic'),
"title" => get('ntfy_title'),
"message" => get('ntfy_success_text'),
"tags" => explode(",", get('ntfy_success_tags')),
"priority" => get('ntfy_success_priority'),
])->send();
})
->once()
->hidden();

desc('Notifies ntfy server about deploy failure');
task('ntfy:notify:failure', function () {
if (!get('ntfy_topic', false)) {
warning('No ntfy topic configured');
return;
}

Httpie::post(get('ntfy_server'))->jsonBody([
"topic" => get('ntfy_topic'),
"title" => get('ntfy_title'),
"message" => get('ntfy_failure_text'),
"tags" => explode(",", get('ntfy_failure_tags')),
"priority" => get('ntfy_failure_priority'),
])->send();
})
->once()
->hidden();
4 changes: 4 additions & 0 deletions contrib/slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function checkSlackAnswer($result)
desc('Notifies Slack');
task('slack:notify', function () {
if (!get('slack_webhook', false)) {
warning('No Slack webhook configured');
return;
}

Expand All @@ -117,6 +118,7 @@ function checkSlackAnswer($result)
desc('Notifies Slack about deploy finish');
task('slack:notify:success', function () {
if (!get('slack_webhook', false)) {
warning('No Slack webhook configured');
return;
}

Expand All @@ -137,6 +139,7 @@ function checkSlackAnswer($result)
desc('Notifies Slack about deploy failure');
task('slack:notify:failure', function () {
if (!get('slack_webhook', false)) {
warning('No Slack webhook configured');
return;
}

Expand All @@ -156,6 +159,7 @@ function checkSlackAnswer($result)
desc('Notifies Slack about rollback');
task('slack:notify:rollback', function () {
if (!get('slack_webhook', false)) {
warning('No Slack webhook configured');
return;
}

Expand Down
Loading

0 comments on commit 8bfa895

Please sign in to comment.