Trigger GitHub’s “Repository Dispatch” Event From ServiceNow

--

Confluent allows users to perform various resource deployment and access provisioning tasks manually from the online portal. Our priority is always to take a code-first approach.

ServiceNow, our enterprise ITSM product, is crucial in managing various requests, from changes to break-fixes. To further enhance our efficiency, I’ve devised a process that leverages ServiceNow to trigger various GitHub Actions workflows that perform resource deployment and access provisioning tasks on the Confluent Kafka platform.

The process I developed leverages a GitHub event called repository_dispatch. In this blog post, I will explain how it works for creating topics on the Confluent Kafka platform.

ServiceNow sends this sample payload to our GitHub repo to get some topics created on the Confluent Kafka platform.

Note: Each activity (topic creation and modification, role binding, etc.) will have its payload.

https://api.github.com/repos/<GitHub org>/<GitHub repo>/dispatches is the API call made by ServiceNow. In the payload, event_type determines the GitHub Actions workflow for the topic creation activity.

Once the API call is made from ServiceNow, the appropriate GitHub Actions workflow will be triggered based on the value assigned to types. The types keyword limits the workflow to run when a specific event_type value is sent in the repository_dispatch webhook payload.

The workflow I developed runs these jobs on the payload from ServiceNow.

  1. Create a new branch in the GitHub repo and copy the payload to a .json file in that new branch.
  2. Modify the structure of the payload JSON file to make Terraform map creation easier. In Terraform, a map is a data structure that allows you to store key-value pairs. It is often used to group related values under a single variable, which makes configurations more organized and manageable.
  3. Create a Pull Request.

Once the Pull Request is created, a new GitHub Actions workflow will be triggered that runs the Terraform “Plan.”

My team reviews the “Plan” output and closes the Pull Request. Closing the PR pushes the code changes to the main branch, which triggers another GitHub Actions workflow that runs the Terraform “Apply.”

Disclaimer: The posts here represent my personal views, not those of my employer or any specific vendor. Any technical advice or instructions are based on my knowledge and experience.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Bharath నునేపల్లి
Bharath నునేపల్లి

Written by Bharath నునేపల్లి

Cloud & platform architect turned AI engineer. Passionate about data, scalable solutions, and leveraging AI/ML to solve real-world problems.

No responses yet

Write a response