Repository navigation
Description
Description
Describe your issue here.
After upgrading this action to version 2.0.0 you are no longer able to set the webhook type with an environment variable. I did not see a breaking change not
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.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version:
2.0.0
node version:
20
OS version(s):
Ubuntu
Steps to reproduce:
- Set up the action with the following code block
- name: Notify failure
env:
SLACK_CHANNEL_ID: "<slack channel>"
CURRENT_DATE: ${{ steps.getCurrentDate.outputs.CURRENT_DATE }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK.
uses: slackapi/slack-github-action@v2.0.0
with:
payload-file-path: ${{ env.SLACK_FAILURE_PAYLOAD_FILE_PATH }}
- Run it
Expected result:
A message is sent using as incoming webhook
Actual result:
Get an error of SlackError: Missing input! The webhook type must be 'incoming-webhook' or 'webhook-trigger'.
Attachments:
This could be changed in https://github.com/slackapi/slack-github-action/blob/main/src/config.js#L111 by changing it to webhookType: core.getInput("webhook-type") || process.env.SLACK_WEBHOOK_TYPE, which matches the environment variable that previously worked.
slack-github-action/src/slack-send.js
Lines 22 to 26 in 74ae656
| if (process.env.SLACK_WEBHOOK_TYPE) { | |
| // The default type is for Workflow Builder triggers. If you want to use this action for Incoming Webhooks, use | |
| // the corresponding type instead. | |
| webhookType = process.env.SLACK_WEBHOOK_TYPE.toUpperCase(); | |
| } |
Activity
zimeg commentedon Dec 4, 2024
Hey @jacob-white-simplisafe 👋 Thanks for writing in about this!
You're totally right to call this out as a breaking change in
v2.0.0- thewebhook-typeinput is a required input when sending withwebhook. A few lines on this were included in the release notes under breaking changes 📚The recommended approach is to now set this value with the step inputs:
I understand that using
envto set these values was a convenience fromv1, and using this environment variable was added after the initial release, but discussions from #221 have pointed us towardswithto add clarity to the inputs.Hoping this helps a bit, but I'm curious to know if the updated approach is alright or if
envcan be useful in more cases here. Open to discussing changes if so, so please let me know! 🙏jacob-white-simplisafe commentedon Dec 4, 2024
Thanks for the clarification!
I read the section of the release notes:
As it was now required to have the webhook-type set but didn't have to be only supplied with the
withstatement.For us, env is helpful because we have multiple jobs/steps where we are sending messages, so it was nice to be able to set the webhook type for all the steps. A more realistic example of how we use it is
Happy to close this out, if the decision was to require the use of
with.zimeg commentedon Dec 5, 2024
@jacob-white-simplisafe That example makes a ton of sense! 🙌
Despite being a bit more verbose, I do still think
withmakes each step more clear when making changes or adding other techniques. I'm hoping that's alright with your implementations!I'd also be super interested in learning about workflows where the
webhook-typemight change within a certain step, but that might not be so common...zimeg commentedon Dec 5, 2024
And thinking about the current
SLACK_TOKENandSLACK_WEBHOOK_URLvariables - we might have a not so ideal error happening with this:slack-github-action/src/config.js
Line 136 in c77439f
I'm thinking this
tokenneeds to be replaced withmethod(these are a required pairing) sincetokenandwebhookmight be set from environment variables shared throughout a workflow!Confirming this errors then I'll open a separate issue, but this pokes at a fear I have using environment variables 👻
jacob-white-simplisafe commentedon Dec 6, 2024
This sounds good to me. I agree it does make sense, and we can just use an environment variable to reduce repeating.
takirala commentedon Jun 13, 2025
@jacob-white-simplisafe Does this also mean that https://github.com/slackapi/slack-github-action/blob/v2.1.0/action.yml#L40
webhookis no longer an optional field ? I got this error: