Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add variables to SLACK_CUSTOM_PAYLOAD #205

Open
jdrcodes opened this issue Oct 18, 2024 · 1 comment
Open

Unable to add variables to SLACK_CUSTOM_PAYLOAD #205

jdrcodes opened this issue Oct 18, 2024 · 1 comment

Comments

@jdrcodes
Copy link

Hello!

I am trying to make an automation when a user creates a pull request that sends a message to a Slack Channel.

SLACK_CUSTOM_PAYLOAD only admits an string that has to be a JSON, but when I use variables it always returns an 400 error and it does not work, even though the log replaces correctly the variables.

SLACK_CUSTOM_PAYLOAD: | { "author": "${{ steps.set-payload.outputs.PAYLOAD_AUTHOR }}", "ticket_link": "Example text", "pr_link": "Example text", "description": "Example text", "title": "Example text" }

Log:

SLACK_CUSTOM_PAYLOAD: { "author": "jdrcodes", "ticket_link": "Example text", "pr_link": "Example text", "description": "Example text", "title": "Example text" }

Any ideas?

Error sending message: Error on message: 400 Bad Request

@L0RD-ZER0
Copy link
Collaborator

Hello there! I took a look at this payload and it doesn't seem quite right. Might help taking a look at Slack's Advanced Message Formatting, and for further reading, it might help looking at Slack's Message Payloads.

For some of the variables you're trying to set, there are equivalent environment variables such as for author, you can use SLACK_MSG_AUTHOR to specify author. You can find a reference list of all the variables in the readme.

You can specify them using environment variables in the following manner:

env:
    SLACK_MESSAGE_AUTHOR: "${{ steps.set-payload.outputs.PAYLOAD_AUTHOR }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants