diff --git a/packages/keybase-notifications/README.md b/packages/keybase-notifications/README.md index 2e29ee04..a03dde77 100644 --- a/packages/keybase-notifications/README.md +++ b/packages/keybase-notifications/README.md @@ -1,6 +1,6 @@ # Keybase Build Notifications -This action allows you to post GitHub build notifications to [Keybase Chat](https://keybase.io/blog/keybase-chat) channels, teams, and DMs. It sends messages via the [opensentinel API](https://keybase.io/sentinelbot), using your `owner` and `token` values. +This action allows you to post GitHub build notifications to [Keybase Chat](https://keybase.io/blog/keybase-chat) channels, teams, and DMs. It sends messages via the [opensentinel API](https://www.opensentinel.com), using your `token` value. ![Keybase default GitHub notification](images/keybase-gh-notification-example.png) @@ -18,12 +18,12 @@ This action allows you to post GitHub build notifications to [Keybase Chat](http ## Using the Action -You will need an opensentinel API token in order to use this action. Go through the [@sentinelbot](https://keybase.io/sentinelbot) setup flow for a **Generic Webhook** and make a note of the `owner` and `token` values in the URL you receive. +You will need an opensentinel automation API token in order to use this action. Create an account and go through the [Keybase setup information](https://www.opensentinel.com/docs/integrations/keybase). This action utilizes a **Generic Webhook** token. -As a reference, `@sentinelbot` Webhook URLs for Keybase will look something like: +For reference, opensentinel automation wbhook URLs for Keybase look something like: ```text -https://api.opensentinel.com/kb/webhooks?owner=&token= +https://automations.opensentinel.com/webhook?token= ``` ### Build notifications for CI Tests @@ -48,7 +48,6 @@ jobs: if: always() with: job_status: ${{ job.status }} - opensentinel_owner: ${{ secrets.OSL_OWNER }} opensentinel_token: ${{ secrets.OSL_TOKEN }} on_success: "never" on_failure: "always" @@ -82,7 +81,6 @@ jobs: with: job_status: ${{ job.status }} job_name: "Production Release" - opensentinel_owner: ${{ secrets.OSL_OWNER }} opensentinel_token: ${{ secrets.OSL_TOKEN }} ``` @@ -92,7 +90,6 @@ This will send you a notification message to let you know if the production rele | Parameter | Description | Default | | ------------------------ | ---------------------------------------------------- | ------------- | -| `opensentinel_owner`\*\* | URL querystring value for owner | `null` | | `opensentinel_token`\*\* | URL querystring value for token | `null` | | `job_status`\*\* | GitHub Actions job status - use `${{ job.status }}` | `null` | | `job_name` | Display name to use in the chat message | Workflow name | @@ -105,11 +102,11 @@ This will send you a notification message to let you know if the production rele ## What about other GitHub events? -Due to the way the permission system around GitHub Actions works, repo secrets cannot be accessed by users on forks & such. In general, an Action that requires a secret will fail when invoked through a pull request from a fork. +The opensentinel system itself handles other GitHub events directly. This action is primarily geared toward sending build + other ad-hoc messages. This action will do its hardest to **NOT fail the build** as a result of a processing error (network/permissions/etc). -If you're still interested in receiving Keybase notifications for other GitHub events (`push`, `pull_request`, etc), set up a **GitHub Notification** webhook with [opensentinel](https://keybase.io/sentinelbot) and add that to your repository. The webhook system is not bound by the permission issues mentioned here! +If you're still interested in receiving Keybase notifications for other GitHub events (`push`, `pull_request`, etc), set up a **GitHub Notification** webhook with [opensentinel](https://www.opensentinel.com/docs/handlers/github-notification) and add that to your repository. ## Filtering Notifications @@ -134,7 +131,7 @@ Every commit that lands on master for this project triggers an automatic build a ## How to get help -The main [README](https://github.com/marvinpinto/actions/blob/master/README.md) for this project has a bunch of information related to debugging & submitting issues. [Opensentinel](https://keybase.io/sentinelbot) help is available in the [opensentinel.users](https://keybase.io/team/opensentinel.users) user group. If you're still stuck, try and get a hold of me on [keybase](https://keybase.io/marvinpinto) and I will do my best to help you out. +The main [README](https://github.com/marvinpinto/actions/blob/master/README.md) for this project has a bunch of information related to debugging & submitting issues. opensentinel help is available through a few [support channels](https://www.opensentinel.com/docs/general/contact) and if you're still stuck, try and get a hold of me on [keybase](https://keybase.io/marvinpinto) and I will do my best to help you out. ## License diff --git a/packages/keybase-notifications/__tests__/main.test.ts b/packages/keybase-notifications/__tests__/main.test.ts index c588833b..8b620470 100644 --- a/packages/keybase-notifications/__tests__/main.test.ts +++ b/packages/keybase-notifications/__tests__/main.test.ts @@ -11,7 +11,6 @@ describe('main handler', () => { jest.resetModules(); nock.disableNetConnect(); - process.env['INPUT_OPENSENTINEL_OWNER'] = 'fakeoslowner'; process.env['INPUT_OPENSENTINEL_TOKEN'] = 'abcd1234fake'; process.env['INPUT_JOB_STATUS'] = 'Success'; process.env['INPUT_JOB_NAME'] = 'Testing Production Deployment'; @@ -42,9 +41,9 @@ describe('main handler', () => { }); it('is able to send out a "success" build message', async () => { - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` completed successfully :tada: - https://example.com', ) .reply(202, { @@ -58,9 +57,9 @@ describe('main handler', () => { it('is able to send out a "failure" build message', async () => { process.env['INPUT_JOB_STATUS'] = 'Failure'; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` failed :rotating_light: - https://example.com', ) .reply(202, { @@ -74,9 +73,9 @@ describe('main handler', () => { it('is able to send out a "cancel" build message', async () => { process.env['INPUT_JOB_STATUS'] = 'Cancelled'; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` was cancelled by `marvinpinto` :warning: - https://example.com', ) .reply(202, { @@ -90,9 +89,9 @@ describe('main handler', () => { it('reverts back to using the workflow name if no job name is specified', async () => { delete process.env['INPUT_JOB_NAME']; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **keybase** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` completed successfully :tada: - https://example.com', ) .reply(202, { @@ -106,9 +105,9 @@ describe('main handler', () => { it('falls back gracefully if this is not a tagged ref', async () => { process.env['GITHUB_REF'] = 'refs/heads/master'; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** for repository `marvinpinto/private-actions-tester` completed successfully :tada: - https://example.com', ) .reply(202, { @@ -122,9 +121,9 @@ describe('main handler', () => { it('falls back gracefully if there is no repository set (for whatever reason)', async () => { delete process.env['GITHUB_REPOSITORY']; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) completed successfully :tada: - https://example.com', ) .reply(202, { @@ -138,9 +137,9 @@ describe('main handler', () => { it('does not send out success messages if configured not to', async () => { process.env['INPUT_ON_SUCCESS'] = 'never'; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` completed successfully :tada: - https://example.com', ) .reply(202, { @@ -155,9 +154,9 @@ describe('main handler', () => { it('does not send out failure messages if configured not to', async () => { process.env['INPUT_ON_FAILURE'] = 'never'; process.env['INPUT_JOB_STATUS'] = 'Failure'; - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` failed :rotating_light: - https://example.com', ) .reply(202, { @@ -170,9 +169,9 @@ describe('main handler', () => { }); it('fails gracefully if unable to send out the message via the opensentinel API', async () => { - const opensentinelAPIcall = nock('https://api.opensentinel.com') + const opensentinelAPIcall = nock('https://automations.opensentinel.com') .post( - '/kb/webhooks?owner=fakeoslowner&token=abcd1234fake', + '/webhook?token=abcd1234fake', 'GitHub build **Testing Production Deployment** (tag v0.0.1) for repository `marvinpinto/private-actions-tester` completed successfully :tada: - https://example.com', ) .reply(408, { diff --git a/packages/keybase-notifications/__tests__/utils/mockSuccessBuildMsg.ts b/packages/keybase-notifications/__tests__/utils/mockSuccessBuildMsg.ts index b0605596..93a3dea7 100644 --- a/packages/keybase-notifications/__tests__/utils/mockSuccessBuildMsg.ts +++ b/packages/keybase-notifications/__tests__/utils/mockSuccessBuildMsg.ts @@ -16,7 +16,6 @@ server.post('/', (req, res) => { }); export const setupEnv = { - INPUT_OPENSENTINEL_OWNER: 'fakeoslowner', INPUT_OPENSENTINEL_TOKEN: 'abcd1234fake', INPUT_JOB_STATUS: 'Success', INPUT_JOB_NAME: 'Testing Production Deployment', diff --git a/packages/keybase-notifications/action.yml b/packages/keybase-notifications/action.yml index 7ae9dc77..106e0766 100644 --- a/packages/keybase-notifications/action.yml +++ b/packages/keybase-notifications/action.yml @@ -2,11 +2,8 @@ name: "Keybase Build Notifications" author: "marvinpinto" description: "Send GitHub build notifications to your Keybase team or channel" inputs: - opensentinel_owner: - description: 'The "owner" portion of your Opensentinel (generic) Webhook URL (e.g. https://api.opensentinel.com/kb/webhooks?owner=&token=efgh6789)' - required: true opensentinel_token: - description: 'The "token" portion of your Opensentinel (generic) Webhook URL (e.g. https://api.opensentinel.com/kb/webhooks?owner=abcd1234&token=)' + description: 'The "token" portion of your opensentinel (generic) Webhook URL (e.g. https://automations.opensentinel.com/webhook?token=)' required: true job_status: description: "Actions build status (e.g. success, failure, cancelled)" diff --git a/packages/keybase-notifications/src/main.ts b/packages/keybase-notifications/src/main.ts index 87b11f51..ecffd018 100644 --- a/packages/keybase-notifications/src/main.ts +++ b/packages/keybase-notifications/src/main.ts @@ -18,7 +18,6 @@ enum BuildNotification { } type Args = { - opensentinelOwner: string; opensentinelToken: string; jobStatus: JobStatus; jobName: string; @@ -28,7 +27,6 @@ type Args = { const getAndValidateArgs = (): Args => { const args = { - opensentinelOwner: core.getInput('opensentinel_owner', {required: true}), opensentinelToken: core.getInput('opensentinel_token', {required: true}), jobStatus: JobStatus.UNKNOWN, jobName: '', @@ -138,13 +136,12 @@ export const main = async () => { core.debug(`Outbound message: ${msg}`); const params = qs.stringify({ - owner: args.opensentinelOwner, token: args.opensentinelToken, }); const baseUrl = process.env['JEST_MOCK_HTTP_PORT'] ? `http://localhost:${process.env['JEST_MOCK_HTTP_PORT']}` - : 'https://api.opensentinel.com'; - const url = `${baseUrl}/kb/webhooks?${params}`; + : 'https://automations.opensentinel.com'; + const url = `${baseUrl}/webhook?${params}`; await axios.post(url, msg, { headers: { 'Content-Type': 'text/plain',