SharePoint Doc to GitHub PR
When a policy markdown file is updated in SharePoint, the flow commits the change to a new branch in the docs repo and calls Create A Pull Request so the docs team reviews in the familiar GitHub workflow.
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 - SharePoint Doc to GitHub PR turns your SharePoint policy-docs library into a gated, review-first publishing pipeline. Whenever a markdown policy document is added or modified in the watched SharePoint library, the flow branches the target docs repository in GitHub, commits the updated file to that branch, opens a pull request, and emails the docs team a link to the PR so they can review in the familiar GitHub workflow before anything merges to the base branch.
The flow treats SharePoint as the authoring experience business users already know, and GitHub as the system of record for versioned, peer-reviewed documentation. No docs change goes live without a reviewer acknowledging it in GitHub.
Use Case
Policy and documentation teams that want SharePoint's editing experience but GitHub's review rigor.
The flow is ideal for teams that:
- Compliance teams publishing SOPs to a public docs site backed by GitHub Pages or MkDocs
- Internal knowledge bases where SMEs edit in SharePoint but engineering owns the downstream repo
- Audit-heavy environments where every doc change must produce a reviewer-signed PR artifact
- Migration away from direct-to-main doc commits toward a branch-and-review workflow
Flow Architecture
When a file is created or modified (properties only)
SharePoint - OnUpdatedFilesPolls the policy library every 5 minutes. splitOn is applied to the trigger body so each modified file runs through the flow independently.
Initialize variables
Initialize variableVariables initialize from environment variables (GitHub owner, repo, base branch, PAT, docs folder, notification recipient).
Compose file relative path
ComposeComposes the file's relative path inside the repo by stripping the SharePoint library prefix from the SharePoint server-relative path.
Compose new branch name
ComposeBuilds a unique branch name using the trimmed filename plus the flow's run ID so each run produces a distinct review branch.
Get a reference
GitHub - GetReferenceResolves the base branch's current head commit SHA, which seeds the new review branch.
Create a reference
GitHub - CreateReferenceCreates the new review branch from the base branch's head SHA.
Get existing file on base branch
HTTP - GETCalls the GitHub Contents API to check whether the file already exists on the base branch and capture the existing blob SHA. Uses runAfter [Succeeded, Failed] with a coalesce so brand-new files pass through unaffected.
Compose commit body
ComposeComposes the commit body containing base64-encoded file content, branch, commit message, and the existing SHA when present.
Commit file to new branch
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com/sites/Docs | Root URL of the SharePoint site that hosts the policy library. |
| flowlibs_DocsLibraryPath | String | /sites/Docs/FlowLibs - Policy Docs | Server-relative folder path watched by the trigger. |
| flowlibs_GitHubOwner | String | <configure> | GitHub account or organization that owns the docs repository. |
| flowlibs_DocsRepositoryName | String | policy-docs | Name of the docs repository the flow commits to. |
| flowlibs_DocsBaseBranch | String | main | Base branch that the pull request targets. |
| flowlibs_GitHubPAT | String (Secret) | <configure> | Fine-grained Personal Access Token scoped to the docs repo with Contents:write and Pull Requests:write. |
| flowlibs_DocsTeamEmail | String | alerts@yourcompany.com | Distribution address that receives PR notifications. Accepts a single address, distribution list, or comma-separated list. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SharePoint | shared_sharepointonline | OnUpdatedFiles (trigger) |
| GitHub | shared_github | GetReference CreateReference CreatePullRequest |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
| HTTP | built-in | GET (GitHub Contents API check for existing file blob SHA) PUT (GitHub Contents API commit of base64-encoded file content) |
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.
- Point at your own SharePoint library
- Create (or choose) a document library that will hold the policy markdown files. Update flowlibs_SharePointSiteURL to the site's URL and flowlibs_DocsLibraryPath to the server-relative path of the library. Open the designer, reselect the library from the trigger's dropdown so the dynamic schema refreshes, and save.
- Point at your own GitHub repo
- Create a fine-grained PAT scoped to the docs repo with Contents:write and Pull Requests:write. Update flowlibs_GitHubOwner, flowlibs_DocsRepositoryName, flowlibs_DocsBaseBranch, and flowlibs_GitHubPAT. Reauthorize the shared_github connection reference as a user with push rights on the repo.
- Change the notification recipient
- Update flowlibs_DocsTeamEmail to a new recipient (single address, distribution list, or comma-separated list). To change the email body, edit the Send_PR_Notification_Email action — the emailMessage/Subject and emailMessage/Body parameters are the two touch-points.
- Change the review cadence
- The trigger's recurrence block is Minute, interval 5. Tighten to Minute 1 for near-real-time review or loosen to Hour 1 for bulk batches.
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.01Compose file relative path
SharePoint server-relative path of the modified file.
EXPR.02Compose trimmed relative path
Strips the SharePoint library prefix so the remainder can be used as a repo-relative file path.
EXPR.03Compose new branch name
Produces a unique, workflow-run-scoped review branch.
EXPR.04Compose existing file SHA
Tolerates a 404 for new files while capturing the blob SHA on updates.
EXPR.05Commit file to new branch body
Base64-encodes the file content for the GitHub Contents API PUT.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.