Skip to content

Commit

Permalink
Merge pull request #8 from L0RD-ZER0/feature/markdown
Browse files Browse the repository at this point in the history
Add markdown formatting for messages
  • Loading branch information
L0RD-ZER0 committed Mar 11, 2024
2 parents 9902697 + ab67f67 commit 45b2a0a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ SLACK_MESSAGE | Generated from git commit message. | The
SLACK_TITLE | Message | Title to use before main Slack message.
SLACK_FOOTER | Powered By rtCamp's GitHub Actions Library | Slack message footer.
MSG_MINIMAL | - | If set to `true`, removes: `Ref`, `Event`, `Actions URL` and `Commit` from the message. You can optionally whitelist any of these 4 removed values by passing it comma separated to the variable instead of `true`. (ex: `MSG_MINIMAL: event` or `MSG_MINIMAL: ref,actions url`, etc.)
SLACKIFY_MARKDOWN | - | If set to `true`, it will convert markdown to slack format. (ex: `*bold*` to `bold`) Note: This only works for custom messages and not for the default message generated by the action.
SLACK_THREAD_TS | - | If you want to send message in a thread, you can pass the timestamp of the parent message to this variable. You can get the timestamp of the parent message from the message URL in Slack. (ex: `SLACK_THREAD_TS: 1586130833.000100`)
SLACK_ON_SUCCESS | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `success`.
SLACK_ON_FAILURE | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `failure`.
SLACK_ON_CANCEL | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `cancelled`.
ENABLE_ESCAPES | - | If set to `true`, enables backslash escapes in the message such as '\n', '\t', etc.


You can see the action block with all variables as below:

```yml
Expand Down
27 changes: 25 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,31 @@ name: 'Slack Notify'
description: 'This action will send a notification to Slack'
author: 'rtCamp'
runs:
using: 'docker'
image: 'docker://ghcr.io/rtcamp/action-slack-notify:v2.2.1'
# using: 'docker'
# image: 'docker://ghcr.io/rtcamp/action-slack-notify:v2.2.1'
using: 'composite'
steps:
- name: "Slack-Markdown Conversion"
if: env.SLACKIFY_MARKDOWN == 'true'
id: slackify
uses: LoveToKnow/slackify-markdown-action@v1.0.2
with:
text: ${{ env.SLACK_MESSAGE }}

- name: "Update Message Variable (Formatted)"
if: env.SLACKIFY_MARKDOWN == 'true'
shell: sh
run: "echo 'SLACK_MESSAGE_FORMATTED=${{ steps.slackify.outputs.text }}' >> $GITHUB_ENV"

- name: "Update Message Variable (Unformatted)"
if: env.SLACKIFY_MARKDOWN == 'false'
shell: sh
run: "echo 'SLACK_MESSAGE_FORMATTED=${{ env.SLACK_MESSAGE }}' >> $GITHUB_ENV"

- name: "Slack Notification"
uses: rtCamp/action-slack-notify@v2.2.1
with:
SLACK_MESSAGE: "${{ env.SLACK_MESSAGE_FORMATTED }}"
branding:
icon: 'bell'
color: 'yellow'

0 comments on commit 45b2a0a

Please sign in to comment.