action-slack-notify icon indicating copy to clipboard operation
action-slack-notify copied to clipboard

Overwriting SLACK_MESSAGE

Open kyletozer opened this issue 5 years ago • 6 comments
trafficstars

I know the docs advise against doing this, but is there a way to do this at the moment with anything other than a plain text string? I would like to add a URL or interpolate another value such as an environment variable in this field if possible. In the case of passing a URL currently to SLACK_MESSAGE, the value output in slack is null.

Example: SLACK_MESSAGE: 'this is a test' Output on Slack: 'this is a test'

SLACK_MESSAGE: 'https://someurl.com' Output on Slack: null

Thanks!

kyletozer avatar Aug 24 '20 16:08 kyletozer

There are two ways to send URL in a message on slack via the webhook, and both are working with this action.

  1. Using the URL directly in the message: SLACK_MESSAGE: 'https://someurl.com' Output on Slack: https://someurl.com

  2. Hyperlinking text with a url: SLACK_MESSAGE: '<https://someurl.com|Some URL>' Output on Slack: Some URL

I test both of these and they are working as expected. So to debug the issue you are facing further, can you please share your workflow file?

Also, which version of the action are you using? If you are not using rtCamp/action-slack-notify@master or rtCamp/[email protected] I would advise you to use any one of these. Here @master always contains the latest stable version, which is v2.1.0 at the moment.

mrrobot47 avatar Aug 25 '20 04:08 mrrobot47

Hi @mrrobot47, I am currently using v2.1.0

Here is my config file, this is a standalone test I ran which when using your previous examples yielded the same output for me in Slack:

# The purpose of this workflow is for debugging actions/behavior of commands executed during steps
name: 'Debugging Workflow'

on:
  workflow_dispatch:
    inputs:
      logLevel:
        description: 'Log level'
        required: true
        default: 'warning'
      tags:
        description: 'Test scenario tags'

env:
  SLACK_WEBHOOK: '${{ secrets.SLACK_WEBHOOK }}'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  debug:
    name: 'Debug Things'
    runs-on: 'ubuntu-latest'
    steps:
      - name: 'Slack Notify'
        uses: rtCamp/[email protected]
        with:
          SLACK_MESSAGE: 'https://someurl.com'

      - name: 'Slack Notify'
        uses: rtCamp/[email protected]
        with:
          SLACK_MESSAGE: '<https://someurl.com|Some URL>'

Here is a screenshot of the Slack output: Screen Shot 2020-08-26 at 1 41 13 PM

kyletozer avatar Aug 26 '20 17:08 kyletozer

Also from that same run, the following error message was located in my CI output: ##[warning]Unexpected input(s) 'SLACK_MESSAGE', valid inputs are ['entryPoint', 'args']

kyletozer avatar Aug 28 '20 16:08 kyletozer

I would also like to be able to use env vars for example SLACK_MESSAGE: ':x: App ${BRANCH} failed tests'

patrickdizon avatar Oct 07 '20 19:10 patrickdizon

Hi there, In my side, I don't have the link on slack : A new <https:github.com|release> is available

FrancoisXavierNoe avatar Aug 23 '21 14:08 FrancoisXavierNoe

I would also like to be able to use env vars for example SLACK_MESSAGE: ':x: App ${BRANCH} failed tests'

Unfortunately, this appear not to be supported. Basic functionalities that one would expect to see even in maiden release!

barywhyte avatar Sep 14 '21 09:09 barywhyte