PR Title Normalizer
On PR create, if the title doesn't match the conventional-commits regex (feat:/fix:/docs:), calls Update A Pull Request to prepend the correct prefix based on changed paths and comments explaining the edit.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
FlowLibs - PR Title Normalizer is a scheduled Power Automate cloud flow that polls a GitHub repository every 15 minutes for open pull requests and rewrites any PR title that does not start with an approved conventional-commits prefix (such as feat:, fix:, docs:). When the flow finds a non-compliant title it prepends the configured default prefix and posts an explanation comment on the PR so the author understands the edit.
The flow is a reference demo. It ships in the Off state with a GitHub connection reference and four environment variables — turning it on in any tenant is a matter of authenticating the GitHub connection, setting the env var values, and enabling the flow.
Use Case
Teams that enforce conventional-commits in their PR history often end up manually fixing sloppy titles at merge time. This flow automates the normalization so the Git log stays consistent without blocking contributors or adding a required CI check. Because it runs on a schedule it also retroactively fixes PRs that were opened while the flow was offline.
Flow Architecture
Poll Every 15 Minutes
RecurrenceRecurrence trigger configured to fire every 15 minutes.
Initialize varGitHubOwner
Initialize variableString variable bound to the `flowlibs_GitHubOwner` environment variable.
Initialize varGitHubRepository
Initialize variableString variable bound to the `flowlibs_GitHubRepository` environment variable.
Initialize varValidPrefixes
Initialize variableString variable bound to `flowlibs_PrValidPrefixes` (comma-separated list, e.g. `feat,fix,docs,chore,refactor,test,perf,style,build,ci`).
Initialize varDefaultPrefix
Initialize variableString variable bound to `flowlibs_PrDefaultPrefix` (e.g. `chore`).
Build Open Pr Search Query
ComposeComposes the GitHub search query string `is:pr is:open repo:{owner}/{repo}`.
Search For Open Pull Requests
GitHub - SearchIssuesCalls the GitHub `SearchIssues` action and returns up to 30 open PRs sorted by newest.
For Each Pull Request
Apply to eachIterates over `coalesce(body('Search_For_Open_Pull_Requests')?['items'], body('Search_For_Open_Pull_Requests'))`. Inside the loop: composes the PR title, PR number, and a lowercase first-token prefix, then evaluates whether the title needs normalization.
Check If Title Needs Normalization
If conditionTrue only if the title contains `:` AND the first token is not in the valid-prefix list.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_GitHubOwner | String | <configure> | Owner or organization of the GitHub repository being monitored (e.g. `your-org`). |
| flowlibs_GitHubRepository | String | <configure> | Repository name without the owner prefix (e.g. `FlowLibs-Demo`). |
| flowlibs_PrValidPrefixes | String | feat,fix,docs,chore,refactor,test,perf,style,build,ci | Comma-separated list of prefixes that will be treated as already compliant. |
| flowlibs_PrDefaultPrefix | String | chore | Prefix prepended when a title does not match any valid prefix. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| GitHub | shared_github | SearchIssues (lists open PRs) UpdateAnIssue (rewrites the PR title) CreateAComment (posts the explanation comment) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Import the solution
- Bring the solution into the target environment — managed for end users, unmanaged for builders who want to extend the logic.
- Authenticate the GitHub connection reference
- Bind the new_sharedgithub_1719c connection reference to a GitHub account that has write access to PRs in the target repository. This is the account whose token will rewrite titles and post the explanation comment.
- Set the four environment variables
- Configure flowlibs_GitHubOwner, flowlibs_GitHubRepository, flowlibs_PrValidPrefixes, and flowlibs_PrDefaultPrefix for the target repository, your team's approved prefix list, and the default prefix to apply when none matches.
- Adjust the recurrence (optional)
- Default is every 15 minutes. Increase the interval if your repo has low PR throughput to stay well under GitHub API rate limits.
- Turn the flow On
- The solution ships with the flow Off — enable it in the target environment once the connection reference and env vars are in place.
- Optional extension: path-based prefix selection
- Instead of a static flowlibs_PrDefaultPrefix, swap in logic that inspects the PR's changed file paths (e.g. docs/** → docs, test/** → test) before falling back to the default. Keep the valid-prefix check in place so titles that already comply are never rewritten.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Build the GitHub search query
Builds the GitHub search query for open PRs scoped to the configured repo.
EXPR.02Coalesce the search response into an array
The GitHub `SearchIssues` connector returns `{ items: [...] }`, but the coalesce guards against alternate response shapes so the Foreach always receives an array.
EXPR.03Extract the first token of the PR title
Splits the title on `:`, takes the first segment, trims whitespace, and lowercases it so the comparison against `flowlibs_PrValidPrefixes` is case-insensitive.
EXPR.04Normalization gate condition
A title is normalized only if it contains a `:` (so it looks like it was trying to be conventional-commits) AND its first token is not already in the valid-prefix list. Titles with no `:` are left alone, which intentionally avoids rewriting `Release v1.2.3` style titles.
EXPR.05Prepend the default prefix
Prepends the configured default prefix to the original title. The original title is preserved verbatim after the prefix so no information is lost.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.