-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for unfurl_links + better logging #3
base: main
Are you sure you want to change the base?
Changes from 2 commits
a6cd17b
2cd262a
1f4882e
9cbadd2
8850891
a6ca8d4
37deab1
aaf89b0
a432e4c
921aa79
be9d6c9
58b1395
5d6132a
9be0fb1
6963330
9023265
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ inputs: | |
text: | ||
description: "The message text to post" | ||
required: true | ||
unfurl_links: | ||
description: "Whether links in the message should be unfurled" | ||
type: boolean | ||
default: true | ||
outputs: | ||
ts: | ||
description: "The timestamp ID of the message that was just posted" | ||
|
@@ -23,11 +27,17 @@ runs: | |
using: 'composite' | ||
steps: | ||
- run: | | ||
response=$(curl --fail-with-body --silent --show-error \ | ||
--request POST \ | ||
--header "Authorization: Bearer ${{ env.SLACK_BOT_TOKEN || inputs.token }}" \ | ||
--header "Content-Type: application/json; charset=utf-8" \ | ||
--url https://slack.com/api/chat.postMessage \ | ||
--data "{\"channel\": \"${{ inputs.channel }}\", \"thread_ts\": \"${{ inputs.thread_ts }}\", \"unfurl_links\": ${{ inputs.unfurl_links }}, \"text\": \"${{ inputs.text }}\"}" \ | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My goals with these changes are:
But I'm a total bash/curl newb, so please feel free to make suggestions! 🙏 |
||
echo "Slack API response:\n$response" | ||
{ | ||
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 "ts<<EOF" | ||
echo "$response" | jq --raw-output '.ts' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something about how I was trying to output the I was looking more closely at their examples for how to do multi-line output and noticed I had added the equal sign in ...but I'm not sure how test test this assumption before merging this PR. 😟 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could create a workflow in a throw-away repo that references this branch like this:
|
||
echo "EOF" | ||
} >> "$GITHUB_OUTPUT" | ||
shell: bash | ||
dbertram marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this default to true in Slack API if not provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their docs don't actually say what it defaults to, but my anecdotal testing seems to indicate yes