Skip to content

notify-microsoft-teams

Actions

About

Microsoft Teams Notification for Github Actions
v1.3.6
Latest
Star (96)

Notify Microsoft Teams

CI GitHub

Teams notify action inspired by git:lazy-actions/slatify (for Slack).

This is Microsoft Teams Notification for GitHub Actions.
Generated from actions/javascript-template.

ToC

Feature

  • Notify the result of GitHub Actions
  • Support all job statuses (reference: job-context)
  • Logs relevant jobs and steps along with their output in case of failure
  • Provides flexible interface to overwrite any part of the message
  • Allows sending raw json-formatted messages directly from action definition
  • Allows tagging msteams member

Usage

First of all, you need to set GitHub secrets for MSTEAMS_WEBHOOK that is Incoming Webhook URL.

You can customize the following parameters:

with parameter required/optional default description
webhook_url optional $MSTEAMS_WEBHOOK Microsoft Teams Incoming Webhooks URL
Please specify this key or MSTEAMS_WEBHOOK environment variable
job optional {}} JSON parsed job context
steps optional {} JSON parsed steps context
needs optional {} JSON parsed needs context
dry_run optional False Do not actually send the message
retries optional 0 Number of retries on Teams notification errors (non-negative integer)
raw optional '' JSON object to send to Microsoft Teams
title optional '' Overwrite default title
actions optional '' JSON array of Adaptive Card Action objects to replace the default Repository/Compare buttons
msteams_emails optional '' Microsoft teams email ids in CSV to tag in the message

When debug logging is enabled for GitHub Actions, this action emits additional debug details for notification attempts and failures. Debug mode is enabled when either ACTIONS_STEP_DEBUG=true or RUNNER_DEBUG=1 is set.

Please refer action.yml for more details.

Examples

name: Check notification

on:
  push: {}
  release: {}

jobs:
  success:
    name: One with everything
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
          needs: ${{ toJson(needs) }}
          job: ${{ toJson(job) }}
          steps: ${{ toJson(steps) }}
          retries: 2
          dry_run: True

  with_emails:
    name: One with emails
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: MSTeams Notification
        uses: ./
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
          title: '`Overwrote title in ${workflow_link}`'
          msteams_emails: 'mm@mm.mm, yy@yy.yy, rr@rr.rr'
          job: ${{ toJson(job) }}
          steps: ${{ toJson(steps) }}
          dry_run: ${{ !github.event.action == 'release' }}

  without_optional_params:
    name: One with little info
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}

  with_overwrite:
    name: One with overwrite
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
          title: '`Overwrote title in ${workflow_link}`'

  with_custom_actions:
    name: One with custom action buttons
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
          job: ${{ toJson(job) }}
          actions: >-
            [
              {
                "type": "Action.OpenUrl",
                "title": "View Run",
                "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
              },
              {
                "type": "Action.OpenUrl",
                "title": "Repository",
                "url": "https://github.com/${{ github.repository }}"
              }
            ]

  with_raw:
    name: One with raw data
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: always()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
          raw: >-
            {
                "type": "message",
                "attachments":
                [
                    {
                        "contentType": "application/vnd.microsoft.card.adaptive",
                        "content":
                        {
                            "type": "AdaptiveCard",
                            "body":
                            [
                                {
                                    "type": "TextBlock",
                                    "text": "Test title text"
                                }
                            ]
                        }
                    }
                ]
            }

  if_failure:
    name: Only if failure
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Microsoft Teams Notification
        uses: skitionek/notify-microsoft-teams@master
        if: failure()
        with:
          webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}

Microsoft Teams UI

Notification Preview 1 Notification Preview 2 Notification Preview 3 Notification Preview 4 Notification Preview 5 Notification Preview 6

Contribution

You are welcome to contribute in any form. I would gladly improve this package.

LICENSE

The MIT License (MIT)

notify-microsoft-teams is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Microsoft Teams Notification for Github Actions
v1.3.6
Latest

notify-microsoft-teams is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.