diff --git a/.github/actions/slack/action.yml b/.github/actions/slack/action.yml new file mode 100644 index 0000000..a4ed1b4 --- /dev/null +++ b/.github/actions/slack/action.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16c2f00..dd4e177 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }}