Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit 0e6dec5

Browse files
committed
feat: send Keybase build notifications using the opensentinel API
BREAKING CHANGE: This no longer sends out Keybase messages directly (using a username + paperkey), but instead makes use of the an API to do so.
1 parent c8e67e1 commit 0e6dec5

36 files changed

+591
-5263
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ jobs:
2727
yarn run lint
2828
yarn run test
2929
yarn run build
30+
- uses: "./packages/keybase-notifications"
31+
if: always()
32+
with:
33+
job_status: ${{ job.status }}
34+
opensentinel_owner: ${{ secrets.OSL_OWNER }}
35+
opensentinel_token: ${{ secrets.OSL_TOKEN }}

.github/workflows/keybase.yml

-39
This file was deleted.

.github/workflows/pre-release.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
files: |
3232
packages/automatic-releases/dist/index.js
3333
packages/keybase-notifications/dist/index.js
34-
packages/keybase-notifications/dist/keybase
3534
id: "automatic_releases"
3635

3736
# marvinpinto/action-keybase-notifications
@@ -42,10 +41,9 @@ jobs:
4241
run: |
4342
./scripts/mirror-actions.sh "$AUTOMATIC_RELEASES_TAG"
4443
45-
- uses: "./packages/keybase-notifications/"
44+
- uses: "./packages/keybase-notifications"
45+
if: always()
4646
with:
47-
message: "Version `${{ steps.automatic_releases.outputs.automatic_releases_tag }}` of `${{ github.repository }}` successfully released."
48-
keybase_username: "${{ secrets.KeybaseUsername }}"
49-
keybase_paper_key: "${{ secrets.KeybasePaperKey }}"
50-
keybase_team_name: "${{ secrets.KeybaseTeamName }}"
51-
keybase_topic_name: "${{ secrets.KeybaseTopicName }}"
47+
job_status: ${{ job.status }}
48+
opensentinel_owner: ${{ secrets.OSL_OWNER }}
49+
opensentinel_token: ${{ secrets.OSL_TOKEN }}

.github/workflows/tagged-release.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
files: |
3030
packages/automatic-releases/dist/index.js
3131
packages/keybase-notifications/dist/index.js
32-
packages/keybase-notifications/dist/keybase
3332
id: "automatic_releases"
3433

