hanoii / platformsh2slack
Platform.sh -> Slack 入站 webhook 适配器。
1.9
2022-06-05 03:29 UTC
Requires
- maknz/slack: ^1.7
- symfony/http-foundation: ^2 || ^3 || ^4
README
这是一个简单的 PHP 脚本,可以将 Platform.sh webhook 转换为 Slack 格式的消息。
您可以将此脚本安装到您的 PHP 应用容器中,并在那里托管您的项目特定 webhook。
由 Infomagnet - 使用 Drupal 构建任何设计的网站 赞助。
安装
您可以使用 Composer 包管理器安装此包。您可以在项目根目录中运行以下命令进行安装
composer require hanoii/platformsh2slack
然后,在您的 Slack 账户上为该包创建一个入站 webhook,以供适配器使用。您将需要 webhook URL 来实例化适配器。
基本用法
<?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 构建 hook
如果您的应用程序 (.platform.app.yaml
) 已经使用 composer 构建
build: flavor: composer
您只需将以下内容添加到您的项目 composer.json
文件中,并创建一个小脚本,如下所示。
"hanoii/platformsh2slack": "^1.0"
To your composer.json
file of the project and create a small script as per above.
如果没有,您将需要将脚本添加到存储库,并在构建 hook 上手动运行 composer install。
设置
令牌
这是一个可选功能,您可以选择在脚本中使用。这是一个简单的验证,以确保您的脚本不会被滥用。
如果您在脚本中添加了
$platformsh2slack->validateToken('1234');
您将需要在 Platform.sh 的 webhook 集成 URL 上附加令牌。
在平台上添加集成
运行以下操作
platform integration:add --type=webhook --url="https://www.example.com/platformsh2slack.php?token=TOKEN"
环境
您可以将此脚本放在任何环境中,甚至 master。根据我的试验,即使推送至 master 也是可行的。