GitHub Actions + Power Automate + Teams

GitHub Actions

GitHub Actions can be thought of as a workflow that runs when certain event occurs in GitHub. An event might be for e.g. someone pushes code to a repository, or someone creates an issue etc. When such events occur, we can run some tasks or actions — e.g. sending an email or deploying code to a site etc.

  1. Pass those issues to a Power Automate flow
  2. The flow then posts a message in a Teams channel and sends a notification

Power Automate

Let’s start by creating a flow. Note: We use a trigger that requires a premium license. So please make sure a right license has been purchased/subscribed to. (If premium features of Flow need to be avoided then we can think of using SharePoint list item triggers.)

  1. Save the flow so that it generates the HTTP POST URL in the first step. Please copy this URL as it will be needed later.

GitHub workflow

Now we need to create a workflow in GitHub which will send the required issues to the flow we created above.

  1. While running
  • Calls a GitHub action (anoopt/get-issues-and-call-flow) which will
  • Get all the issues that are open and have the label as ‘bug’
  • Build an object to hold all the issues and some other information
  • Post all the issues to the flow we created earlier
  1. Line number 18 — Please enter the flow HTTP POST URL that was copied in the previous section.

Performing a quick test

If a quick test needs to be performed, then please we need to update the trigger in the YAML file. To do that, please comment line number 4 and 6 and write “push” instead — which means every time a file is pushed, the workflow runs.

Other options for workflow

In the workflow above we are using a GitHub action which gets all the required issues and posts some JSON data (in a particular format) to a Flow. If this feels a bit restricted i.e. if the JSON format needs to be updated or say if the Flow can be skipped entirely then the following options can be looked at.

Details of the GitHub Action

The code for the get-issues-http-post GitHub Action is written in Typescript. The important file in the project is main.ts . This file has code to get issues of the repository where the workflow runs. This is done with the help of octokit client as shown in the code below.

Summary

GitHub Actions are very powerful and provide a fantastic ability to automate lot of tasks. In this post we have seen how we can communicate between GitHub and Teams via Actions and Power Automate. Communicating between GitHub and Microsoft 365 becomes much simpler as soon as Actions and Power Automate come into picture. Hope in future more and more workflows and actions get developed so that more and more tasks can be automated.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anoop

Anoop

154 Followers

Microsoft MVP. M365 Developer Architect at Content+Cloud.