Skip to content

Github action to send message card to microsoft teams via webhook

License

Notifications You must be signed in to change notification settings

FreEZer00/teams-webhook-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Microsoft Teams Webhook Action

typescript-action status typescript-action status typescript-action status typescript-action status


What's included 🚀Setup 🛠️Sample 🖥️License 📓


What's included

  • Teams Webhook client
  • Supports for additional action buttons
  • Automatic status deduction from job/needs results
  • Dry run debugging option
  • Type safety

This action sends a defined message card to an incoming teams webhook.

Inspired by actions from Skitionek and homoluctus.

Setup

Configure the workflow

name: build
on:
  pull_request:

jobs:
  testJob:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v3
    - run: |
        exit 0
  build:
    name: Checkout and notify
    needs: [ TestJob ]
    if: ${{always()}}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v1
      - uses: freezer00/[email protected]
        with:
          webhook_url: ${{secrets.webhook}}
          needs: ${{ toJson(needs) }}
          job: ${{ toJson(job) }}
          title: Custom title
          additional_button_title: |-
            Link to Google
            Link to Microsoft
          additional_button_url: |-
            https://google.com
            https://www.microsoft.com/de-de/microsoft-teams
          hide_facts: false
          dry_run: false

Inputs

Input Required Description
webhook_url Required Teams Webhook - URL of the incoming webhook (should be store in secrets)
title Optional Custom title for the message card. Default Workflow \"<workflow-name/>\" ran with result <result/>
job Optional JSON formatted job toJson(job) (current job)
needs Optional JSON formatted needs toJson(needs) (previous required jobs)
additional_button_title Optional Multiline input for additional titles of potential actions on message card see test.yml)
additional_button_url Optional Multiline input for additional links of potential actions on message card see test.yml)
hide_facts Optional Keept the notification short and omit the facts (needs) in the message card (default false)
dry_run Optional Skip the sending of the webhook to Teams (default false)

Sample

example_image

License

The MIT License (MIT)