diff --git a/.github/actions/breakpoint-webhook-definition.json b/.github/breakpoint-webhook-definition.json similarity index 100% rename from .github/actions/breakpoint-webhook-definition.json rename to .github/breakpoint-webhook-definition.json diff --git a/.github/workflows/breakpoint.yaml b/.github/workflows/breakpoint.yaml index ce28e4a..7e26b5b 100644 --- a/.github/workflows/breakpoint.yaml +++ b/.github/workflows/breakpoint.yaml @@ -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 diff --git a/README.md b/README.md index f4e8b5b..56e6efb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index b59faa7..47195bb 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/main/index.js b/dist/main/index.js index 209bdb0..6e6041b 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -42971,6 +42971,8 @@ class WaitConfig { } class Webhook { } +class SlackBot { +} function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -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) { diff --git a/main.ts b/main.ts index ae020b8..aa89450 100644 --- a/main.ts +++ b/main.ts @@ -12,7 +12,8 @@ class WaitConfig { authorized_github_users: string[]; shell: string[]; allowed_ssh_users: string[]; - webhook: string[]; + webhook: Webhook[]; + slack_bot: SlackBot; } class Webhook { @@ -20,6 +21,10 @@ class Webhook { payload: any; } +class SlackBot { + channel: string; +} + async function run(): Promise { try { await core.group(`Install breakpoint CLI`, async () => { @@ -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); }