Skip to content

Commit 3ae470b

Browse files
authored
feat: add notify-about-build-failure GHA (#211)
1 parent 6a45e88 commit 3ae470b

File tree

8 files changed

+3214
-22
lines changed

8 files changed

+3214
-22
lines changed

.changeset/little-cows-tap.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'davinci-github-actions': minor
3+
---
4+
5+
- add notify-about-build-failure action. It sends notifications about build failure to specified Slack channel and private Slack messages of failing commit author

.lintstagedrc.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const buildTargets = ['create-matrix', 'get-changeset-info', 'report-missing-changeset', 'notify-about-build-failure']
2+
13
module.exports = {
24
'{**/*.{js,jsx,ts,tsx},.changeset/*.md}': [
35
'davinci-syntax lint code',
@@ -7,16 +9,12 @@ module.exports = {
79
paths.length > 0
810
? ['yarn documentation:generate', `git add */README.md`]
911
: [],
10-
'create-matrix/**/*.js': () => [
11-
'yarn build:create-matrix',
12-
'git add create-matrix/dist',
13-
],
14-
'get-changeset-info/**/*.js': () => [
15-
'yarn build:get-changeset-info',
16-
'git add get-changeset-info/dist',
17-
],
18-
'report-missing-changeset/**/*.js': () => [
19-
'yarn build:report-missing-changeset',
20-
'git add report-missing-changeset/dist',
21-
],
12+
...(buildTargets.reduce((acc, target) => {
13+
acc[`${target}/**/*.js`] = () => [
14+
`yarn ncc build ${target}/index.js -o ${target}/dist`,
15+
`git add ${target}/dist`,
16+
]
17+
18+
return acc
19+
}, {}))
2220
}

notify-about-build-failure/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Notify about build failure
2+
3+
Sends notifications about build failure to specified Slack channel and private Slack messages of failing commit author
4+
5+
### Description
6+
7+
Sends notification about build failure to specified Slack channel and direct Slack messages of failing commit author. In order to match GitHub name of commit authors and their Slack handles, the TopTeam API is used.
8+
9+
### Inputs
10+
11+
The list of arguments, that are used in GH Action:
12+
13+
| name | type | required | default | description |
14+
| --------------------------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
15+
| `slack-bot-token` | string || | Slack API token, needed for sending messages in Slack |
16+
| `top-team-api-key` | string || | TopTeam API key, needed for fetching Company structure to match GitHub name of commit author to Slack handle |
17+
| `slack-channel-name` | string || | Slack channel name (for example, `#-test-channel`) |
18+
| `github-commit-author-name` | string || | GitHub name of commit author, needed for finding the Slack handle of commit author |
19+
| `github-action-run-url` | string || | Failing GitHub Acton run URL (for example, `https://github.com/toptal/staff-portal/actions/runs/123`), needed for the notification message |
20+
21+
### Outputs
22+
23+
Not specified
24+
25+
### ENV Variables
26+
27+
Not specified
28+
29+
### Usage
30+
31+
GitHub Actions Notifications bot will send message to commit author and post a message in #-test-notifications-channel channel in Slack. The message will contain URL for the failing GitHub Action job run.
32+
33+
```yaml
34+
jobs:
35+
notify-build-breaker:
36+
name: Notify about build failure
37+
steps:
38+
- uses: toptal/davinci-github-actions/notify-about-build-failure@master
39+
with:
40+
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
41+
top-team-api-key: ${{ secrets.TOP_TEAM_API_KEY }}
42+
slack-channel-name: '#-test-notifications-channel'
43+
github-commit-author-name: ${{ github.event.pusher.name }}
44+
github-action-run-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
45+
```

notify-about-build-failure/action.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Notify about build failure
2+
description: Sends notifications about build failure to specified Slack channel and private Slack messages of failing commit author
3+
inputs:
4+
slack-bot-token:
5+
description: Slack API token, needed for sending messages in Slack
6+
required: true
7+
top-team-api-key:
8+
description: TopTeam API key, needed for fetching Company structure to match GitHub name of commit author to Slack handle
9+
required: true
10+
slack-channel-name:
11+
description: Slack channel name (for example, `#-test-channel`)
12+
required: true
13+
github-commit-author-name:
14+
description: GitHub name of commit author, needed for finding the Slack handle of commit author
15+
required: true
16+
github-action-run-url:
17+
description: Failing GitHub Acton run URL (for example, `https://github.com/toptal/staff-portal/actions/runs/123`), needed for the notification message
18+
required: true
19+
20+
runs:
21+
using: node20
22+
main: ./dist/index.js

0 commit comments

Comments
 (0)