Coder Social home page Coder Social logo

slack-github-action's Introduction

Slack Send GitHub Action

codecov

Send data into Slack using this GitHub Action!

Sending Variables

You can send GitHub-specific data related to GitHub Action workflow events using GitHub Contexts and Variables that GitHub Actions provides.

For examples on how to leverage this in your workflows, check out the example workflows we have.

How to Send Data to Slack

This package has three different techniques to send data to Slack:

  1. Send data to Slack's Workflow Builder (requires a paid Slack instance).
  2. Send data via a Slack app to post to a specific channel (use an existing custom app or create a new one).
  3. Send data via a Slack Incoming Webhook URL (use an existing custom app or create a new one).

The recommended way to use this action is with Slack's Workflow Builder (if you're on a paid Slack plan).

Technique 1: Slack Workflow Builder

โ—๏ธ This approach requires a paid Slack plan; it also doesn't support any text formatting

This technique sends data into Slack via a webhook URL created using Slack's Workflow builder. Follow these steps to create a Slack workflow using webhooks. The Slack workflow webhook URL will be in the form https://hooks.slack.com/workflows/.....

As part of the workflow setup, you will need to define expected variables in the payload the webhook will receive (described in the "Create custom variables" section of the docs). If these variables are missing in the payload, an error is returned.

To match the webhook input format expected by Workflow Builder, the payload will be flattened and stringified (all nested keys are moved to the top level) before being sent. The default delimiter used to flatten payloads is a period (".") but should be changed to an underscore ("_") using the payload-delimiter parameter if you're using nested payloads as input values in your own workflows.

Setup

  • Create a Slack workflow webhook.
  • Copy the webhook URL (https://hooks.slack.com/workflows/....) and add it as a secret in your repo settings named SLACK_WEBHOOK_URL.
  • Add a step to your GitHub action to send data to your Webhook.
  • Configure your Slack workflow to use variables from the incoming payload from the GitHub Action. You can select where you want to post the data and how you want to format it in Slack's workflow builder interface.

Usage

Add this Action as a step to your project's GitHub Action Workflow file:

- name: Send GitHub Action trigger data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  with:
    payload-delimiter: "_"
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

or

- name: Send custom JSON data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  with:
    # This data can be any valid JSON from a previous step in the GitHub Action
    payload: |
      {
        "key": "value",
        "foo": "bar"
      }
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

or

If the payload is provided it will take preference over payload-file-path

- name: Send custom JSON data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  with:
    payload-file-path: "./payload-slack-content.json"
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

To send the payload file JSON as is, without replacing templated values with github.context or github.env, set payload-file-path-parsed to false. Default: true.

- name: Send custom JSON data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  with:
    payload-file-path: "./payload-slack-content.json"
    payload-file-path-parsed: false
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Technique 2: Slack App

By creating a new Slack app or using an existing one, this approach allows your GitHub Actions job to post a message in a Slack channel or direct message by utilizing the chat.postMessage API method. Using this approach you can instantly post a message without setting up Slack workflows.

Setup

  • Create a Slack App for your workspace (alternatively use an existing app you have already created and installed).
  • Add the chat:write bot scope under OAuth & Permissions.
  • Install the app to your workspace.
  • Copy the app's Bot Token from the OAuth & Permissions page and add it as a secret in your repo settings named SLACK_BOT_TOKEN.
  • Invite the bot user into the channel you wish to post messages to (/invite @bot_user_name).

Usage

Add this Action as a step to your project's GitHub Action Workflow file:

- name: Post to a Slack channel
  id: slack
  uses: slackapi/[email protected]
  with:
    # Slack channel id, channel name, or user id to post message.
    # See also: https://api.slack.com/methods/chat.postMessage#channels
    # You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs.
    channel-id: 'CHANNEL_ID,ANOTHER_CHANNEL_ID'
    # For posting a simple plain text message
    slack-message: "GitHub build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Using JSON payload for constructing a message is also available:

- name: Post to a Slack channel
  id: slack
  uses: slackapi/[email protected]
  with:
    # Slack channel id, channel name, or user id to post message.
    # See also: https://api.slack.com/methods/chat.postMessage#channels
    channel-id: 'CHANNEL_ID'
    # For posting a rich message using Block Kit
    payload: |
      {
        "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
        "blocks": [
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
            }
          }
        ]
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Update the message

If you would like to notify the real-time updates on a build status, you can modify the message your build job posted in the subsequent steps. In order to do this, the steps after the first message posting can have update-ts: ${{ steps.slack.outputs.ts }} in their settings. With this, the step updates the already posted channel message instead of posting a new one.

Please note that the message update step does not accept a channel name. Set a channel ID for the steps for the actions that update messages.

