Skip to content

Commit

Permalink
Set slack bot token to env var.
Browse files Browse the repository at this point in the history
  • Loading branch information
edganiukov committed May 26, 2023
1 parent c0cfbc9 commit a4d4f4e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/breakpoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
with:
duration: 2m
authorized-users: edganiukov,hugosantos,n-g,htr,nichtverstehen,gmichelo
webhook-definition: ./.github/breakpoint-webhook-definition.json
webhook-definition: ./.github/slack-notification.json
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ This action offers inputs that you can use to configure `breakpoint` behavior:

* `endpoint` - is the quic endpoint of a breakpoint rendezvous server. This is
the required parameter and by default the action will use [Namespace](https://namespace.so)
managed server - `breakpoint.namespace.so:5000`.
managed server - `rendezvous.namespace.so:5000`.

* `duration` - is the initial duration of a breakpoint started by the action.
A duration string is a possibly sequence of decimal numbers a unit suffix,
such as "30s" or "2h5m". Valid time units are "ns", "us", "ms", "s", "m", "h".

The default value is "30m".

* `authorized-users` - is the comma-separated list of GitHub users that would be
Expand All @@ -25,8 +26,16 @@ This action offers inputs that you can use to configure `breakpoint` behavior:
* `webhook-definition` - is the path to a webhook definition file that contains
`url` and `payload` fields. If webhook definition is provided `breakpoint`
will send `POST` request to the provided `url` with the provided `payload`.
Example of such definition file can be found
[here](/.github/breakpoint-webhook-definition.json).

Example of such definition file for sending notifications to Slack can be
found [here](/.github/slack-notification.json).

* `slack-announce-channel` - is a Slack channel where webhook sends and updates
messages about started and currently active breakpoints.

To use this feature necessary to provide `SLACK_BOT_TOKEN` environment
variable. See [here](https://api.slack.com/authentication/token-types) how to
create a bot token.

Note, that `authorized-users` and `authorized-keys` used to provided SSH access
to a GitHub Runner. The action will fail if neither `authorized-users` nor
Expand Down
5 changes: 4 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43092,7 +43092,10 @@ function jsonifyInput() {
}
const slackChannel = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("slack-announce-channel");
if (Boolean(slackChannel)) {
const slackBot = { channel: slackChannel };
const slackBot = {
channel: slackChannel,
token: "${SLACK_BOT_TOKEN}",
};
config.slack_bot = slackBot;
}
return JSON.stringify(config);
Expand Down
6 changes: 5 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Webhook {

class SlackBot {
channel: string;
token: string;
}

async function run(): Promise<void> {
Expand Down Expand Up @@ -159,7 +160,10 @@ function jsonifyInput(): string {

const slackChannel: string = core.getInput("slack-announce-channel");
if (Boolean(slackChannel)) {
const slackBot: SlackBot = { channel: slackChannel };
const slackBot: SlackBot = {
channel: slackChannel,
token: "${SLACK_BOT_TOKEN}",
};
config.slack_bot = slackBot;
}

Expand Down

0 comments on commit a4d4f4e

Please sign in to comment.