Skip to content

Commit

Permalink
Merge pull request #2 from ynab/db/reply-in-thread-support
Browse files Browse the repository at this point in the history
add ts output + support for sending threaded replies when posting
  • Loading branch information
dbertram authored Nov 6, 2024
2 parents 9ed9e1b + 52ad6b1 commit 3bb4412
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@ GitHub Action that posts a message to a Slack channel

**Required** The channel name to post to (example: `#general`)

#### `thread_ts`

**Optional** The timestamp ID of the parent message to reply to (e.g., the `ts` output from a previous Slack message call)

### `text`

**Required** The message text to post

## Outputs

### `ts`

The timestamp ID of the message (can be used to make subsequent Slack messages a threaded reply)

## Example usage

```yaml
Expand Down
17 changes: 14 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@ inputs:
required: false
channel:
description: "The channel name to post to"
required: true
required: true
thread_ts:
description: "The timestamp ID of the parent message to reply to"
required: false
text:
description: "The message text to post"
required: true
outputs:
ts:
description: "The timestamp ID of the message that was just posted"
branding:
icon: 'tag'
color: 'blue'
runs:
using: 'composite'
steps:
- run: |
curl --silent --show-error -X POST -H "Authorization: Bearer ${{ env.SLACK_BOT_TOKEN || inputs.token }}" -H "Content-Type: application/json" --url https://slack.com/api/chat.postMessage \
-d "{\"channel\": \"${{ inputs.channel }}\", \"text\":\"${{ inputs.text }}\"}"
{
echo "ts=<<EOF"
curl --silent --show-error -X POST -H "Authorization: Bearer ${{ env.SLACK_BOT_TOKEN || inputs.token }}" -H "Content-Type: application/json; charset=utf-8" --url https://slack.com/api/chat.postMessage \
-d "{\"channel\": \"${{ inputs.channel }}\", \"thread_ts\":\"${{ inputs.thread_ts }}\", \"text\":\"${{ inputs.text }}\"}" \
| jq --raw-output '.ts'
echo "EOF"
} >> "$GITHUB_OUTPUT"
shell: bash

0 comments on commit 3bb4412

Please sign in to comment.