- id: slack
  uses: slackapi/[email protected]
  with:
    # The following message update step does not accept a channel name.
    # Setting a channel ID here for consistency is highly recommended.
    channel-id: "CHANNEL_ID"
    payload: |
      {
        "text": "Deployment started (In Progress)",
        "attachments": [
          {
            "pretext": "Deployment started",
            "color": "dbab09",
            "fields": [
              {
                "title": "Status",
                "short": true,
                "value": "In Progress"
              }
            ]
          }
        ]
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- uses: slackapi/[email protected]
  with:
    # Unlike the step posting a new message, this step does not accept a channel name.
    # Please use a channel ID, not a name here.
    channel-id: "CHANNEL_ID"
    update-ts: ${{ steps.slack.outputs.ts }}
    payload: |
      {
        "text": "Deployment finished (Completed)",
        "attachments": [
          {
            "pretext": "Deployment finished",
            "color": "28a745",
            "fields": [
              {
                "title": "Status",
                "short": true,
                "value": "Completed"
              }
            ]
          }
        ]
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Reply to a message

If you want to post a message as a threaded reply, you can populate the payload with a thread_ts field. This field should equal the ts value of the parent message of the thread. If you want to reply to a message previously posted by this Action, you can use the ts output provided as the thread_ts of a consequent threaded reply, e.g. "thread_ts": "${{ steps.deployment_message.outputs.ts }}".

Please note that reply to a message does not accept a channel name. Set a channel ID for the actions that reply to messages in thread.

- id: deployment_message
  uses: slackapi/[email protected]
  with:
    channel-id: "CHANNEL_ID"
    payload: |
      {
        "text": "Deployment started (In Progress)"
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- uses: slackapi/[email protected]
  with:
    # Unlike the step posting a new message, this step does not accept a channel name.
    # Please use a channel ID, not a name here.
    channel-id: "CHANNEL_ID"
    payload: |
      {
        "thread_ts": "${{ steps.deployment_message.outputs.ts }}",
        "text": "Deployment finished (Completed)"
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Technique 3: Slack Incoming Webhook

This approach allows your GitHub Actions job to post a message to a Slack channel or direct message by utilizing Incoming Webhooks.

Incoming Webhooks conform to the same rules and functionality as any of Slack's other messaging APIs. You can make your posted messages as simple as a single line of text, or make them really useful with interactive components. To make the message more expressive and useful use Block Kit to build and test visual components.

Setup

  • Create a Slack App for your workspace (alternatively use an existing app you have already created and installed).
  • Add the incoming-webhook bot scope under OAuth & Permissions.
  • Install the app to your workspace (you will select a channel to notify).
  • Activate and create a new webhook under Incoming Webhooks.
  • Copy the Webhook URL from the Webhook you just generated add it as a secret in your repo settings named SLACK_WEBHOOK_URL.

Usage

- name: Send custom JSON data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  with:
    # For posting a rich message using Block Kit
    payload: |
      {
        "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
        "blocks": [
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
            }
          }
        ]
      }
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
    SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

HTTPS Proxy

If you need to use a proxy to connect with Slack, you can use the HTTPS_PROXY (or https_proxy) environment variable. In this example we use the Slack App technique, but configuring a proxy works the same way for all of them:

- name: Post to a Slack channel via a proxy
  id: slack
  uses: slackapi/[email protected]
  with:
    channel-id: 'CHANNEL_ID'
    slack-message: 'This message was sent through a proxy'
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
    # Set the HTTPS_PROXY environment variable to whatever your policy requires
    HTTPS_PROXY: 'http://proxy.example.org:8080'

Contributing

See CONTRIBUTING.

License

See LICENSE.

slack-github-action's People

Contributors

cageyv avatar cclauss avatar ddzz avatar dependabot[bot] avatar desrosj avatar ehitchcockiag avatar filmaj avatar hello-ashleyintech avatar jonboulle avatar koki-develop avatar kuboon avatar kyledecot avatar lulzneko avatar m5kr1pka avatar maso7 avatar mwbrooks avatar paulo9mv avatar quinnjn avatar raihle avatar robzr avatar ryan-williams avatar rzumer avatar seratch avatar srajiang avatar stevengill avatar talgendler avatar treemmett avatar umbertix avatar williambergamin avatar zimeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-github-action's Issues

UnhandledPromiseRejectionWarning: Error: Request failed with status code 400

Description

Getting error while using

- name: Send GitHub Action trigger data to Slack workflow
  id: slack
  uses: slackapi/[email protected]
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

node:1549) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
no custom payload was passed in, using default payload that triggered the GitHub Action
    at createError (/home/runner/work/_actions/slackapi/slack-github-action/v1.14.0/dist/index.js:8314:15)
    at settle (/home/runner/work/_actions/slackapi/slack-github-action/v1.14.0/dist/index.js:8573:12)
axios post failed, double check the payload being sent includes the keys Slack expects
    at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/slackapi/slack-github-action/v1.14.0/dist/index.js:7703:11)
{
    at IncomingMessage.emit (events.js:215:7)
  action: 'completed',
    at endReadableNT (_stream_readable.js:1184:12)
  organization: {
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    avatar_url: 'https://avatars.githubusercontent.com/u/********?v=4',
(node:1549) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
    description: 'Publisher of academic abesjgr, books, media and information',
(node:1549) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    events_url: 'https://api.github.com/orgs/

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

channel-id with environmental variable

Description

can Channel_ID be set using an environmental variable?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • [x ] question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • [ x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

my workflow YAML

- name: Post to Slack
        id: slackinitial     
        uses: slackapi/[email protected]
        with:
          channel-id: $env:channel_name
          slack-message: ""I am a Test message"
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
          channel_name: ${{ github.event.client_payload.channel_name }}

Expected result:

channel-id will pickup the environmental variable. Looking at the output the environmental variable is being picked up but channel-id I guess only takes Strings literally.

Actual result:

`Run slackapi/[email protected]
  with:
    channel-id: $env:channel_name
    slack-message: "I am a Test message"
  env:
    SLACK_BOT_TOKEN: ***
    channel_name: test-channel
Error: Error: An API error occurred: channel_not_found`

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Unable to use action via workflow call (reusable workflow)

Description

I have no issue using this action via a push trigger, but when used as a workflow_call (i.e a reusable workflow), it doesn't work. I tested this both in a fork of the repo (see here) and in our own (private) repo. Same behavior in both.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.18.0

node version: n/a

OS version(s): n/a

Steps to reproduce:

  1. Create a workflow using the action (like this one) and set up Slack webhook URL as described in README
  2. Invoke it via a caller workflow (like the one linked above, in the description)
  3. Workflow fails to trigger in Slack, even though invoking the workflow defined in step one via push works just fine

Expected result:

Workflow should trigger in Slack

Actual result:

Workflow fails to trigger in Slack via workflow_call triggers

Log output

Logs
##[debug]Evaluating: secrets.SLACK_MOBILE_RELEASE_TRAIN_WEBHOOK
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SLACK_MOBILE_RELEASE_TRAIN_WEBHOOK'
##[debug]=> null
##[debug]Result: null
##[debug]Evaluating condition for step: 'Send a message to Mobile Release Train Webhook'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Send a message to Mobile Release Train Webhook
##[debug]Loading inputs
##[debug]Loading env
Run btrautmann/[email protected]
  with:
    payload: {
    "message": "Testing"
  }
  
  env:
    SLACK_WEBHOOK_URL: 

::set-output name=time::13:05:[2](https://github.com/btrautmann/slack-github-action/runs/6128937737?check_suite_focus=true#step:2:2)6 GMT+0000 (Coordinated Universal Time)
##[debug]='1[3](https://github.com/btrautmann/slack-github-action/runs/6128937737?check_suite_focus=true#step:2:3):0[5](https://github.com/btrautmann/slack-github-action/runs/6128937737?check_suite_focus=true#step:2:5):2[6](https://github.com/btrautmann/slack-github-action/runs/6128937737?check_suite_focus=true#step:2:6) GMT+0000 (Coordinated Universal Time)'
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Send a message to Mobile Release Train Webhook

Feat: Support `SLACK_COLOR` with `slack-message`

Description

When using a Slack App and the simple

with:
  channel-id: '123456789'
  slack-message: 'My message'

Syntax, setting SLACK_COLOR: ${{ job.status }} has no effect.

What type of issue is this?

  • enhancement (feature request)

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: slackapi/[email protected]'

Steps to reproduce:

Setup a job like this:

uses: slackapi/[email protected]
with:
  channel-id: '123456789'
  slack-message: "My message"
env:
   SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
   SLACK_COLOR: ${{ job.status }}

Expected result:

The message specified as slack-message gets posted to the channel and has a highlight color according to job.status.

Actual result:

No coloring is added

Attachements

image

missing_text_or_fallback_or_attachments

Description

Error: missing_text_or_fallback_or_attachments
Error: Request failed with status code 400

Include this as part of my github action and received the above error, tried with major versions as well

Read the SLACK_WEBHOOK_URL from my secret

- name: Send notify
        uses: slackapi/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

When updating a message it seems that Channel Name might not be allowed

Description

When updating a message it seems that Channel Name might not be allowed

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version: 16

OS version(s): Ubuntu 22.04

Steps to reproduce:

  1. Follow the instuctions here https://github.com/slackapi/slack-github-action#update-the-message
  2. Use a Channel Name

Expected result:

The message should be updated and the task should succeed

Actual result:

The "started" message is posted fine but the success and failure messages do not appear in Slack and the GitHub Action fails with

Error: An API error occurred: channel_not_found

Attachments:

Publish Workflow creates duplicate tags

Description

The publish workflow is created duplicate tags. The manual release steps creates a semver tag (e.g. v1.20.0) while the JasonEtco/build-and-tag-action action creates a second tag that's missing the patch (e.g. v1.20).

image

We may be able to fix this by specifying the tag name in the JasonEtco/build-and-tag-action action.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Action fails silently when the API call fails

Description

There may have been a network issue which causes an API call to fail. However, the workflow did not fail.
The workflow was using Slack Bot Token and a Channel ID while posting a payload.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Reproducible in:

package version: 1.16.0

node version:

OS version(s): Ubuntu 20

Steps to reproduce:

  1. With a step looking like this
  users: slackapi/[email protected]
  with:
    channel-id: XXXXX
    payload: {
    "text": "Some text",
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*Some text*"
        }
      }
    ]
  }
  env:
    SLACK_BOT_TOKEN: ***
  1. Not sure how you could simulate Slack API going down... I am guessing you want this line to raise an exception:
    await web.chat.postMessage({ channel: channelId, text: message, ...(payload || {}) });

It is worth noting that the said step runs fine many times, so I am pretty sure that the payload and parameters are set correctly.

Expected result:

The step causes the workflow to error

Actual result:

The workflow passes.

Attachments:

Error logged:


(node:2465) UnhandledPromiseRejectionWarning: Error: An API error occurred: fatal_error
    at Object.platformErrorFromResult (/home/runner/work/_actions/slackapi/slack-github-action/v1.16.0/dist/index.js:5082:33)
    at WebClient.apiCall (/home/runner/work/_actions/slackapi/slack-github-action/v1.16.0/dist/index.js:4685:28)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2465) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2465) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Upgrade to Node.js 16

