Thursday, March 27, 2025

how to send notification to teams channel github actions

 To send a notification to a Microsoft Teams channel from GitHub Actions, you can use an Incoming Webhook connector in Teams.


✅ Steps to configure it

1. Create Incoming Webhook in Teams

  1. Go to the desired Teams channel.

  2. Click ... (More options) > Connectors.

  3. Search for Incoming Webhook and click Configure.

  4. Give it a name (e.g., GitHub Actions Notification).

  5. Upload an image if you like.

  6. Click Create, and it will give you a Webhook URL.

  7. Copy this URL.


2. Add webhook URL as GitHub Secret

  1. Go to your GitHub repository.

  2. Settings > Secrets and variables > Actions > New repository secret.

  3. Name it, e.g., TEAMS_WEBHOOK_URL and paste the webhook URL.


3. Example GitHub Actions workflow to send notification

name: Notify Teams

on:
  push:
    branches:
      - main

jobs:
  notify:
    runs-on: ubuntu-latest

    steps:
    - name: Send notification to Microsoft Teams
      run: |
        curl -H 'Content-Type: application/json' \
        -d '{
              "title": "GitHub Actions Notification",
              "text": "A new push has been made to the main branch."
            }' \
        ${{ secrets.TEAMS_WEBHOOK_URL }}

✅ Tips:

  • You can customize the JSON payload as per Microsoft Teams message card schema.

  • You can make it dynamic using GitHub context variables like ${{ github.actor }}, ${{ github.event_name }}, ${{ github.sha }}.


Example with dynamic data:

- name: Notify Teams with commit info
  run: |
    curl -H 'Content-Type: application/json' \
    -d '{
          "title": "GitHub Actions Notification",
          "text": "New commit pushed by ${{ github.actor }} to branch ${{ github.ref_name }}. Commit: ${{ github.sha }}"
        }' \
    ${{ secrets.TEAMS_WEBHOOK_URL }}

If you want, I can also show you a fancier Teams message with colors, buttons, or more formatting. Just say yes, and I'll show you an advanced version.

If connectors not showing in above option. Then try below steps.


Ah, you're correct! Microsoft quietly moved or deprecated the "Connectors" option in many tenants (new Teams experience or some admin policies). But you can still add an Incoming Webhook, it's just slightly hidden now.


✅ Updated Method to add Incoming Webhook in 2024 Teams UI:

  1. Open Teams.

  2. Go to the target Channel.

  3. Click on the "..." (More options) next to the channel name (not the team).

  4. Click "Manage channel".

  5. Go to Apps tab.

  6. Click + Add an app.

  7. Search for Incoming Webhook.

  8. Click Add > then click Set up.

  9. Provide name and image (optional).

  10. Copy the generated Webhook URL.


Once you get the webhook URL, the GitHub Actions part I gave earlier works exactly the same.


🔄 Why you may not see it?

  • Your Teams Admin may have restricted Custom Apps or Connectors.

  • You're using New Teams UI (try switching back to Classic Teams temporarily and check).

  • You're in a Guest account (Guests can't manage connectors).

  • Microsoft is migrating more features to the new Apps tab per channel.



No comments:

Post a Comment