3534
# marvinpinto/action-keybase-notifications
@@ -41,9 +40,8 @@ jobs:
4140
./scripts/mirror-actions.sh "$AUTOMATIC_RELEASES_TAG"
4241
4342
- uses: "marvinpinto/action-keybase-notifications@latest"
43+
if: always()
4444
with:
45-
message: "Version `${{ steps.automatic_releases.outputs.automatic_releases_tag }}` of `${{ github.repository }}` successfully released."
46-
keybase_username: "${{ secrets.KeybaseUsername }}"
47-
keybase_paper_key: "${{ secrets.KeybasePaperKey }}"
48-
keybase_team_name: "${{ secrets.KeybaseTeamName }}"
49-
keybase_topic_name: "${{ secrets.KeybaseTopicName }}"
45+
job_status: ${{ job.status }}
46+
opensentinel_owner: ${{ secrets.OSL_OWNER }}
47+
opensentinel_token: ${{ secrets.OSL_TOKEN }}

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
"@commitlint/cli": "^8.2.0",
3434
"@commitlint/config-conventional": "^8.2.0",
3535
"@commitlint/config-lerna-scopes": "^8.2.0",
36-
"@types/jest": "^24.0.18",
37-
"@types/node": "^12.7.12",
38-
"@typescript-eslint/eslint-plugin": "^2.3.3",
39-
"@typescript-eslint/parser": "^2.3.3",
36+
"@types/jest": "^24.0.24",
37+
"@types/node": "^13.1.0",
38+
"@typescript-eslint/eslint-plugin": "^2.13.0",
39+
"@typescript-eslint/parser": "^2.13.0",
4040
"@zeit/ncc": "^0.20.5",
41-
"eslint": "^6.5.1",
42-
"eslint-config-prettier": "^6.4.0",
43-
"eslint-plugin-jest": "^22.17.0",
44-
"eslint-plugin-prettier": "^3.1.1",
41+
"eslint": "^6.8.0",
42+
"eslint-config-prettier": "^6.7.0",
43+
"eslint-plugin-jest": "^23.1.1",
44+
"eslint-plugin-prettier": "^3.1.2",
4545
"jest": "^24.9.0",
4646
"jest-circus": "^24.9.0",
4747
"lerna": "^3.17.0",
48-
"prettier": "^1.18.2",
49-
"ts-jest": "^24.1.0",
50-
"typescript": "^3.6.4"
48+
"prettier": "^1.19.1",
49+
"ts-jest": "^24.2.0",
50+
"typescript": "^3.7.4"
5151
},
5252
"eslintIgnore": [
5353
"!.*.js"

packages/automatic-releases/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@actions/core": "^1.1.3",
2525
"@actions/github": "^1.1.0",
2626
"@octokit/rest": "^16.33.0",
27-
"@types/lodash": "^4.14.144",
2827
"conventional-changelog-angular": "^5.0.5",
2928
"conventional-commits-parser": "^3.0.5",
3029
"globby": "^10.0.1",

packages/automatic-releases/src/utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import * as core from '@actions/core';
2-
import {getShortSHA} from '../../keybase-notifications/src/githubEvent';
32
import * as Octokit from '@octokit/rest';
43
import defaultChangelogOpts from 'conventional-changelog-angular';
54

5+
export const getShortSHA = (sha: string): string => {
6+
const coreAbbrev = 7;
7+
return sha.substring(0, coreAbbrev);
8+
};
9+
610
export type ParsedCommitsExtraCommit = Octokit.ReposCompareCommitsResponseCommitsItem & {
711
author: {
812
email: string;

packages/keybase-notifications/README.md

+64-74
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Keybase Chat Notifications
1+
# Keybase Build Notifications
22

3-
This action allows you to post messages to [Keybase Chat](https://keybase.io/blog/keybase-chat) channels, teams, and DMs. It sends messages using a Keybase paperkey and the corresponding Keybase username.
3+
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.
44

55
![Keybase default GitHub notification](images/keybase-gh-notification-example.png)
66

77
## Contents
88

99
1. [Using the Action](#using-the-action)
1010
1. [Parameters](#parameters)
11-
1. [Supported GitHub Events](#supported-github-events)
11+
1. [What about other GitHub events?](#what-about-other-github-events)
1212
1. [Filtering Notifications](#filtering-notifications)
1313
1. [Versioning](#versioning)
1414
1. [How to get help](#how-to-get-help)
@@ -18,112 +18,102 @@ This action allows you to post messages to [Keybase Chat](https://keybase.io/blo
1818
1919
## Using the Action
2020

21-
You will need a Keybase paperkey and its corresponding username. It is probably a good idea to create a dedicated Keybase account for this purpose, or at the very least generate a dedicated paperkey on your existing account. This makes it easier to revoke if needed.
21+
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.
2222

23-
### Pull Request Notifications Example
23+
As a reference, `@sentinelbot` Webhook URLs for Keybase will look something like:
24+
25+
```text
26+
https://api.opensentinel.com/kb/webhooks?owner=<OSL_OWNER>&token=<OSL_TOKEN>
27+
```
28+
29+
### Build notifications for CI Tests
2430

2531
```yaml
26-
name: "keybase"
32+
name: "CI Tests"
2733

2834
on:
29-
pull_request:
30-
types:
31-
- "opened"
32-
- "closed"
33-
- "reopened"
34-
- "synchronize"
35+
push:
3536

3637
jobs:
37-
keybase:
38+
ci:
3839
runs-on: "ubuntu-latest"
3940
steps:
41+
# ...
42+
- name: "Build & test"
43+
run: |
44+
echo "done!"
45+
46+
# Add the notification step as the last one
4047
- uses: "marvinpinto/action-keybase-notifications@latest"
48+
if: always()
4149
with:
42-
keybase_username: "${{ secrets.KeybaseUsername }}"
43-
keybase_paper_key: "${{ secrets.KeybasePaperKey }}" # "fancy regular ..."
44-
keybase_team_name: "${{ secrets.KeybaseTeamName }}" # "keybasefriends"
45-
keybase_topic_name: "${{ secrets.KeybaseTopicName }}" # "general"
50+
job_status: ${{ job.status }}
51+
opensentinel_owner: ${{ secrets.OSL_OWNER }}
52+
opensentinel_token: ${{ secrets.OSL_TOKEN }}
53+
on_success: "never"
54+
on_failure: "always"
4655
```
4756
48-
### Private Messaging
57+
This will send you a Keybase chat notification whenever a CI build fails but not when it passes (if you wanted to reduce channel noise). The `if: always()` stanza above ensures that the notification step [runs no matter what](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#job-status-check-functions).
58+
59+
### Build notifications for releases
4960

5061
```yaml
62+
on:
63+
push:
64+
tags:
65+
- "v*"
66+
5167
jobs:
52-
keybase:
68+
ci:
5369
runs-on: "ubuntu-latest"
5470
steps:
55-
- uses: "marvinpinto/action-keybase-notifications@latest"
56-
with:
57-
keybase_username: "${{ secrets.KeybaseUsername }}"
58-
keybase_paper_key: "${{ secrets.KeybasePaperKey }}" # "fancy regular ..."
59-
keybase_channel: "${{ secrets.KeybaseChannel }}" # "you,robot,chris"
60-
```
71+
# ...
72+
- name: "Build & test"
73+
run: |
74+
echo "done!"
6175
62-
### Custom Notification Message
76+
- name: "Deploy to production"
77+
run: |
78+
echo "+1"
6379
64-
```yaml
65-
jobs:
66-
keybase:
67-
runs-on: "ubuntu-latest"
68-
steps:
6980
- uses: "marvinpinto/action-keybase-notifications@latest"
81+
if: always()
7082
with:
71-
message: "Hey there, world!"
72-
keybase_username: "${{ secrets.KeybaseUsername }}"
73-
keybase_paper_key: "${{ secrets.KeybasePaperKey }}" # "fancy regular ..."
74-
keybase_team_name: "${{ secrets.KeybaseTeamName }}" # "keybasefriends"
75-
keybase_topic_name: "${{ secrets.KeybaseTopicName }}" # "general"
83+
job_status: ${{ job.status }}
84+
job_name: "Production Release"
85+
opensentinel_owner: ${{ secrets.OSL_OWNER }}
86+
opensentinel_token: ${{ secrets.OSL_TOKEN }}
7687
```
7788

89+
This will send you a notification message to let you know if the production release was successful or not.
90+
7891
## Parameters
7992

80-
| Parameter | Description | Default |
81-
| ----------------------- | ------------------------------------------- | ------- |
82-
| `keybase_username`\*\* | Keybase username, e.g. `spacedrop` | `null` |
83-
| `keybase_paper_key`\*\* | Keybase Paper Key, e.g. `fancy regular ...` | `null` |
84-
| `keybase_channel` | Peer channels, e.g. `you,robot,chris` | `null` |
85-
| `keybase_team_name` | Keybase Team Name, e.g. `keybasefriends` | `null` |
86-
| `keybase_topic_name` | Team channel, e.g. `general` | `null` |
93+
| Parameter | Description | Default |
94+
| ------------------------ | ---------------------------------------------------- | ------------- |
95+
| `opensentinel_owner`\*\* | URL querystring value for owner | `null` |
96+
| `opensentinel_token`\*\* | URL querystring value for token | `null` |
97+
| `job_status`\*\* | GitHub Actions job status - use `${{ job.status }}` | `null` |
98+
| `job_name` | Display name to use in the chat message | Workflow name |
99+
| `on_success` | When a build passes, notify you "always" or "never"? | `always` |
100+
| `on_failure` | When a build fails, notify you "always" or "never"? | `always` |
87101

88102
### Notes:
89103

90104
- Parameters denoted with `**` are required.
91-
- `keybase_team_name` and `keybase_topic_name` are required for messaging within team chat rooms.
92-
- `keybase_channel` is required for peer-to-peer messages.
93105

94-
## Supported GitHub Events
106+
## What about other GitHub events?
95107

96-
The following events are supported in this action. Everything else gets silently ignored. Have a read through the [Events that trigger workflows](https://help.github.com/en/articles/events-that-trigger-workflows) document for more information on how this works.
108+
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.
97109

98-
```yaml
99-
on:
100-
watch: # when someone stars a repository
101-
types:
102-
- "started"
103-
push: # when someone pushes to a repository branch
104-
pull_request:
105-
types:
106-
- "opened"
107-
- "closed"
108-
- "reopened"
109-
- "synchronize"
110-
commit_comment:
111-
issues:
112-
types:
113-
- "opened"
114-
- "edited"
115-
- "closed"
116-
- "reopened"
117-
issue_comment:
118-
types:
119-
- "created"
120-
- "edited"
121-
- "deleted"
122-
```
110+
This action will do its hardest to **NOT fail the build** as a result of a processing error (network/permissions/etc).
111+
112+
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!
123113

124114
## Filtering Notifications
125115

126-
You can cut down on chat noise by applying filters to events that trigger this action. For example, you can send a Keybase chat notification only when someone pushes to the `master` branch.
116+
You can cut down on chat noise by applying filters to events that trigger this action. For example, you can send a Keybase build notification only when someone pushes to the `master` branch.
127117

128118
```yaml
129119
on:
@@ -144,7 +134,7 @@ Every commit that lands on master for this project triggers an automatic build a
144134

145135
## How to get help
146136

147-
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. 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.
137+
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.
148138

149139
## License
150140

packages/keybase-notifications/__tests__/githubEvent.test.ts

-21
This file was deleted.

0 commit comments

Comments
 (0)