Description

This repository uses Node.js 12 actions, which are deprecated. GitHub Actions recently began adding the following annotation warning all users of slackapi/slack-github-action:

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: slackapi/slack-github-action

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Github.context.payload fails JSON.parse if payload has newlines

payload = github.context.payload;

When the commit message has new lines, such as a squash merge, the JSON.parse will fail.

I suggest using JSON.stringify on the github.context.payload to make it properly encode it.

// Get the JSON webhook payload for the event that triggered the workflow
payload = JSON.stringify(github.context.payload, null, '\n');

At the very least the message might not read as well as the actual commit message, but it will actually send and not fail the action.

Cannot parse env info in the payload

Description

How can I parse the env info to the payload to have the dynamic notification?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
- name: Send notify
        if: steps.changes.outputs.interview == 'true'
        uses: slackapi/[email protected]
        with:
          payload: '{"attachments": [{"color": "#3AA3E3", "author_name": "Pull request submitted by \"${{ env.AUTHOR_NAME }}\"", "title": "\"${{ env.PR_TITLE }}\"", "title_link": "\"${{ env.PR_RUN_LINK }}\""}]}'
        env:
          SLACK_WEBHOOK_URL: ${{ SLACK_WEBHOOK_URL }}
          SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
          AUTHOR_NAME: $(jq --raw-output .pull_request.user.login $GITHUB_EVENT_PATH)
          AUTHOR_LINK: $(jq --raw-output .pull_request.user.html_url $GITHUB_EVENT_PATH)
          PR_TITLE: $(jq --raw-output .pull_request.title $GITHUB_EVENT_PATH)
          PR_RUN_LINK: $(jq --raw-output .pull_request.html_url $GITHUB_EVENT_PATH)
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

