Skip to content

Commit

Permalink
Add slack-announce-channel input parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
edganiukov committed May 26, 2023
1 parent 15b09d3 commit c0cfbc9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 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/actions/breakpoint-webhook-definition.json
webhook-definition: ./.github/breakpoint-webhook-definition.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This action offers inputs that you can use to configure `breakpoint` behavior:
`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/actions/breakpoint-webhook-definition.json).
[here](/.github/breakpoint-webhook-definition.json).

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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
webhook-definition:
description: "The path to a webhook definition file."
required: false
slack-announce-channel:
description: "A slack channel where webhook sends notifications."
required: false
runs:
using: node16
main: dist/main/index.js
7 changes: 7 additions & 0 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42971,6 +42971,8 @@ class WaitConfig {
}
class Webhook {
}
class SlackBot {
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down Expand Up @@ -43088,6 +43090,11 @@ function jsonifyInput() {
const webhookDef = fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync(webhookDefFile, "utf8");
config.webhooks = [JSON.parse(webhookDef)];
}
const slackChannel = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("slack-announce-channel");
if (Boolean(slackChannel)) {
const slackBot = { channel: slackChannel };
config.slack_bot = slackBot;
}
return JSON.stringify(config);
}
function tmpFile(file) {
Expand Down
13 changes: 12 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ class WaitConfig {
authorized_github_users: string[];
shell: string[];
allowed_ssh_users: string[];
webhook: string[];
webhook: Webhook[];
slack_bot: SlackBot;
}

class Webhook {
url: string;
payload: any;
}

class SlackBot {
channel: string;
}

async function run(): Promise<void> {
try {
await core.group(`Install breakpoint CLI`, async () => {
Expand Down Expand Up @@ -152,6 +157,12 @@ function jsonifyInput(): string {
config.webhooks = [JSON.parse(webhookDef)];
}

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

return JSON.stringify(config);
}

Expand Down

0 comments on commit c0cfbc9

Please sign in to comment.