Giter Club home page Giter Club logo

simple-ms-teams-webhook-notifier's Introduction

Simple MS Teams Webhook


A GitHub Action to send notifications to MS Teams using the syntax of Legacy Actionable Messages (Not all features yet).


Input Description Required Default
webhook_url Url generated by Incoming Webhook for MS Teams channel ✔️
summary Card summary
title Card title
text Card body text
theme-color Brand color card. Hexadecimal (without #).
You can use Success, Warning, Error and Info words as well
Success
sections For more information visit Sections fields.
This action uses yaml format in value as string. Some examples below.
potential-action For more information visit Actions.
This action uses yaml format in value as string. Some examples below.
yaml-ident This action uses YAML to parse the value of sections & potential-action to json properties.
This input configures the number of spaces used for the indentations.
2

Templates

Use them in title, summary, text and sections fields to easily display information

Syntax Description Output
{gh:actor} Return the username that runs the workflow UserName
{gh:actor-url} Returns the URL of the user who runs the program. https://github.com/UserName
{gh:avatar-url} Returns the avatar URL of the user who runs the program. https://avatars2.githubusercontent.com/u/123456789?v=4
{gh:run-number-link} Returns a link to the run id displaying run number #1 => https://github.com/user/repository/actions/runs/{run_id}

Examples

Send only basic fields

- name: run action
      id: run_action
      uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
      with: 
        webhook_url: ${{ secrets.WEBHOOK_URL }}
        summary: 'Card Summary'
        title: 'Card title'
        text: 'Card text'

Set hexadecimal theme color

- name: run action
      id: run_action
      uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
      with: 
        webhook_url: ${{ secrets.WEBHOOK_URL }}
        summary: 'Card Summary'
        title: 'Card title'
        text: 'Card text'
        theme-color: 'b405ff'

Set preset theme color

- name: run action
      id: run_action
      uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
      with: 
        webhook_url: ${{ secrets.WEBHOOK_URL }}
        summary: 'Card Summary'
        title: 'Card title'
        text: 'Card text'
        theme-color: 'Success'

Use sections (You can use the basic fields at the same time) and templates

- name: run action
      id: run_action
      uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
      with: 
        webhook_url: ${{ secrets.WEBHOOK_URL }}
        summary: 'Card Summary'
        title: 'Card Title'
        text: 'Card Text'
        sections: |
          - activityTitle: "Section title by {gh:actor}"
            activitySubtitle: "Section subtitle. Make click [here]({gh:actor-url}) to go to user profile"
            activityImage: "{gh:avatar-url}"
            facts:
              - name: 'Fact 1'
                value: 'Value 1'
              - name: 'Fact 2'
                value: 'Value 2'

Use potential action

- name: run action
      id: run_action
      uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
      with: 
        webhook_url: ${{ secrets.WEBHOOK_URL }}
        summary: 'Card Summary'
        title: 'Card Title'
        text: 'Card Text'
        potential-action: |
        	- "@type": "OpenUri"
	          name: "Open Executed Action"
	          targets:
	          	- os: "default"
	          	  uri: "https://docs.microsoft.com/outlook/actionable-messages"
	          

Note: To use special characters you must use double quotes " " in the property name. You can use double quotes in the values too.

simple-ms-teams-webhook-notifier's People

Contributors

luisghz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simple-ms-teams-webhook-notifier's Issues

Add support for node 16

Since nodejs v12 support has beeen deprecated by GH actions, can we upgrade node support to v16?

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: luisghz/[email protected]

html_url undefined when run from cron

Hello

I'm successfully using your notification script to send automated build notifications to our Teams dev channel, which has been received very well by everyone by the way - looks very professional, but find it errors if run from a cron schedule. I don't think it's anything I'm doing in setting it up but please let me know if it is. We have a physical remote Windows runner performing the actual build but I doubt that makes a difference.

My calling code (with redacted names) is:

on:
  # Run nightly builds @22:00 mon-fri on default 'develop' only
  schedule:
    - cron: "0 22 * * 1-5"

...

	- uses: luisghz/simple-ms-teams-webhook-notifier@v1-latest
	  if: failure()
	  with: 
		webhook_url: ${{ env.XXXX_NOTIFY_URI }}
		summary: "Autobuild Failed"
		theme-color: Error
		title: "XXXX Autobuild Failed   (${{env.XXXX_ACTOR}})"
		text: "For ${{env.XXXX_NOTIFY_BUILD}}"
		sections: |
		  - activityTitle: "[View build output](https://github.com/XXXX/actions/runs/${{ github.run_id }}) from ${{env.XXXX_BUILD_END}}"
			activitySubtitle: "Commit msg: **${{env.COMMIT_MSG}}**\n\nWorkflow and/or build error output files are available on GitHub."
			activityImage: "http://XXXX.png"

The workflow error output states:

Setup Ok
(node:10080) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'html_url' of undefined
    at new BuildCard (C:\actions-runner\_work\_actions\luisghz\simple-ms-teams-webhook-notifier\v1-latest\dist\index.js:13135:117)
    at C:\actions-runner\_work\_actions\luisghz\simple-ms-teams-webhook-notifier\v1-latest\dist\index.js:6394:27
    at Generator.next (<anonymous>)
    at fulfilled (C:\actions-runner\_work\_actions\luisghz\simple-ms-teams-webhook-notifier\v1-latest\dist\index.js:6348:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:10080) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10080) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and to my untrained js eye it looks like the html_url reference in C:\actions-runner_work_actions\luisghz\simple-ms-teams-webhook-notifier\v1-latest\dist\index.js is not available in the github context payload when run from a cron job.
Note: I'm not using the run-number-link in my script.

        this.regexReplacer = [
            { target: 'actor', replace: githubActor },
            { target: 'actor-url', replace: `https://github.com/${githubActor}` },
            { target: 'avatar-url', replace: `${process.env.avatar_url}` },
            { target: 'run-number-link', replace: `[#${githubContext.runNumber}](${githubContext.payload.repository.html_url}/actions/runs/${githubContext.runId})` }
        ];

Thanks
Al

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.