Thursday, March 7, 2024

How to Integrate Slack with GitHub Actions | Slack Integration with GitHub Actions| Send Push notifications to Slack GitHub Actions

Integrating Slack with GitHub Actions for sending Notifications


How to integrate Slack with GitHub Actions

We will be using slack GitHub Action Slack integration action for posting messages to Slack channel from GitHub Actions.

We will be following below steps:

1. Create a new App in
2. Select workspace in the app
3.Select incoming webhooks
4. Activate incoming webhook
5. Add new webhook integration
6. Select channel, Allow
7. Copy the webhook url

Create App from scratch

Enter App name and pick a workspace
Click on incoming webhooks
Activate incoming webhooks, click on Add new webhook to workspace

Select the channel where you want to send notfications

Copy webhook url

Add Slack Webhook URL as Secret in GitHub Actions
Go to your GitHub Repo --> Settings --> 

Click on Secrets and Variables under Security in left nav 
Click new Repository Secret
Add SLACK_WEBHOOK_URL with value

Create GitHub Actions CICD workflow yaml:

Go to GitHub repo where your Java project is, create a new file:


name: cicd-workflow with slack integration
    branches: [ "master" ]
    runs-on: ubuntu-latest
    - uses: act10ns/slack@v2
        status: starting
        channel: '#mar-2024-weekend-batch'
        message: Starting Docker Build image...
      if: always()
    - uses: actions/checkout@v3
    - name: Build Docker image
      run: |
        docker build -t my-docker-repo .
    - uses: act10ns/slack@v2
        channel: '#mar-2024-weekday-batch'
        status: ${{ job.status }}
        steps: ${{ toJson(steps) }}
      if: always()

Watch Steps in YouTube channel:

No comments:

Post a Comment