Open DSdatsme opened 1 year ago
Hi @DSdatsme 👋🏻 Thanks for reaching out!
I don't see an immediately problem after looking over your code sample and I see you've already tried slackapi/slack-github-action@v1.23.0
.
I'm going to setup an example to recreate your problem and I'll get back to you shortly! Thanks for your patience 🙇🏻
Hi @DSdatsme 👋🏻 🌙
I've setup an example repository that uses the Slack GitHub Action in 2 ways:
I can confirm that I was able to re-create your error with JSON Payload example.
I solved the problem by removing the values: |
property and instead referencing the values using the GitHub Context syntax (${{ <context> }}
):
Example: .github/workflows/slack-message-json.yml#L34-L36:
"text": "${{ github.sha }}"
},
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
I believe the examples are slightly out-of-date. They should not use the values:
property and instead they should use the new ${{ github }}
context syntax. I'll try to update those examples for us.
I'd recommend that you look at the examples in the README.md for Technique 2. They appear to be accurate and should unblock you.
Let me know how it goes!
Heya @mwbrooks , Thanks for the quick response on the issue.
My goal for using values
block was to pass on GitHub workflow inputs (workflow parameters) to slack message.
something like {{ inputs.UserInput1 }}
.
Currently, this action only supports github
context, I thought values
would be a good way to pass on other variables which are outside of github context.
Or maybe I'll have to wait for env
context implementation(PR 159) which looks like blocked due to test cases.
As a temporary workaround, I've forked this repo and implemented the env context and started using it for my actions.
Will have to wait until either values or env context feature is released, and any other better workaround you could suggest.
Hey @DSdatsme, thanks for the response and background on why you wanted to use values
.
Please checkout the Contexts documentation because GitHub Workflow inputs are also available: ${{ inputs }} and
${{ inputs.
Let me know if that helps! It would be ideal if you can use this repo instead of maintaining your own fork 😄
Hey @mwbrooks ,
Currently, this slack action does not support inputs
context.
Also, a lot of github
context variables do not work when I used them in payload json. I am unsure whether it's an issue with reading the file or I am missing out something.
I've created a PR to your example repo to explain this with an example.
github.actor
works whereas github.repository
or github.run_id
does not seem to work.
This is the payload template that I used
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \n GH actor: ${{ github.actor }},,,,,, GH Input: ${{ inputs.branch }}"
}
}
This is what I got as a slack message:
Unsure if you want to track it as a separate 2 issues or continue here.
1) not all github
context variables are working.
2) support for inputs
and other contexts.
@DSdatsme the issue around missing github
context variables for payload-file-path
are being tracked in #203!
Hey @zimeg , yes it's missing some context variables. Thanks for mentioning the issue, I see other folks have also faced the same issue.
As I mentioned above, as a workaround, I am using this patched version for myself. https://github.com/slackapi/slack-github-action/compare/main...DSdatsme:slack-github-action:main
Description
The GitHub actions are giving an error for the
values
field when being used. I've copied the sample code from here https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_2_Slack_App/JSON_payload.yml#L45-L47I am using the OAuth approach (approach 2) of the slack bot to send notifications to slack. Need to understand if I am missing something or if it's for another setup? because documentation does not mention anything about
values
field.What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Reproducible in:
package version: tested on
node version:
OS version(s): ubuntu-22.04 (github hosted runners)
Steps to reproduce:
Expected result:
values field should work
Actual result:
getting error
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.