image

Logs, screenshots, screencast, sample project, funny gif, etc.

Cannot get the test array's browser or projectName to consistently populate when test.describe() is used

Description

summaryResults.tests[i].browser and summaryResults.tests[i].projectName are only populated when the suiteName for a test is the path of the test. when test.describe() is used and the suiteName is given, the browser and projectName are empty strings.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.23.0

node version: 16.x

OS version(s): n/a

Steps to reproduce:

  1. A test with the line test.describe('[some test suite title]')
  2. Run the test on any browser or project
  3. Browser and projectName will be blank for that test

Expected result:

Browser and projectName to be populated

Actual result:

Browser and projectName are empty strings in the test array object

Cannot use slack-message with incoming webhook.

Can we have support for using slack-message with incoming webhooks. Right now it seems that only payload key is supported.
The reason for this request is that for example for Pull Request notifications we ended up sometimes with malformed JSON object.

Support file as payload input

Description

It would be very nice if instead of having only the text payload option, the action could take a json file path input.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Escaping newlines

Description

It doesn't seem to be possible to put newlines in the Slack payload. Of course, I could be wrong/missing something.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: v1.18.0

(Github action)

Steps to reproduce:

Here's a sample: I'm trying to write a message to Slack for failed builds with the latest commit message. I've tried doing nothing, and escaping the newlines before putting it in the payload.

notify:
    if: ${{ always() && needs.test.result == 'failure' }} # always() seems to be needed
    needs: [ test ]
    runs-on: ubuntu-latest
    steps:
      - name: Prepare
        id: slack-prepare
        run: |
          COMMIT_MESSAGE="${{ github.event.head_commit.message }}"
          COMMIT_MESSAGE_TRIMMED=${COMMIT_MESSAGE//$'\n'/'%0A'}
          echo "::set-output name=commit-message::${COMMIT_MESSAGE}"
      - name: Notify
        uses: slackapi/[email protected]
        with:
          payload: |
            {
              "commit_hash": "${{ github.sha }}",
              "developer": "${{ github.actor }}",
              "commit_message": "${{  steps.slack-prepare.outputs.commit-message }}"
            }

Expected result:

Message to be sent with escaped new lines in the payload, and actual new lines in the slack client.

Actual result:

with:
    payload: {
    "commit_hash": "d5e25d0d0042"
    "developer": "aspin",
    "commit_message": "fix for spaces
  
  multiline"
  }
  
  env:
    SLACK_WEBHOOK_URL: ***
passed in payload was invalid JSON
Error: Error: Need to provide valid JSON payload

Github context is not properly referenced within the JSON payload template

Description

Github context is not properly referenced when using the workflow_run

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Create a workflow_run github action

Reproducible in:

package version: v1.18.0
node version: v16.13.0
OS version(s):

Steps to reproduce:

  1. create a Github Action running on the workflow_run events
  2. add a json template that uses ${{github.event.workflow_run.name}} for example
  3. fire the event, and the json template will not properly replace the github context

Example of my JSON template

{
  "text": "[Codebase News] - Pipeline is ๐Ÿ”ด",
  "attachments": [
    {
      "color": "#000",
      "blocks": [
        {
          "type": "section",
          "text": {
            "type": "mrkdwn",
            "text": "Pipeline is ๐Ÿ”ด on `master`."
          }
        },
        {
          "type": "section",
          "text": {
            "type": "mrkdwn",
            "text": "Workflow `${{github.event.workflow_run.name}}` requires extra attention. :warning:"
          }
        },
        {
          "type": "context",
          "elements": [
            {
              "type": "mrkdwn",
              "text": "More info here ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.github.event.workflow_run.run_id}}"
            }
          ]
        }
      ]
    }
  ]
}

Expected result:

I would expect for the JSON file to have in hand the entire provided github context corresponding to the workflow_run event triggers.

Actual result:

As you can see ${{github.event.workflow_run.name}} did not work as expected
image
Also the regular github context did not work as well, here
image

Side Node:

I looked into this issue #51, and was aware that the problem got fixed, but I tested it multiple times, it was not properly fixed.

payload-file-path broken

Description

This example does not work
image

My action

      - name: Notify success
        if: ${{ success() }}
        uses: slackapi/[email protected]
        with:
          payload-file-path: "./.github/workflows/payload-success.json"

My webhook url is set at the job level

jobs:
  tests:
    runs-on: ubuntu-latest
    env:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

I see this in logs

Warning: Unexpected input(s) 'payload-file-path', valid inputs are ['channel-id', 'slack-message', 'payload']

payload-file-path appears to be missing as an input here:
https://github.com/slackapi/slack-github-action/blob/main/action.yml

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.17.0

node version:

OS version(s):

Steps to reproduce:

  1. Create action with payload-file-path per example

Expected result:

Payload is used

Actual result:

Fails to send

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Support custom variable interpolation in payload JSON file

Description

With the current implementation, it seems like the only variables that can be interpolated into the message payload are the ones from the github context object. It'd be really helpful to be able to pass in custom variables besides just what's available in there. Ideally you'd be able to just use anything in the env object but it doesn't seem like the github actions SDK allows you to access that? In that case I'd propose allowing something like a vars input that, if provided, will be accessible in your payload. Something like:

action.yml

env:
  myCustomVar: abc123

...

- name: Post slack message
  id: slack
  uses: slackapi/[email protected]
  with:
    channel-id: ${{env.channel_id}}
    payload-file-path: "./my-payload.json"
    vars: |
      {
        myVar: ${{env.myCustomVar}},
        application: Backend
      } 

my-payload.json

{
  "text": "{{{vars.application}}} deploy - {{vars.myvar}}"
}

I'm happy to take a pass at the implementation but wanted to verify that this would be of interest first

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Add support to update messages

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

It would be great to add support for the chat.update endpoint. Idea came from trying to make better GHA deploy messages.

Something like:

- id: slack
  uses: slackapi/[email protected]
  with:
    channel-id: "#channel"
    payload: |
      {
        "attachments": [
          {
            "pretext": "Deployment started",
            "color": "dbab09",
            "fields": [
              {
                "title": "Status",
                "short": true,
                "value": "In Progress"
              }
            ]
          }
        ]
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}}
- uses: slackapi/[email protected]
  with:
    channel-id: "#channel"
    time: ${{ steps.slack.outputs.time }}
    payload: |
      {
        "attachments": [
          {
            "pretext": "Deployment finished",
            "color": "28a745",
            "fields": [
              {
                "title": "Status",
                "short": true,
                "value": "Completed"
              }
            ]
          }
        ]
      }
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}}

setting update-ts causes channel_not_found error

Description

Updating comments not working, just returns channel_not_found error

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

When trying to make a status comment and then update it, I repeatedly encounter "channel_not_found" errors when I have update-ts enabled. Removing the update-ts flag allows both messages through.

I have these permissions set:

 runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
      pull-requests: write

I have the following github action steps:

      - id: slack
        uses: slackapi/[email protected]
        with:
          channel-id: "test"
          slack-message: "starting test"
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}}

      - run: sleep 10
      - uses: slackapi/[email protected]
        with:
          channel-id: "test"
          update-ts: ${{ steps.slack.outputs.ts }}
          slack-message: "updated test"
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}}

This reliably fails for me with error described above.

Reproducible in:

package version: 1.21.0

OS version(s): ubuntu-latest

Steps to reproduce:

  1. Run github action with update-ts set to output of previous step

Expected result:

I expect this to update the existing message on Slack.

Actual result:

Fails to find channel (message?)

Attachments:

image

To be able to include a multiple line Github Commit Message in a payload. Currently gives an error: Need to provide valid JSON Payload

Description

I'm unable to use the Payload if I use a multiple line or otherwise JSON Breaking string. I would like to include a git commit message in an action ( for example ${{ github.event.head_commit.message }} ), but it will break with new lines or formatting in there.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.21.0

node version: 14

OS version(s): MacOS 12.5

Steps to reproduce:

  1. Create an action that uses a multiple line output, using the readme.md example:
    `- name: Post to a Slack channel
    id: slack
    uses: slackapi/[email protected]
    with:

    Slack channel id, channel name, or user id to post message.

    See also: https://api.slack.com/methods/chat.postMessage#channels

    channel-id: 'CHANNEL_ID'

    For posting a simple plain text message

    slack-message: "Git commit example: ${{github.event.head_commit.message }}\n it will be broken after here in the shell output"
    env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}`

  2. The output in the shell will look off. In the blocks example, I have this:

 {
        "type": "section",
        "fields": [
          {
            "type": "mrkdwn",
            "text": "*Type:*\nAndroid ๐Ÿค–"
          },
          {
            "type": "mrkdwn",
            "text": "*Build place:*\nBretts-MBP"
          }
        ]
      },
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*About this build*:\nCommit header
  
  This is a multiple line 
  commit message
  that might have some nice formatting?"
        }
      },
  1. The error will be: Error: Error: Need to provide valid JSON payload

Expected result:

What you expected to happen.
To be able to somehow put a commit message in the payload and show it to the user when posting a slack message.

Actual result:

