Skip to content

Latest commit

 

History

History
124 lines (101 loc) · 5.84 KB

README.md

File metadata and controls

124 lines (101 loc) · 5.84 KB

Action Slack

GitHub Actions status GitHub Actions status

You can notify slack of GitHub Actions.

Usage

See action.yml, checkin.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 '' '' Always mention when specified.
only_mention_fail 'here' or 'channel' or '' '' If specified, mention only on failure.
payload e.g. {"text": "Custom Field Check"} '' Only available when status: custom.
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:
    type: ${{ 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

Custom Notification

Use status: custom if you want to send an arbitrary payload.

custom

- uses: 8398a7/action-slack@v2
  with:
    status: custom
    payload: |
      { "text": "Custom Field Check",
        "attachments": [{
          "author_name": "slack-actions",
          "fallback": "fallback",
          "color": "good",
          "title": "CI Result",
          "text": "Succeeded",
          "fields": [{
            "title": "short title1",
            "value": "short value1",
            "short": true
          },
          {
            "title": "short title2",
            "value": "short value2",
            "short": true
          },
          {
            "title": "long title1",
            "value": "long value1",
            "short": false
          }],
          "actions": [{
          }]
        }]
      }
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
    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