Scheduled Auto-Merge Window
Every Monday at 9am lists open PRs carrying the 'ready-to-merge' label, verifies checks are green, and merges each in priority order — creating a predictable weekly release-train cadence.
Overview
Weekly release-train automation. Every Monday at 9:00 AM Eastern, scans a target GitHub repository for open PRs tagged with a configurable "ready-to-merge" label, verifies each PR is mergeable, squash-merges qualifying PRs, and posts a consolidated summary to a Teams channel.
Environment-variable driven (no hard-coded orgs, repos, labels, Teams targets), ships in its own Dataverse solution, delivered Off so the importing tenant can review and activate.
**State:** Off (Stopped)
Use Case
Engineering teams that practice trunk-based development or have a weekly release-train cadence benefit from a predictable, low-ceremony merge window. Apply a ready-to-merge label to anything to ship this cycle. Flow handles the rest: gates on mergeability, squashes the history, broadcasts release notes to Teams.
Single run produces one Teams post with the full list of merged PRs — no spam throughout the week.
Flow Architecture
Trigger: **Every Monday At 9AM** (Recurrence Weekly Monday 09:00 ET).
1. Init 9 vars (org, repo, ready label, Teams group/channel, merge method='squash', merged count=0, merged summary='')
2. **Get Open Pull Requests** (GitHub GetPullRequests state=open)
3. **Filter PRs With Ready Label** (Filter array via `contains(string(item()['labels']), '"name":"<label>"')`)
4. **For Each Eligible PR**:
- Get Pull Request Details (needed for `mergeable` field)
- Check PR Is Mergeable (If `mergeable == true`)
- Yes: Merge Pull Request (squash) → Increment count → Append `<li>` to summary
- No: skip silently
5. **Post Summary To Teams** (HTML body with count + accumulated list)Environment Variables
| Variable | Schema Name | Type | Default | Purpose |
|---|---|---|---|---|
| FlowLibs GitHub Org | flowlibs_github_org | String | (none) | GitHub org or user that owns the target repo |
| FlowLibs GitHub Repo | flowlibs_github_repo | String | (none) | Repository name |
| FlowLibs Ready Label | flowlibs_ready_label | String | ready-to-merge | Label applied to PRs to merge this cycle |
| FlowLibs Teams Group Id | flowlibs_teams_group_id | String | (none) | GUID of the Teams team for the summary |
| FlowLibs Teams Channel Id | flowlibs_teams_channel_id | String | (none) | Channel ID inside the team |
Connectors & Connections
| Connector | API Name | Connection Format | Usage |
|---|---|---|---|
| GitHub | shared_github | OAuth | GetPullRequests + GetPullRequest + MergePullRequest |
| Microsoft Teams | shared_teams | OAuth | PostMessageToConversation (Flow bot) |
Customization Guide
1. Set 5 env vars (org, repo, label, Teams group/channel).
2. Bind GitHub + Teams connection refs.
3. Turn on.
**Common Modifications:** change merge strategy (merge or rebase); change schedule; tighten mergeability gate via mergeable_state == 'clean'; multi-repo via outer Foreach.
Key Expressions
- @contains(string(item()?['labels']), concat('"name":"', variables('varPRReadyLabel'), '"')) — Filter PRs by ready label
- @equals(body('Get_Pull_Request_Details')?['mergeable'], true) — mergeability gate (null-safe)
- @concat('<li>PR #', items('For_Each_Eligible_PR')?['number'], ' — ', items('For_Each_Eligible_PR')?['title'], '</li>') — summary accumulator