What actually happened
Error: Error: Need to provide valid JSON payload

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

What does the "Slack App Route" allow for?

Description

The documentation here kinda tapers off. Can it be updated?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: *

node version: *

OS version(s): *

Steps to reproduce:

  1. Read the docs
  2. ???
  3. Actually there is no profit step ๐Ÿ˜ƒ

Expected result:

Me understanding the benefits of the Slack App Route.

Actual result:

Me asking what the benefits are in a GitHub issue.

Attachments:

This video of cats meowing always attracts my cat to it: https://www.youtube.com/watch?v=XgbkY3TkAHI

Consider Offering One or More Default Messages or Templates

Description

One thing I miss about CircleCI is the convenience of issuing Slack notifications. Their Slack orb has a few message templates that meet basic needs. It would be ideal to offer some sort of generic starting point. There has been an explosion of community-contributed Slack notification GitHub actions that may serve as a reference. I suspect the absence of a default message is the major deficiency of the official Slack GitHub Action that has led to its unpopularity relative to unofficial actions like rtCamp's.

What type of issue is this?

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Workarounds

Presently, we copy and paste the following pair of steps into each pertinent workflow:

      - name: Configure Slack notification.
        if: always()
        run: source ./.github/scripts/setSlackMessage.sh "${{ job.status }}"
      - name: Send Slack notification.
        if: always()
        uses: slackapi/[email protected]
        with:
          channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
          slack-message: ${{ env.SLACK_MESSAGE }}
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Here are the contents of .github/scripts/setSlackMessage.sh, which we copy into each pertinent repository:

 #!/bin/bash

set -e -u -f -o pipefail

# Sets the environment variable SLACK_MESSAGE to a string appropriate to send at
# the end of a workflow triggered by a pull_request or push event. Includes the
# given final status of the job in the message.
function setSlackMessage() {
  local repository_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
  local repository_link="<$repository_url|$GITHUB_REPOSITORY>"

  local workflow_url="$repository_url/actions/runs/$GITHUB_RUN_ID"
  local workflow_link="<$workflow_url|$GITHUB_WORKFLOW workflow>"

  local branch="${GITHUB_REF#refs/*/}"
  local pull_request_number event_info event_url
  if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
    pull_request_number="${branch%/*}"
    branch="$GITHUB_HEAD_REF"
    event_url="$repository_url/pull/$pull_request_number"
    event_info="<$event_url|#$pull_request_number> from"
  elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
    event_url="$repository_url/commit/$GITHUB_SHA"
    event_info="push of <$event_url|$GITHUB_SHA> to"
  else
    event_url="https://docs.github.com/en/actions/reference/events-that-trigger-workflows#$GITHUB_EVENT_NAME"
    event_info="unexpected <$event_url|$GITHUB_EVENT_NAME> event"
  fi

  local branch_url="$repository_url/commits/$branch"
  local branch_link="<$branch_url|$branch>"

  local slack_message="$workflow_link *$1* for $event_info $branch_link on $repository_link by $GITHUB_ACTOR."
  echo "SLACK_MESSAGE=$slack_message" >>"$GITHUB_ENV"
}

setSlackMessage "$@"

`channel-id` should also be honored when using an incoming webhook

Description

A Slack incoming webhook specifies a channel to post to, by default. But it is possible to override that for every message sent. The slatify action, for example allows the user to override the default channel when using an incoming webhook.

This action does not do that.

I would expect that if I specify a channel-id, it will be honored regardless of whether I'm using an app token or an incoming webhook.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

"Create a slack app" link results in 404

Description

image

The link currently links to https://github.com/slackapi/slack-github-action/blob/main

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

payload-file-path does not respect env variables in the payload JSON file

Description

If you have variables embedded in payload-file-path JSON data, the variables won't be expanded.

You can do tests with the following:

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Passing an empty token or webhook url does not cause an error

Description

If SLACK_BOT_TOKEN or SLACK_WEBHOOK_URL is set to an empty string, the action will succeed.
Is this intentional?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: v1.21.0

node version:

OS version(s): ubuntu-22.04

Steps to reproduce:

  1. Set SLACK_BOT_TOKEN or SLACK_WEBHOOK_URL to an empty string
  2. Run workflow

Expected result:

Expect the action to fail.

Actual result:

The action will succeed.
Naturally, no message is sent.

Attachments:

Debugged in this repository: https://github.com/koki-develop/slack-github-action-debug

You can see that the action is not failing even though SLACK_BOT_TOKEN and SLACK_WEBHOOK_URL are set to empty characters or nonexistent secret.

Log: https://github.com/koki-develop/slack-github-action-debug/actions/runs/2991645944

      - uses: slackapi/[email protected]
        env:
          SLACK_WEBHOOK_URL: ""
      - uses: slackapi/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.NON_EXSISTENT_SECRET }}

https://github.com/koki-develop/slack-github-action-debug/blob/2fac0fd12078736e04359578a64b6e760faf86a6/.github/workflows/main.yml#L10-L15

Support user-id syntax

Description

As suggested in #41, this action could support the following syntax of user-id for improved clarity. Currently channel-id accepts either a Slack CHANNEL_ID or USER_ID.

- name: Post to a Slack channel
  id: slack
  uses: slackapi/[email protected]
  with:
    user-id: 'USER_ID' # currently channel-id field accepts either CHANNEL_ID or USER_ID
    slack-message: 'posting from a github action!'
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Related to

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Discussion about inactive 3rd party dependency projects

