Open a ServiceNow change request when a production PR merges

By General Input

When a pull request labeled production-deploy is merged in GitHub, file the matching ServiceNow change request and post the CR number back into the PR thread.

Integrations

  • GitHub
  • ServiceNow

Type

Deterministic Code

Categories

  • Engineering
  • Operations

Build a code workflow that turns merged GitHub pull requests into ServiceNow change requests so our ITSM compliance is satisfied without forcing engineers out of their PR flow.

Trigger: a GitHub webhook for the pull_request event. Only run the workflow when action is closed, the pull request's merged field is true, and the PR carries a label named production-deploy (make the label configurable). Ignore all other pull_request events.

Step 1. Call GitHub's Get a Pull Request action using the repository owner, repo, and pull_number from the webhook payload. Pull title, body, user.login, user.email (or the head commit author email if user.email is null), html_url, base.ref, additions, deletions, and the commits list.

Step 2. Look up the merging engineer in ServiceNow. Use ServiceNow's List Users action on the sys_user table, filtered by email equal to the PR author email. Take the first result's sys_id as assigned_to. If no user is returned, leave assigned_to blank so the change manager can route it manually.

Step 3. Call ServiceNow's Create Change Request action with these field mappings: type = standard, short_description = PR title, description = PR body followed by a line that says "GitHub PR: {html_url}", implementation_plan = the PR body (or the section marked Implementation in the PR description if present), justification = any GitHub issue references parsed out of the PR body (for example, lines like "Closes #123"), assigned_to = the sys_id from step 2, planned_start_date = now in ServiceNow's expected datetime format. Capture the returned change request number (for example, CHG0030042) and its sys_id.

Step 4. Call GitHub's Create an Issue Comment action on the same pull request (issue_number = pull_number) with a short message like: "ServiceNow change request {number} opened for this deploy. Assigned to {author or 'change manager for routing'}." Include a link to the change request in ServiceNow if the instance URL is known.

Error handling: if the ServiceNow user lookup fails, still create the change request unassigned. If Create Change Request fails, post a comment on the PR explaining the failure so the engineer knows to file the change record manually. The whole pipeline is deterministic and there are no judgement calls, so ship it as a code workflow with discrete nodes.

Related prompts

Explore more prompts
Open a Heroku release war room the moment production looks wrongSee what Hacker News really thinks of the tools in your stackSee and fix Terraform variable drift across every workspaceA docs coverage board that catches what shipped undocumentedA technology radar board your architecture group works out ofTake-home review desk that runs candidate code in a sandboxDeploy control room for DigitalOcean App Platform appsClean up the Fly.io preview apps your team left behindFind the dbt models that are burning your warehouse budgetTranslation coverage board for your app's language files