Skip to content

Commit 8623b89

Browse files
committed
First version
0 parents  commit 8623b89

File tree

18 files changed

+15405
-0
lines changed

18 files changed

+15405
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: TS Lint Check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- src/*
9+
pull_request:
10+
branches:
11+
- master
12+
paths:
13+
- src/*
14+
15+
jobs:
16+
lint:
17+
name: Lint Check
18+
runs-on: ubuntu-18.04
19+
steps:
20+
- uses: actions/checkout@master
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: '10.x'
26+
27+
- name: Setup TS
28+
run: npm install tslint typescript -g
29+
30+
- name: Lint check with tslint
31+
run: tslint './src/*.ts'

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Prepare for release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
name: Build production
11+
runs-on: ubuntu-18.04
12+
steps:
13+
- uses: actions/checkout@v1
14+
15+
- uses: actions/setup-node@v1
16+
with:
17+
node-version: '10.x'
18+
19+
- name: Create Release
20+
uses: actions/[email protected]
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
tag_name: ${{ github.ref }}
25+
release_name: ${{ github.ref }}
26+
draft: 'false'
27+
prerelease: 'false'
28+
29+
- name: Rocket.Chat Notification
30+
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
31+
if: always()
32+
with:
33+
type: ${{ job.status }}
34+
job_name: ':rocket: *Publish new release ${{ github.ref }}*'
35+
channel: '#develop'
36+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}

.github/workflows/test.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Check notification
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
success:
7+
name: Works properly
8+
runs-on: ubuntu-18.04
9+
steps:
10+
- uses: actions/checkout@master
11+
12+
- name: Rocket.Chat Notification
13+
uses: ./
14+
if: always()
15+
with:
16+
type: ${{ job.status }}
17+
job_name: ':robot_face: *Success*'
18+
mention: 'here'
19+
mention_if: 'failure'
20+
channel: '#develop'
21+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
22+
23+
success_no_mention:
24+
name: Works properly without mention
25+
runs-on: ubuntu-18.04
26+
steps:
27+
- uses: actions/checkout@master
28+
29+
- name: Rocket.Chat Notification
30+
uses: ./
31+
if: always()
32+
with:
33+
type: ${{ job.status }}
34+
job_name: ':robot_face: *Success no mention*'
35+
channel: '#develop'
36+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
37+
38+
failure:
39+
name: Works failed
40+
runs-on: ubuntu-18.04
41+
steps:
42+
- uses: actions/checkout@master
43+
44+
- name: Forced failure
45+
run: exit 1
46+
47+
- name: Rocket.Chat Notification
48+
uses: ./
49+
if: failure()
50+
with:
51+
type: ${{ job.status }}
52+
job_name: ':robot_face: *Failure*'
53+
mention: 'here'
54+
mention_if: 'failure'
55+
channel: '#develop'
56+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
57+
58+
- name: Check if work properly
59+
if: failure()
60+
run: |
61+
echo 'Rocket.Chat failure notification succeeded'
62+
exit 0
63+
64+
cancel:
65+
# You have to cancel this job
66+
name: Works canceled
67+
runs-on: ubuntu-18.04
68+
needs: success
69+
timeout-minutes: 1
70+
steps:
71+
- uses: actions/checkout@master
72+
73+
- name: Wait
74+
run: sleep 70
75+
76+
- name: Rocket.Chat Notification
77+
uses: ./
78+
if: cancelled()
79+
with:
80+
type: ${{ job.status }}
81+
job_name: ':robot_face: *Cancel*'
82+
mention: 'here'
83+
mention_if: 'always'
84+
channel: '#develop'
85+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
86+
87+
- name: Check if work properly
88+
if: cancelled()
89+
run: |
90+
echo 'Rocket.Chat cancelled notification succeeded'
91+
exit 0
92+
93+
commit:
94+
name: Include commit data
95+
runs-on: ubuntu-18.04
96+
steps:
97+
- uses: actions/checkout@master
98+
99+
- uses: ./
100+
with:
101+
type: ${{ job.status }}
102+
job_name: ':robot_face: *Commit*'
103+
channel: '#develop'
104+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
105+
commit: 'true'
106+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.node_repl_history
2+
.config/
3+
.npm/
4+
node_modules/
5+
package-lock.json

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 200,
3+
"tabWidth": 4,
4+
"useTabs": true,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018 GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Rocket.Chat.GitHub.Action.Notification
2+
3+
![](https://github.com/RocketChat/Rocket.Chat.GitHub.Action.Notification/workflows/TS%20Lint%20Check/badge.svg)
4+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/RocketChat/Rocket.Chat.GitHub.Action.Notification?color=brightgreen)
5+
![GitHub](https://img.shields.io/github/license/RocketChat/Rocket.Chat.GitHub.Action.Notification?color=brightgreen)
6+
7+
This is Rocket.Chat Notification for GitHub Actions.<br>
8+
Generated from [actions/javascript-template](https://github.com/actions/javascript-template).
9+
10+
# Feature
11+
- Notify the result of GitHub Actions
12+
- Support three job status (reference: [job-context](https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#job-context))
13+
- success
14+
- failure
15+
- cancelled
16+
- Mention
17+
- Notify message to channel members efficiently
18+
- You can specify the condition to mention
19+
20+
# How to use
21+
First of all, you need to set GitHub secrets for ROCKETCHAT_WEBHOOK that is Incoming Webhook URL.<br>
22+
You can customize the following parameters:
23+
24+
|with parameter|required/optional|default|description|
25+
|:--:|:--:|:--|:--|
26+
|type|required|N/A|The result of GitHub Actions job<br>This parameter value must contain the following word:<br>- `success`<br>- `failure`<br>- `cancelled`<br>We recommend using ${{ job.status }}|
27+
|job_name|required|N/A|Means rocket.chat notification title|
28+
|url|required|N/A|Rocket.Chat Incoming Webhooks URL<br>Please specify this key or ROCKETCHAT_WEBHOOK environment variable<br>※ROCKETCHAT_WEBHOOK will be deprecated|
29+
|mention|optional|N/A|Rocket.Chat message mention|
30+
|mention_if|optional|N/A|The condition to mention<br>This parameter can contain the following word:<br>- `success`<br>- `failure`<br>- `cancelled`<br>- `always`|
31+
|icon_emoji|optional|Use Rocket.Chat Incoming Webhook configuration|Rocket.Chat icon|
32+
|username|optional|Use Rocket.Chat Incoming Webhook configuration|Rocket.Chat username|
33+
|channel|optional|Use Rocket.Chat Incoming Webhook configuration|Rocket.Chat channel name|
34+
|commit|optional|false|If true, Rocket.Chat notification includes the latest commit message and author.|
35+
|token|case by case|N/A|This token is used to get commit data.<br>If commit parameter is true, this parameter is required.<br>${{ secrets.GITHUB_TOKEN }} is recommended.|
36+
37+
Please refer `action.yml` for more details.
38+
39+
## Examples
40+
41+
```..github/workflows/example1.yml
42+
- name: Rocket.Chat Notification
43+
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
44+
if: always()
45+
with:
46+
type: ${{ job.status }}
47+
job_name: '*Lint Check*'
48+
mention: 'here'
49+
mention_if: 'failure'
50+
channel: '#random'
51+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
52+
```
53+
54+
↓ Including the latest commit data
55+
56+
```..github/workflows/example2.yml
57+
- name: Rocket.Chat Notification
58+
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
59+
if: always()
60+
with:
61+
type: ${{ job.status }}
62+
job_name: '*Lint Check*'
63+
mention: 'here'
64+
mention_if: 'failure'
65+
channel: '#random'
66+
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
67+
commit: true
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
```
70+
71+
# Rocket.Chat UI Example
72+
73+
<img src="./images/rocketchat.png" alt="Notification Preview" width="90%">
74+
75+
# Contribute
76+
1. Fork this repository
77+
2. Pull your repository in local machine
78+
3. Update original repository
79+
4. Checkout "master" branch based "remotes/origin/master" branch
80+
5. Work on "master" branch
81+
6. Push you changes to your repository
82+
7. Create a new Pull Request
83+
84+
# LICENSE
85+
86+
[The MIT License (MIT)](https://github.com/RocketChat/Rocket.Chat.GitHub.Action.Notification/blob/master/LICENSE)

__tests__/main.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
describe('TODO - Add a test suite', () => {
2+
it('TODO - Add a test', async () => {});
3+
});

action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'Rocket.Chat Notification'
2+
description: 'Rocket.Chat Notification for GitHub Actions'
3+
author: 'Rocket.Chat'
4+
inputs:
5+
type:
6+
description: 'job status (success, failure or cancelled)'
7+
required: true
8+
job_name:
9+
description: 'job name of workflow (format: markdown)'
10+
required: true
11+
mention:
12+
description: 'rocket.chat mention'
13+
required: false
14+
mention_if:
15+
description: 'the condition for mention'
16+
required: false
17+
username:
18+
description: 'rocket.chat username'
19+
required: false
20+
icon_emoji:
21+
description: 'rocket.chat icon emoji'
22+
required: false
23+
channel:
24+
description: 'rocket.chat channel'
25+
required: false
26+
url:
27+
description: 'rocket.chat incoming webhook url'
28+
required: false
29+
commit:
30+
description: 'whether include commit data or not (true or false)'
31+
required: false
32+
default: 'false'
33+
token:
34+
description: 'need to get commit data'
35+
required: false
36+
runs:
37+
using: 'node12'
38+
main: 'dist/index.js'
39+
branding:
40+
icon: 'bell'
41+
color: 'green'

0 commit comments

Comments
 (0)