Skip to content

Commit

Permalink
Merge pull request #3 from TonyCTHsu/slack-notif
Browse files Browse the repository at this point in the history
Add Slack notification action
  • Loading branch information
TonyCTHsu authored May 24, 2024
2 parents 740cc88 + 04128b8 commit d68eaaf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Slack Notification

description: 'Send slack notification'

inputs:
message:
description: 'Message to send'
required: true
channel:
description: 'Slack channel ID'
required: true
token:
description: 'Slack bot token'
required: true

runs:
using: "composite"
steps:
- uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ inputs.token }}
with:
channel-id: ${{ inputs.channel }}
slack-message: ${{ inputs.message }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,32 @@ jobs:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
DD_ENV: ci
run: bundle exec rake spec

notify:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- if: ${{ needs.test.result == 'success' }}
name: Notify success
uses: ./.github/actions/slack
with:
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!
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 d68eaaf

Please sign in to comment.