proposal-chatops
When somebody proposes a deployment, post it to Slack with Approve and Reject buttons. The message shows the instance, the action, the bundle version, who proposed it, and the deployment message.
A click calls approveDeployment or rejectDeployment as the service account. The message then shows the
decision and the Slack user who clicked, for example Approved by @sam in Slack. If the call fails, for example
because the deployment is no longer PROPOSED, only the person who clicked sees the error.
A proposal that is approved or rejected in Massdriver, the CLI, or the API also updates its Slack message, for
example Rejected by Sam Lee in Massdriver, and the buttons go away.
Slack app​
Use the shared Slack app. Turn on interactivity and set its request URL to
https://<host>/slack/interactions. proposal-chatops needs the bot token: a webhook cannot update a message or
receive a click, so SLACK_WEBHOOK_URL does not apply.
Settings​
| Key | Default | |
|---|---|---|
slack.channel | Required. The channel name, such as #deploys, or channel ID for proposals. Invite the app to a private channel. | |
slack.channel_attribute | An instance attribute key. When the instance has this attribute, its value names the channel instead of slack.channel. | |
slack.allowed_users | Slack user IDs that can click the buttons. Empty allows everybody in the channel. |
slack:
channel: "#deploys"
channel_attribute: slack_channel
allowed_users: [U012ABCDEF, U034GHIJKL]
The bundle's Settings params have the same keys as the config file. Channel defaults to #deploys. The full
commented file is
config.example.yaml.
Secrets​
| Variable | |
|---|---|
SLACK_BOT_TOKEN | Required. The xoxb- bot token of the Slack app. |
SLACK_SIGNING_SECRET | Required. The signing secret of the Slack app. Clicks without a valid signature get 401. |
The bundle does not deploy without both. The MASSDRIVER_* variables are in the
common settings.
Permissions​
The service account needs instance:deploy on the instances. Massdriver gates approval and rejection with that
permission. With the bundle, it also needs organization:manageEventDestinations.
If the environment has separation of duty turned on, a proposal that the service account made itself cannot be approved from Slack.
Host​
Set Ingress > Host. On ECS, an empty host uses proposal-chatops.<domain of the cluster's hosted zone>. Both
paths must be public:
/hooks/massdriver, for Massdriver/slack/interactions, for Slack
Event attributes adds an attribute filter to the destination, such as md-environment = prod. Refer to
Deploy for the platform details.
Event destination​
The bundle creates a destination for deployment.proposed, deployment.approved, and deployment.rejected, with
the Event attributes filter and no condition. The automation acts on every event of these types.
To create the destination yourself, with mass 2.6.0 or later:
mass event destination create \
--name proposal-chatops \
--url https://chatops.example.com/hooks/massdriver \
--event-type deployment.proposed \
--event-type deployment.approved \
--event-type deployment.rejected
To post proposals of one environment only, add --attribute md-environment=prod.
Copy the signing secret from the destination's Overview tab into MASSDRIVER_SIGNING_SECRET.
Run​
docker run -p 8080:8080 \
-v "$PWD/config.yaml:/etc/massdriver-automations/config.yaml:ro" \
-e MASSDRIVER_ORGANIZATION_ID=acme \
-e MASSDRIVER_API_KEY=md_... \
-e MASSDRIVER_SIGNING_SECRET=whsec_... \
-e SLACK_BOT_TOKEN=xoxb-... \
-e SLACK_SIGNING_SECRET=... \
ghcr.io/massdriver-cloud/massdriver-automations:0.3 run proposal-chatops
Limits​
- Massdriver records the service account, not the Slack user, as the approver. The V2 API has no field for a
reviewer or a comment on
approveDeploymentorrejectDeployment. The Slack user is in the Slack message and in the log linedeployment decided. - The Slack message of each proposal is remembered in memory for 30 days. After a restart, the buttons on earlier messages still work, but an approval or rejection made in Massdriver does not update an earlier message. Run one replica.
- Massdriver sends events in any order. When the approval or rejection arrives before the proposal, the message is posted already decided, without buttons.
- When Slack refuses a message, the automation responds
500, and Massdriver sends the event again. - Anybody who can click in the channel can approve, unless
slack.allowed_usersis set.