GitHub Actions — Create an Event with Microsoft Graph using MSAL

Example scenario

An example usage might be — when a pull request is submitted in the MAIN branch on the GitHub repository, an event is created in the repository owner’s calendar on the next day which contains the details of the pull request. The owner will get a reminder on the next day at the specified time and then the owner can review the pull request and can the required take action.


Firstly, if GitHub Actions are new to you, please have a quick look at this short video to understand what GitHub actions are and then have a look at this video by GitHub to understand more details.

Pre-requisites for using the action

App registration

Since the GitHub Action explained in this post uses Microsoft Graph, we need to create an app registration in Azure AD so that we can communicate with Office 365. To do that please follow the instructions mentioned in this video by Microsoft. Provide the app “Calendars.ReadWrite” permissions and create a client secret for that app.

Repository secrets

In the GitHub repository where this action will be used, create the following 3 secrets by navigating to “Settings > Secrets

  1. CLIENT_SECRET : A secret of the app registration created above.
  2. TENANT_ID : The Id of your Microsoft 365 tenant.

Using the action in workflow

In the GitHub repository, click on “Actions”. GitHub will recognize project type and will show us some predefined workflows which can be used. However, we will not use a predefined one and instead start from scratch. So click on “Set up a workflow yourself”.

Repo related to the action

The entire code of the action can be found here. Please feel free to fork it and make changes accordingly.


The same concept was used to create the “Create an event with Microsoft Graph using MSAL” action. Once the base setup is ready, we install the MSAL for node package

  1. date-fns package to help with the date related functionality


The repo contains 3 typescript files.

  1. graph.ts — Has methods to create an event in a person’s calendar with the help of Graph client.
  2. auth.ts — Makes use of MSAL to get an access token which will then be used by methods in graph.ts


What we have seen above is a simple action that uses the power of MSAL and Microsoft Graph to create an event. With Microsoft Graph there are endless possibilities that we can think of developing.



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



Microsoft MVP. M365 Developer Architect at Content+Cloud.