Description

I would suggest to remove the following libraries because they are not maintained since some years.

What type of issue is this?

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Allow step users to pass any json payload to webhook

Description

Currently, the webhook portion of this action takes the github.context.payload, flattens it and sends it to slack via webhook. We should allow developers to pass in any valid JSON payload to be sent to slack.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

How to mention whole channel on send message

Description

How can i mention an channel from a send message action? I tried hardwriting the @channel but it wont work.

      - name: Post to a Slack channel
        id: slack
        uses: slackapi/[email protected]
        with:
          channel-id: 'ID'
          slack-message: "mention @channel"
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SL}}

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Update of existing slack post does not work with channel name, only channel id

Description

When using update-ts: to update a previous action's slack post, the error Error: An API error occurred: channel_not_found is thrown.

The update works fine when using the channel ID, but does not work when using channel name.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

  1. Create subsequent actions like:
      - name: Post to a Slack channel
        id: slack
        uses: slackapi/[email protected]
        with:
          channel-id: '#mychannel'
          payload: |
            {
              "text": "first message"
            }
      - name: Update Existing Message in Slack
        id: slack_update
        uses: slackapi/[email protected]
        with:
          channel-id: '#mychannel'
          update-ts: ${{ steps.slack.outputs.ts }}
          payload: |
            {
              "text": "UPDATED MESSAGE"
            }
  1. Note: token set in env at global level
  2. Execute the workflow
  3. Notice first message is posted to slack
  4. Notice the slack post if never updated.
  5. Notice in github action page an error has occur with message: Error: An API error occurred: channel_not_found

Expected result:

Existing post is updated with the subsequent action.

Actual result:

Notice in github action page an error has occur with message: Error: An API error occurred: channel_not_found

Attachments:

Allow step users to pass any json payload to botToken to leverage blocks

Description

Currently, the botToken portion of this action takes a message and sends it to slack as text, while the webhook allows any valid JSON to be sent to slack. Providing the ability to send json to both action types allows developers to pass in any valid JSON payload to be sent to slack, which will allow them to leverage blocks within their bot or app.

I'd be happy to work this enhancement.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Missing quote in JSON_payload.yml

Description

Invalid yml in JSON_payload.yml. Also the values key on line 45 does not appear to be valid, but I'm new to GH actions and possibly missing something.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

How to setup the workflow variables correctly?

Description

How to set the variables in the Slack workflow, that the message looks formatted correctly?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Question

I have used your example json for Slack message and add all the variables into the my Slack workflow (Technique 1: Slack Workflow Builder). But the message in Slack looks like


#d90000
section
mrkdwn
Test workflow failed on $??? branch in the $??? repository!
divider
actions
button
plain_text
Build
true
$???/actions/runs/$???
button
plain_text
Commit
true
$???/commit/$73fbb9e6d939bbb7a0d709e27a64c415a667fbd2

The color and so on are not formatted correctly in Slack.

Support response output

Description

Action outputs API response, we can get thread_ts value in next steps.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Example

jobs:
  post:
    runs-on: ubuntu-latest
    env:
      SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

    steps:
      - uses: slackapi/[email protected]
        id: slack
        with:
          channel-id: '#general'
          slack-message: "Summary"
      - uses: slackapi/[email protected]
        with:
          channel-id: '#general'
          payload: |
            {
              "text": "Details",
              "thread_ts": "${{ fromJSON(steps.slack.outputs.response).ts }}"
            }

Add support for sending threaded messages

Description

Would like the ability to send a message into a thread by passing thread-ts from a previous message, with optional flag to broadcast the threaded message to the channel.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

There is a problem with the JSON payload path reference.

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.19.0

node version:

OS version(s): ubuntu: 20.04

Steps to reproduce:

Expected result:

JSON payload loads normally

Actual result:

image

image

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Action does not error when message could not be sent

Description

I'm new to Slack's APIs, and I only installed the action. I missed to install the new app to the channel I want it to send a message to, the PR at #5 would have saved me some time ;)

I wanted to let you know that although the error is logged to the output, the action still exists as if sending the message succeeded.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: latest

node version: any

OS version(s): any

Steps to reproduce:

  1. Create new slack app
  2. Install on workspace
  3. Without adding the app to a channel, try to send a message to it

Expected result:

Action should fail with helpful instructions

Actual result:

Error is logged, but exist status is still 0

Attachments:

Sorry I've re-ran the action and have no longer access to the run that failed

Feature request: send direct message to a user

Description

slackapi/slack-github-action can be used to send a message to a channel, but not to send message to a user by it's handle (@ndeloof)

What type of issue is this? (place an x in one of the [ ])

  • enhancement (feature request)

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Reproducible in:

package version: v1.16.0

node version: ?

OS version(s): github's ubuntu-latest hosted runner

Steps to reproduce:

  1. create github workflow to send notification to a specific user
      - name: Notify 
        uses: slackapi/[email protected]
        with:
          channel-id: '@ndeloof'          
          slack-message: '๐Ÿฆ„'
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Expected result:

Can send message to user (maybe using a distinct action parameter)

Actual result:

UnhandledPromiseRejectionWarning: Error: An API error occurred: channel_not_found

Attachments:

Sending a message with blocks fails

Description

Support for advanced notification to slack fails.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

When using Webhook trigger due to flatten function action fails is more complex messages.

flatten(payload) output:

