Provides the function of slack notification to GitHub Actions.
Перейти к файлу
839 6a706b2cad
Merge pull request #32 from 8398a7/feature/26
[#26] If csv contains space, normalize it.
2019-12-30 16:58:53 +09:00
.github/workflows Separate notification destinations for integration tests 2019-12-28 18:38:13 +09:00
__tests__ [#26] If csv contains space, normalize it. 2019-12-30 16:56:08 +09:00
dist [command] npm run build && npm run pack 2019-12-28 18:12:56 +09:00
docs Initial commit 2019-08-15 15:14:40 +00:00
src [#26] If csv contains space, normalize it. 2019-12-30 16:56:08 +09:00
.eslintignore update template 2019-12-27 16:35:42 +09:00
.eslintrc.json update template 2019-12-27 16:35:42 +09:00
.gitignore update template 2019-12-27 16:35:42 +09:00
.prettierignore update template 2019-12-27 16:35:42 +09:00
.prettierrc.json update template 2019-12-27 16:35:42 +09:00
LICENSE Prepare repository 2019-08-16 00:19:52 +09:00
README.md close #27 Fixed broken link 2019-12-28 18:17:20 +09:00
action.yml update template 2019-12-27 16:35:42 +09:00
jest.config.js add codecov setting 2019-12-28 01:36:39 +09:00
package-lock.json update version 2019-12-28 18:27:34 +09:00
package.json update version 2019-12-28 18:27:34 +09:00
tsconfig.json update template 2019-12-27 16:35:42 +09:00

README.md

Action Slack

codecov

You can notify slack of GitHub Actions.

Usage

See action.yml, test.yml

with Parameters

key value default description
status 'success' or 'failure' or 'cancelled' or 'custom' '' Recommend
${{ job.status }}.
text any string '' You can add to text by specifying it.
author_name any string '8398a7@action-slack' It can be overwritten by specifying. The job name is recommend.
mention 'here' or 'channel' or user_id (e.g. mention: user_id,user_id2) '' Always mention when specified.
only_mention_fail 'here' or 'channel' or user_id (e.g. mention: user_id,user_id2) '' If specified, mention only on failure.
payload e.g. {"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()} '' Only available when status: custom. The payload format can pass javascript object.
username Only legacy incoming webhook supported. '' override the legacy integration's default name.
icon_emoji Only legacy incoming webhook supported. '' an emoji code string to use in place of the default icon.
icon_url Only legacy incoming webhook supported. '' an icon image URL string to use in place of the default icon.
channel Only legacy incoming webhook supported. '' override the legacy integration's default channel. This should be an ID, such as C8UJ12P4P.

See here for payload reference or Custom Notification.

Notification

success
- uses: 8398a7/action-slack@v2
  with:
    status: ${{ job.status }}
    author_name: Integration Test # default: 8398a7@action-slack
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
  if: always() # Pick up events even if the job fails or is canceled.

When adding to text, write as follows.

- uses: 8398a7/action-slack@v2
  with:
    status: ${{ job.status }}
    text: overwrite text
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

In case of failure or cancellation, you will be notified as follows.

failure cancelled

Legacy Incoming Webhooks

If you specify as follows, you can also support legacy incoming webhooks.
The specified secrets.SLACK_WEBHOOK_URL must be legacy.

- uses: 8398a7/action-slack@v2
  with:
    type: ${{ job.status }}
    username: Custom Username
    icon_emoji: ':octocat:'
    channel: '#integration-test'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Custom Notification

Use status: custom if you want to send an arbitrary payload.
The payload format can pass javascript object.

custom
- uses: 8398a7/action-slack@v2
  with:
    status: custom
    payload: |
      {
        text: "Custom Field Check",
        attachments: [{
          "author_name": "8398a7@action-slack", // json
          fallback: 'fallback',
          color: 'good',
          title: 'CI Result',
          text: 'Succeeded',
          fields: [{
            title: 'lower case',
            value: 'LOWER CASE CHECK'.toLowerCase(),
            short: true
          },
          {
            title: 'reverse',
            value: 'gnirts esrever'.split('').reverse().join(''),
            short: true
          },
          {
            title: 'long title1',
            value: 'long value1',
            short: false
          }],
          actions: [{
          }]
        }]
      }      
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Next Action

Selectable Field

Currently the field is fixed, but I want to make it selectable.
It is assumed that the input is in csv format.

- uses: 8398a7/action-slack@v2
  with:
    status: ${{ job.status }}
    fields: repo,message,action,author
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required