Adding GitHub Reviewers with Power Automate

Adding GitHub Reviewers with Power Automate

As a software developer or a team lead, you know the importance of code reviews in ensuring the quality and maintainability of your codebase. However, managing and assigning reviewers for your GitHub pull requests can be a time-consuming and tedious task, especially if you have a large team or multiple projects to manage.

In addition, assigning reviewers by policy is not always sufficient, and manually assigning special reviewers does not scale. That’s why I want to introduce you to Power Automate, a powerful tool for automating tasks and streamlining workflows.

In this blog post, I’ll show you how to use Power Automate to automatically add GitHub reviewers. This is particularly useful when certain development tasks require special reviewers to ensure code quality. But let me explain this with my example use case.

Use Case: Adding GitHub Reviewers automated

Basically, when I create a pull request in GitHub, I need to make sure that all the assigned work items have been reviewed. By default, my pull requests are reviewed by a dedicated team based on a policy in GitHub. This is quite good but do not cover all my needs.

Some work items in my backlog are marked as critical using a tag or label. This means, the code must be reviewed by an additional expert from another team. This is important because these work items may have critical functionality that requires extra attention. As result I must add additional reviewers to review my pull request.

Here is an example of my manual process:

By automating this process, I can ensure that all additional reviewers are added. Furthermore, all necessary reviews are completed before merging my pull request. In the end, this automated process will save time and reduce the risk of manual errors.

Automate the Process

With Power Automate, adding GitHub reviewers automatically is easy for me. This is because I can react to newly created pull requests with a trigger. I can also check all assigned work items for special tags. When work items are marked as critical review, my flow add the required reviewers automatically. That makes my review process more efficient and streamlined.

Let my translate my initial process into a Power Automate flow. You see I have included new some API calls:

The reason is that Power Automate also needs to collect information for the process as I do manually.

GitHub Triggers in Power Automate

Let’s start with my trigger in Power Automate. The right standard trigger for GitHub is available. Therefore, I use the trigger When a pull request is created or modified (preview):

Once my trigger is added, I have to configure the parameters. In addition, I use 2 environment variables from my solution. The GRM GitHub Owner and GRM GitHub Repository variables are configured to my demo repository in GitHub. I also use a Scope as an action to simplify my trigger test:

As result, my Power Automate Flow reacts on my created pull request:

Note: The is at least one action needed to save and test a Power Automate Flow. I like to use an empty Scope action for this purpose.

Getting GitHub Pull Requests in Power Automate

As next step I have to get my Pull Request from GitHub. I choose the Get a pull request (preview) action from my GitHub actions. I also remove my Scope action to keep my example simple.

Now, I use the information provided by my Power Automate flow trigger as parameters for my newly added action:

Backlog REST API

In my next step, I want to collect information from my work items in my backlog. I do this because I want to identify additional reviewers. Good news for me, because my team already provides me with a serverless AWS Lambda function that returns all the required reviewers for a GitHub pull request.

The architecture of this microservice is quite simple:

A serverless Lambda Function get the backlog information directly from Atlassian Jira. Furthermore, the calculation of my needed reviewers is based on a configuration stored in a DynamoDB. In addition, the AWS API Gateway provides a public endpoint for my Power Automate Flow.

Today, I’m not creating a custom connector, I’m using the HTTP Request action. In detail, I call my AWS endpoint directly by a HTTP request:

I use again environment variables for my service URI and for my AWS Gateway X-API-Key. Additionally, my request body contains the URL of my GitHub pull request.

The result of my microservice contains all necessary reviewers. Here is an example:

    "reviewers": ["user_1", "user_2", ...]

As result, I can use these reviewers to update my pull request.

Request Review with GitHub REST API

Unfortunately, I can’t use a standard action to assign my reviewers on my GitHub pull request. This means, I use the Request Reviewers (GitHub API Documentation) from GitHub REST API.

Here is an example request, that adds a list of reviewers to my pull request:

Authorization: Basic user {{pat}}
Content-Type: application/json

    "reviewers": ["user_1", "user_2"]

There are still some calculations to do before I can add my reviewers from previous action response to my pull request. Yes, I must exclude the pull request owner from reviewers. I do this in a separate Scope in my Power Automate flow where I calculate the correct Reviewers for my pull request.

Finally, I’m using the HTTP Request action in Power Automate for this call and use the calculated Reviewers here as parameter:

Well done, my flow is ready to use.


To summarize, while adding GitHub reviewers manually may be an option, it can result in errors. On the other hand, using automatic policies to add reviewers is a common practice, but it may not always fit the unique needs of a development process.

In my case, I have created a Power Automate Flow to automatically add reviewers to pull requests based on certain tags on work items:

This solution has worked perfectly for me and demonstrates the versatility of Power Automate in automating business processes across various tools and technologies, as long as their APIs are accessible.

Comments are closed.