From a00de563b96144df1ae6ba8de4b246cf0c16a862 Mon Sep 17 00:00:00 2001 From: homoluctus Date: Thu, 21 Nov 2019 18:13:20 +0900 Subject: [PATCH] [readme] Add commit parameters description --- README.md | 24 ++++++++++++++++++++++-- dist/index.js | 4 ++-- src/slack.ts | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2fb176bd..02dbbea3 100644 --- a/README.md +++ b/README.md @@ -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.
If commit parameter is true, this parameter is required.
${{ 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() @@ -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 diff --git a/dist/index.js b/dist/index.js index 6719cd90..41a2ee80 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11017,7 +11017,7 @@ class Block { * @param {string} token * @returns {Promise} */ - getCommitField(token) { + getCommitFields(token) { return __awaiter(this, void 0, void 0, function* () { const { owner, repo } = this.context.repo; const { sha } = this.context; @@ -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 = { diff --git a/src/slack.ts b/src/slack.ts index 7f71877c..6dd26bcf 100644 --- a/src/slack.ts +++ b/src/slack.ts @@ -88,7 +88,7 @@ class Block { * @param {string} token * @returns {Promise} */ - public async getCommitField(token: string): Promise { + public async getCommitFields(token: string): Promise { const {owner, repo} = this.context.repo; const {sha} = this.context; const options: Octokit.GitGetCommitParams = { @@ -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);