archive / github-actions-slack

Github Action for sending message (and reactions/threads/update/blocks) to Slack - With support for Slack's optional arguments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add reaction to existing message

mmkal opened this issue Β· comments

Hi, great library!

We use this to send a message like

πŸš€ Deploying to production

Just before a deployment kicks off.

Since the slack-result output contains channel and timestamp fields, it'd be very useful to be able to add a βœ”οΈ emoji to the same message after the deployment is complete (or ❌ if it failed). I was imagining something like this, with a new method input corresponding to https://api.slack.com/methods/chat.postMessage, https://api.slack.com/methods/reactions.add etc.:

- id: notify
  uses: archive/github-actions-slack@v1.0.blah
  with:
    method: chat.postMessage # this would be the default method for backwards compatibility
    slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
    slack-channel: deployments
    slack-text: ':rocket: Deploying to production'

- run: ./deploy.sh

- uses: archive/github-actions-slack@v1.0.blah
  with:
    method: reactions.add
    slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
    slack-channel: ${{ steps.notify.outputs.slack-result.channel }}
    timestamp: ${{ steps.notify.outputs.slack-result.ts }}
    name: white_check_mark

Thanks @mmkal !

Sounds like a fantastic idea! The "method" solution will make the action more "conceptually" geeky to use, but hey, we are discussion github actions here - which is geeky per se :)

Would you like to try to PR this? I be happy to assist testing and review the solution. Otherwise I will look at it later tonight / this week.

Hi @archive - I'd like to but likely won't get a chance to for a week or so, so please don't hold off on my account if you do like the idea!

Will be included in v2.0

@archive amazing, thank you! Another thing occurred to me, although let me know if I should split out into its own issue:

The way you've implemented this, we could use the exact same technique to support thread replies. If the action looked at slack-message-timestamp even for post-message commands, it could be passed as a thread_ts value, allowing giving more detailed context than a reaction can.

Edit: looking more closely at the docs, this might already be possible with slack-optional-thread_ts. I'll try it out asap!

Yes. I added a sample for threads in the readme and actions