Skip to content

Commit

Permalink
[readme] Add commit parameters description
Browse files Browse the repository at this point in the history
  • Loading branch information
homoluctus committed Nov 21, 2019
1 parent b632a95 commit a00de56
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,29 @@ 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()
with:
type: ${{ job.status }}
job_name: '*Lint Check*'
mention: 'here'
mention_if: 'failure'
channel: '#random'
url: ${{ secrets.SLACK_WEBHOOK }}
```

↓ Including the latest commit data

```..github/workflows/example2.yml
- name: Slack Notification
uses: homoluctus/slatify@master
if: always()
Expand All @@ -46,6 +64,8 @@ Please refer `action.yml` for more details.
mention_if: 'failure'
channel: '#random'
url: ${{ secrets.SLACK_WEBHOOK }}
commit: true
token: ${{ secrets.GITHUB_TOKEN }}
```

# Slack UI Example
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11017,7 +11017,7 @@ class Block {
* @param {string} token
* @returns {Promise<MrkdwnElement[]>}
*/
getCommitField(token) {
getCommitFields(token) {
return __awaiter(this, void 0, void 0, function* () {
const { owner, repo } = this.context.repo;
const { sha } = this.context;
Expand Down Expand Up @@ -11077,7 +11077,7 @@ class Slack {
fields: slackBlockUI.baseFields
};
if (commitFlag && token) {
const commitFields = yield slackBlockUI.getCommitField(token);
const commitFields = yield slackBlockUI.getCommitFields(token);
baseBlock.fields = baseBlock.fields.concat(commitFields);
}
const attachments = {
Expand Down
4 changes: 2 additions & 2 deletions src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Block {
* @param {string} token
* @returns {Promise<MrkdwnElement[]>}
*/
public async getCommitField(token: string): Promise<MrkdwnElement[]> {
public async getCommitFields(token: string): Promise<MrkdwnElement[]> {
const {owner, repo} = this.context.repo;
const {sha} = this.context;
const options: Octokit.GitGetCommitParams = {
Expand Down Expand Up @@ -160,7 +160,7 @@ export class Slack {
};

if (commitFlag && token) {
const commitFields: MrkdwnElement[] = await slackBlockUI.getCommitField(
const commitFields: MrkdwnElement[] = await slackBlockUI.getCommitFields(
token
);
baseBlock.fields = baseBlock.fields.concat(commitFields);
Expand Down

0 comments on commit a00de56

Please sign in to comment.