Posting to Slack

December 12, 2024 ยท View on GitHub

๐Ÿ’™ This integration is available to sponsors.

This action can post the results to a channel in Slack. For example:

To configure the Slack integration:

  1. Create a webhook in your workspace (you must be a Slack admin). It should look like this: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX. Check out this tutorial if you have questions about getting the webhook URL.
  2. Set the slackWebhook (from the previous step) and slackChannel (don't forget to include the # character) parameters in this action.
  3. Ready to go!

Since it may be pretty annoying to receive a Slack notification every time someone creates a pull request, it is recommended to configure this action to be executed every while using the schedule trigger. For example, every Monday at 9am UTC:

name: Pull Request Stats

on:
  schedule:
    - cron:  '0 9 * * 1'

jobs:
  stats:
    runs-on: ubuntu-latest
    steps:
      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@main
        with:
          slackChannel: '#mystatschannel'
          slackWebhook: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
          # slackWebhook: ${{ secrets.SLACK_WEBHOOK }} You may want to store this value as a secret.