2017 © Pedro Peláez
 

project platformsh2slack

Platform.sh -> Slack incoming webhook adapter.

image

hanoii/platformsh2slack

Platform.sh -> Slack incoming webhook adapter.

  • Wednesday, October 11, 2017
  • by hanoii
  • Repository
  • 4 Watchers
  • 14 Stars
  • 3,743 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 17 Versions
  • 17 % Grown

The README.md

Platform.sh -> Slack incoming webhook adapter

This is a simple php script that translates Platform.sh webhook into a Slack formatted message., (*1)

You can install this in your php app container and host it there for your project's specific webhooks., (*2)

Sponsored by Infomagnet - builds websites to any design using Drupal., (*3)

slack-example, (*4)

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:, (*5)

composer require hanoii/platformsh2slack

Then create an incoming webhook on your Slack account for the package to use. You'll need the webhook URL to instantiate the adapter., (*6)

Basic Usage

<?php

// Optional settings
$settings = [
  'channel' => '#random',
  'project' => 'Some project',
  // Environment will be appended to the URL
  'project_url' => 'https://console.platform.sh/USER/PROJECTID',
];

$platformsh2slack = new Hanoii\Platformsh2Slack\Platformsh2Slack(
  'https://hooks.slack.com/...',
  $settings
);

// Optionally protect the request with a token that has to be present in the Platform.sh webhook
$platformsh2slack->validateToken('1234');

// Send the information to slack
$platformsh2slack->send();

Platform.sh build hook

If your application (.platform.app.yaml) is already being built with composer:, (*7)

build:
    flavor: composer

You can simply add:, (*8)

    "hanoii/platformsh2slack": "^1.0"

To your composer.json file of the project and create a small script as per above., (*9)

If not, you will have to add a script to the repository and run composer install on your build hook manually., (*10)

Settings

Option Type Default Description
channel string null The default channel that messages will be sent to, otherwise defaults to what's set on the Slack's incoming webhook
commit_limit int 10 The number of commits from the payload to include in the Slack message
routes bool false Whether to show project's routes on every slack message. If false, it will be shown only when you branch.
redirects bool false Whether to include project's redirects with routes on every Slack message. If false, redirects will be shown only when you branch.
basic_auth bool false Whether to show project environment's HTTP Authentication username and password in Slack message. WARNING: If true, potentially sensitive data passwords will be sent in the clear to your Slack channel.
configurations bool false Whether to show project's configurations on every slack message. If false, it will be shown only for master when you push, merge or have a subscription plan update.
attachment_color string '#e8e8e8' RGB color for Slack attachment.
project string null If present, it will be used as the project name instead of the default string. Project name is misisng in Platform.sh's payload.
project_url string null If present, the project name will be used as a link to this URL on Slack notifications. Environment branch will be appended automatically to the URL.
debug string null An optional path where posssible unhandled webhooks JSON can be saved. This is useful if you want to send over the json for me to add support for it.
debug_all boolean false If debug is set, it saves the JSON of every webhook sent, not only the unhandled ones.
active boolean false If active is set, only webhooks of active environments will be sent to platform. Useful for some external integrations.

Token

This is an optional feature you can choose to use on the script. It's a nice simple validation so that you script is not abused., (*11)

If you added:, (*12)

$platformsh2slack->validateToken('1234');

to your script, you will have to append the token the Platform.sh's webhook integration URL., (*13)

Add the integration on platform

Run the following:, (*14)

platform integration:add --type=webhook --url="https://www.example.com/platformsh2slack.php?token=TOKEN"

Environoments

You can have this script on any environment, even master. As far as my trials went, even pushing to master works., (*15)

The Versions

11/10 2017

dev-master

9999999-dev

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

11/10 2017

1.4

1.4.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

16/06 2017

1.3

1.3.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

29/04 2017

1.2

1.2.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

27/04 2017

1.1

1.1.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

27/04 2017

1.0

1.0.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Ariel Barreiro

slack platformsh

04/04 2017

v0.6.5

0.6.5.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

The Requires

 

28/03 2017

v0.6

0.6.0.0

Platform.sh -> Slack incoming webhook adapter.

  Sources   Download

The Requires

 

23/02 2017

v0.5

0.5.0.0

  Sources   Download

The Requires

 

16/01 2017

v0.4.5

0.4.5.0

  Sources   Download

The Requires

 

16/01 2017

v0.4.1

0.4.1.0

  Sources   Download

The Requires

 

07/10 2016

v0.4

0.4.0.0

  Sources   Download

The Requires

 

05/10 2016

v0.3.2

0.3.2.0

  Sources   Download

The Requires

 

01/10 2016

v0.3.1

0.3.1.0

  Sources   Download

The Requires

 

01/10 2016

v0.3

0.3.0.0

  Sources   Download

The Requires

 

01/10 2016

v0.2

0.2.0.0

  Sources   Download

The Requires

 

30/09 2016

v0.1

0.1.0.0

  Sources   Download

The Requires