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

how does one send a message with a snippet?

Open iamstarkov opened this issue 1 year ago • 1 comments

Description

I'd like to send a nice snippet of code in a message instead of markdown code block.

This is what I do now: Screenshot 2024-09-05 at 13 30 41

This is what I want: Screenshot 2024-09-05 at 13 31 02

Im not quite sure how to do it and will appreciate any guiding

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

  • [ ] bug
  • [x] 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.

iamstarkov avatar Sep 05 '24 11:09 iamstarkov

Hi @iamstarkov! 👋 Thanks for sharing the example! The second snippet is showing a file upload with a specific file type instead of block kit blocks or other formatting, which isn't yet possible, but it is good to know of some workaround for this right now.

Support for this is in progress (#333) and also tracked in #92, but let's keep this open since this seems like a useful case to have documented 📚 🙏

zimeg avatar Sep 25 '24 23:09 zimeg

This is now possible with the @2.0.0 release! Details on updating are included with that link, but a step like so might be helpful for sending snippets:

- name: Share a file to that channel
  uses: slackapi/[email protected]
  with:
    method: files.uploadV2
    token: ${{ secrets.SLACK_BOT_TOKEN }}
    payload: |
      channel: ${{ secrets.SLACK_CHANNEL_ID }}
      file: "./path/to/api.json"
      filename: "api.json"

I'm going to close this issue for now, but please feel free to comment with follow ups or open another whenever! 🙏

zimeg avatar Nov 15 '24 00:11 zimeg