{
  text: 'test',
  'blocks.0.type': 'section',
  'blocks.0.text.type': 'mrkdwn',
  'blocks.0.text.text': 'You have a new request: ',
  'blocks.1.type': 'section',
  'blocks.1.fields.0.type': 'mrkdwn',
  'blocks.1.fields.0.text': '*Type:* Computer (laptop)',
  'blocks.1.fields.1.type': 'mrkdwn',
  'blocks.1.fields.1.text': '*When:* Submitted Aut 10'
}

Steps to reproduce:

- name: Send Slack notification
  uses: slackapi/[email protected]
  env:
     SLACK_WEBHOOK_URL:  ***
  with:
     payload: '{"text":"test","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"You have a new request: "}},{"type":"section","fields":[{"type":"mrkdwn","text":"*Type:* Computer (laptop)"},{"type":"mrkdwn","text":"*When:* Submitted Aut 10"}]}]}'

Expected result:

What you expected to happen

**slackBotName**
You have a new request:
Type: Computer (laptop)        When: Submitted Aut 10

Actual result:

What actually happened

**slackBotName**
test

GitHub Actions: Deprecating set-output commands

Description

This repository uses the command set-output, which is deprecated. GitHub Actions recently began adding the following annotation warning all users of slackapi/slack-github-action:

Warning: The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

You should replace all command set-output (core.setOutput) with theGITHUB_OUTPUT environment variable (core.exportVariable)

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Fancy messages with Slack App Webhooks

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

I wanted to use this GitHub Action with Slack App Webhooks rather than Slack Workflows.
So that I could send fancy messages (built in https://app.slack.com/block-kit-builder/) right from GitHub.

But since payload is flattened (https://github.com/slackapi/slack-github-action/blob/main/index.js#L50-L54), it doesn't work.
Can it be configurable?

Message never gets sent to slack

Description

I can't rule out that it's me doing something wrong but i've tried this 100 ways it feels like and I can't understand where i'm going wrong.

I've verified that my webhook accepts the payload that is being sent through postman and the message does get posted.

I've read every line of source code in the repo, and i've determined i'm sending the POST and adding the time to the github outputs, and verify that the time is there in my action.

The check itself is green and has no signs that it didn't successfully complete.

The JSON i'm sending is what my workflow expects (it works if I manually curl/postman).

I've tried all three types of slack integrations, (webhook, workflow, bot).

I have no idea where the error is, there is no signs of an error. I've run the workflow on ubuntu and macos.

Again, I can manually POST to my webhook url.

I have added it as a secret in my repo/re generated urls/etc

Here is my action:

name: Slack Notify
        id: slack
        uses: slackapi/[email protected]
        with:
          payload: |
            {
              "author": "${{ github.event.pull_request.user.login }}",
              "title": "${{ github.event.pull_request.title }}",
              "status": "${{ job.status }}",
              "url": "${{ github.event.pull_request.html_url }}"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

I've compared this to the actions in this repo, the examples, etc.

I follow up this step with

      - run: test -n "${{ steps.slack.outputs.time }}"

Attached is the steps running:

Screen Shot 2022-02-01 at 9 52 52 AM

What type of issue is this? (place an x in one of the [ ])

  • [x ] bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

  1. Use above workflow step in a workflow
  2. Add a workflow

Expected result:

The post to get sent to slack and post the message

Actual result:

The post seemingly is never sent to slack although the action passes.

Support multiple channel IDs

Description

The channel-id input supports a single channel ID. Can this be updated to support multiple comma-separated channel ID's?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Axios Post Request fails behind HTTP Proxy

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

When Axios POSTs the request to HTTPS webhook (to trigger Slack Workflow) on a Github Runner acting behind a HTTP proxy, the request will hang forever. This is due to an outstanding Axios bug which hasn't been fixed.

Reproducible in:

package version: 1.22.0

node version: 16.14.2

OS version(s): Amazon Linux 2

Steps to reproduce:

  1. Configure Slack workflow and add SLACK_WEBHOOK_URL to Github Secrets.
  2. Trigger slackapi/slack-github-action in Github Agent running an HTTP proxy configured with the HTTPS_PROXY environment variable.
    steps:
      - name: Send GitHub Action trigger data to Slack workflow
        id: slack
        uses: slackapi/[email protected]
        with:
          payload: |
            {
              "version": "1.0.0",
              "message": "This came from Github!"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Expected result:

Github Workflow passes and Webhook triggers Slack Workflow.

Actual result:

slackapi/slack-github-action runs forever in Github Workflow.

Attachments:

image

I was able to resolve this by configuring an https-proxy-agent when the request webhook uses HTTPS and the proxy uses HTTP. Link to PR in fork https://github.com/EHitchcockIAG/slack-github-action-debug/pull/2/files. Currently we are using the tag v1.23.0-alpha from the fork in our Github Workflows.

image

I'm not sure if this is an adequate solution by the team's standards. If this looks okay, I can add some tests and open a PR to main.

Action fails silently if SLACK_BOT_TOKEN is not set

Description

Action fails silently if SLACK_BOT_TOKEN is not set

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 1.15.0

node version: I don't think you should ask that, as it's configured in your own action.yml

OS version(s): ubuntu-latest

Steps to reproduce:

        env:
          SLACK_BOT_TOKEN: ${{ secrets.DOES_NOT_EXIST }}

Expected result:

Should error with a helpful message

Actual result:

No output, success status

Attachments:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.