Skip to content

Commit

Permalink
Improve message
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed May 23, 2024
1 parent 1bcc4dc commit 0d92ead
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/actions/slack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ inputs:
runs:
using: "composite"
steps:
- id: prepare_message
run: |
MESSAGE="${{ inputs.message }}"
MESSAGE="${MESSAGE//'%'/'%25'}"
MESSAGE="${MESSAGE//$'\n'/'\\n'}"
MESSAGE="${MESSAGE//$'\r'/'%0D'}"
echo "MESSAGE=$MESSAGE" >> $GITHUB_ENV
shell: bash

- uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ inputs.token }}
Expand All @@ -28,7 +37,7 @@ runs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ inputs.message }}"
"text": "${{ env.MESSAGE }}"
}
}
]
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,22 @@ jobs:
name: Notify success
uses: ./.github/actions/slack
with:
message: ":tada: Tests passed!"
message: >
:tada: Tests passed!
Branch: ${{ github.ref }}
Commit: ${{ github.sha }}
Workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
channel: ${{ vars.SLACK_CHANNEL_ID }}
token: ${{ secrets.SLACK_BOT_TOKEN }}

- if: ${{ needs.test.result == 'failure' }}
uses: ./.github/actions/slack
name: Notify failure
with:
message: ":red-light: Tests failed!"
message: >
:red-light: Tests failed!
Branch: ${{ github.ref }}
Commit: ${{ github.sha }}
Workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
channel: ${{ vars.SLACK_CHANNEL_ID }}
token: ${{ secrets.SLACK_BOT_TOKEN }}

0 comments on commit 0d92ead

Please sign in to comment.