slack-post-message-action

A GitHub action that posts a message to Slack using the Block format

Stars
1

Slack Post Message Action

Description

A GitHub action that posts a message to Slack using the Block format.

Screenshot

Arguments

If both block-json and block-json-file are set block-json will take priority.

GitHub Action Contexts can be used in message and block-json.

Example Usage

name: Example Slack Message Workflow

on:
  release:
    types: [published]

jobs:
  slack_message:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Post a message to Slack on release
        uses: ataylorme/slack-post-message-action@master
        with:
          token: "${{ secrets.SLACK_TOKEN }}"
          channel: "#github-action-test"
          message: "Hello from ${{ github.ref }} of ${{ github.repository }}"
          block-json: |
            [
              {
                  "type": "section",
                  "text": {
                      "type": "mrkdwn",
                      "text": "A new release `${{ github.ref }}` for `${{ github.repository }}` was published by ${{ github.actor }}!"
                  },
                  "accessory": {
                      "type": "button",
                      "text": {
                          "type": "plain_text",
                          "text": "View on GitHub"
                      },
                      "url": "https://github.com/${{ github.repository }}/releases/tag/${{ github.ref }}"
                  }
              }
            ]

Example Block JSON

[
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "A new release `1.0.0` for `ataylorme/slack-post-message-action` was published by `ataylorme`!"
        }
    },
    {
        "type": "divider"
    },
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "GitHub Tag: `1.0.0`"
        },
        "accessory": {
            "type": "button",
            "text": {
                "type": "plain_text",
                "text": "View on GitHub"
            },
            "url": "https://github.com/ataylorme/slack-post-message-action/releases/tag/1.0.0"
        }
    }
]