Get notified for PnP updates from GitHub

Get notified for PnP updates from GitHub header image

During the CollabDays Netherlands 2022 I spend a few minutes listening to Luise Freese on Fluent UI design for Power Apps in Microsoft Teams. During those few minutes I witnessed a discussion on using GitHub stuff in your projects. One of the questions raised was how to stay up to date on new releases. Wether it was PnP community stuff or the Fluent UI design in both cases those building blocks can be beneficial for your projects. But what if new releases come out? How do you know when to update stuff? GitHub does support notifications for releases, but what if you are not using GitHub that often? Or want to use another medium for your notifications? I am using the Power Platform (or Logic Apps if you want to) to stay up to date for some of the packages I use often, so I ended up being voluntold to do a write-up on how to achieve this.

GitHub REST Api

If you are not a developer worry not. While you need the GitHub REST API there is not too much to configure. You can learn more about this API and what resources are available. If even that is a bridge to far the most important parts are as follows:

  • You do not need authentication for PnP as it is an open source repository
  • You can query for issues and releases, as well as adding additional filters to refine the results
  • The results returned are a max 100, if you need more it becomes a bit more complex as you need to loop through all results

Since our goal is to get the latest releases (or open issues for demo purposes) we do not really care about the maximum number of items. So figuring out what we need is just a single URL to get issues (or releases) from the repository that we are using.

Get notifications about issues

As a maintainer for the CLI for Microsoft 365 one of the repositories I use most often is https://github.com/pnp/cli-microsoft365/. Let’s assume we want to receive open issues, the REST URL for that is to use https://api.github.com/repos/pnp/cli-microsoft365/issues. Just a slight difference compared to the normal URL we get when using the browser: https://github.com/pnp/cli-microsoft365/issues. In our CLI sample we tweet about how many open issues and in the UI you can use filters like is:open or label:enhancement. For the REST API those are working slightly different as we need state=open and labels=good first issue as well as help wanted. So we end up with a URL looking as follows: https://api.github.com/repos/pnp/cli-microsoft365/issues?state=open&labels=good%20first%20issue,help%20wanted&per_page=100. If you are looking for issues only for docs you could add a label labels=docs. These labels differ per repo in PnP, so make sure to use the UI to figure out what is needed.

With that URL in place you can build a Flow or Logic App that retrieves the information you are looking for, in our case we run a Logic App once a week to tweet about the amount of outstanding issues for the CLI for Microsoft 🦾.

Call the GitHub Rest API from a Logic App

Notify about releases

Using this approach you can also retrieve the releases from a project. Let’s say you want to list all the releases for the PnP Modern Search web part. The URL needs to point to the correct repo and you can use /releases to get the releases. You can read about all the options available for releases if you want. In our case we need the latest major release, something you can achieve by adding /latest to your URL. Meaning the full URL would be https://api.github.com/repos/microsoft-search/pnp-modern-search/releases/latest. If you also want to include pre-releases you can use https://api.github.com/repos/microsoft-search/pnp-modern-search/releases and get the first item.

With that URL we can build a Logic App (or Flow) that retrieves the latest release. We can use that output to see if it is was published in the last 7 days, and if so we can send an e-mail.

Call the GitHub Rest API for releases from a Logic App

If you trigger the Logic App with a timer trigger that runs every week, we can use a condition where we use the published_at property of a release against the current time minus 7 days using addDays(utcNow(), -7) resulting in the following expression.

"expression": {
                    "and": [
                        {
                            "greater": [
                                "@parseDateTime(body('Get_Latest_Release')?['published_at'])",
                                "@addDays(utcNow(), -7)"
                            ]
                        }
                    ]
                }

By doing so we ensure that we only get a notification if the release has been published in the last seven days. You can use this info for changes made to whatever you like, wether it is issues or releases or even discussions. During Collab Days Luise Freese talked about the Fluent UI Teams Theme as part of the samples, so if you want to stay up to speed on those, all you need is the URL: https://github.com/pnp/powerapps-samples/tree/main/samples/fluentui-for-teams-theme and list all the commits to see if new stuff has been added https://api.github.com/repos/pnp/powerapps-samples/commits and put that in your Logic App to get notified whenever something new is added to the samples 🦾.

Loading comments…