Skip to content

Commit

Permalink
Merge pull request #57 from homoluctus/feature/commit
Browse files Browse the repository at this point in the history
[WIP] Include commit message
  • Loading branch information
homoluctus authored Nov 21, 2019
2 parents 5cddadc + 3ee4bcd commit 9dcaaf0
Show file tree
Hide file tree
Showing 9 changed files with 1,376 additions and 1,160 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: always()
with:
type: ${{ job.status }}
job_name: ':robot_face: *Check action*'
job_name: ':robot_face: *Success*'
mention: 'here'
mention_if: 'failure'
channel: '#develop'
Expand All @@ -31,7 +31,7 @@ jobs:
if: always()
with:
type: ${{ job.status }}
job_name: ':robot_face: *Check action*'
job_name: ':robot_face: *Success no mention*'
channel: '#develop'
url: ${{ secrets.SLACK_WEBHOOK }}

Expand All @@ -41,20 +41,26 @@ jobs:
steps:
- uses: actions/checkout@master

- name: Exit 1
- name: Forced failure
run: exit 1

- name: Slack Notification
uses: ./
if: always()
with:
type: ${{ job.status }}
job_name: ':robot_face: *Check action*'
job_name: ':robot_face: *Failure*'
mention: 'here'
mention_if: 'failure'
channel: '#develop'
url: ${{ secrets.SLACK_WEBHOOK }}

- name: Check if work properly
if: failure()
run: |
echo 'Slack failure notification succeeded'
exit 0
cancel:
# You have to cancel this job
name: Works canceled
Expand All @@ -71,8 +77,29 @@ jobs:
if: always()
with:
type: ${{ job.status }}
job_name: ':robot_face: *Check action*'
job_name: ':robot_face: *Cancel*'
mention: 'here'
mention_if: 'always'
channel: '#develop'
url: ${{ secrets.SLACK_WEBHOOK }}
url: ${{ secrets.SLACK_WEBHOOK }}

- name: Check if work properly
if: cancelled()
run: |
echo 'Slack cancelled notification succeeded'
exit 0
commit:
name: Include commit data
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master

- uses: ./
with:
type: ${{ job.status }}
job_name: ':robot_face: *Commit*'
channel: '#develop'
url: ${{ secrets.SLACK_WEBHOOK }}
commit: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ You can customize the following parameters:
|icon_emoji|optional|Use Slack Incoming Webhook configuration|Slack icon|
|username|optional|Use Slack Incoming Webhook configuration|Slack username|
|channel|optional|Use Slack Incoming Webhook configuration|Slack channel name|
|commit|optional|false|If true, slack notification includes the latest commit message and author.|
|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.|

Please refer `action.yml` for more details.

## Example
```..github/workflows/main.yml
## Examples

```..github/workflows/example1.yml
- name: Slack Notification
uses: homoluctus/slatify@master
if: always()
Expand All @@ -48,9 +51,28 @@ Please refer `action.yml` for more details.
url: ${{ secrets.SLACK_WEBHOOK }}
```

↓ Including the latest commit data

```..github/workflows/example2.yml
- name: Slack Notification
uses: homoluctus/slatify@master
if: always()
with:
type: ${{ job.status }}
job_name: '*Lint Check*'
mention: 'here'
mention_if: 'failure'
channel: '#random'
url: ${{ secrets.SLACK_WEBHOOK }}
commit: true
token: ${{ secrets.GITHUB_TOKEN }}
```

<img src="./images/slack2.png" alt="Notification Preview" width="90%">

# Slack UI Example

<img src="./images/slack.png" alt="Notification Preview" width="70%">
<img src="./images/slack.png" alt="Notification Preview" width="90%">

# Contribute
1. Fork this repository
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ inputs:
url:
description: 'slack incoming webhook url'
required: false
commit:
description: 'whether include commit data or not (true or false)'
required: false
default: 'false'
token:
description: 'need to get commit data'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
Loading

0 comments on commit 9dcaaf0

Please sign in to comment.