GitHub App Install - Auto-Add New Repo
When a new Repo record is created in Dataverse, the flow calls Add Selected Repository To An Installation so CI/CD bots and Copilot tooling get immediate access without a manual sync step.
Overview
Event-driven bridge between Dataverse and GitHub. When a new repo record is created in the flowlibs_githubrepo table, the flow fires a repository_dispatch event to an orchestrator repo so a GitHub Actions workflow can add the repo to a specific GitHub App installation — then notifies the team in Teams.
Uses dispatch-event pattern because the GitHub connector does not expose AddSelectedRepositoryToInstallation directly. Stays connector-first instead of falling back to raw HTTP+PAT.
**State:** Built (Off by default)
Use Case
Teams that maintain dozens of repos and use a GitHub App (Copilot, CI automation, security scanners, Renovate) with *Selected repositories* installation scope have to manually check the new repo every time. Easy to forget — causes broken CI, missing bot reviews. This flow dispatches an event to an orchestrator workflow that runs with App credentials to add the repo, with Teams notification.
**Custom Dataverse Table:** flowlibs_githubrepo (entityset flowlibs_githubrepos) with name, repoowner, reponame, ghrepoid (BigInt) columns.
Flow Architecture
Trigger: **When a New Repo Is Added in Dataverse** (SubscribeWebhookTrigger on `flowlibs_githubrepo`, message=Create, scope=Organization). 1. Init 6 vars (orchestrator owner/repo, event type, installation ID, Teams group + channel) 2. **Get New Repo Row** (Dataverse GetItem) — re-fetches all columns 3. **Dispatch Add Repo To Installation Event** (GitHub CreateRepositoryDispatchEvent with client_payload = installation_id + repo details) 4. **Notify Teams Channel Of Dispatch** (Teams PostMessageToConversation HTML card)
Environment Variables
| Variable | Schema Name | Type | Default | Purpose |
|---|---|---|---|---|
| GitHub Orchestrator Owner | flowlibs_GitHubOrchestratorOwner | String | (none) | Org/user that owns the orchestrator repo |
| GitHub Orchestrator Repo | flowlibs_GitHubOrchestratorRepo | String | (none) | Name of the orchestrator repo |
| Dispatch Event Type | flowlibs_DispatchEventType | String | add-repo-to-installation | Custom event_type value |
| GitHub App Installation ID | flowlibs_GitHubAppInstallationId | String | (none) | GitHub App installation ID |
| Teams Group ID | flowlibs_TeamsGroupId | String | (none) | Teams team/group ID |
| Teams Channel ID | flowlibs_TeamsChannelId | String | (none) | Teams channel ID |
Connectors & Connections
| Connector | API Name | Connection Format | Usage |
|---|---|---|---|
| Microsoft Dataverse | shared_commondataserviceforapps | - | SubscribeWebhookTrigger + GetItem on flowlibs_githubrepo |
| GitHub | shared_github | - | CreateRepositoryDispatchEvent — fire typed dispatch |
| Microsoft Teams | shared_teams | - | PostMessageToConversation — HTML notification |
Customization Guide
1. Set 6 env vars per environment.
2. Bind connection refs.
3. Create the flowlibs_githubrepo table if not present.
4. Set up the orchestrator workflow .github/workflows/add-repo-to-installation.yml with actions/create-github-app-token@v1 to mint installation token.
5. Test by creating a flowlibs_githubrepo row and watching the workflow run.
**Common Modifications:** swap Teams for Slack/Email; route multiple installations via choice column + Switch; gate by branch policy compliance via SearchIssues; update Dataverse on success.
Key Expressions
- @triggerOutputs()?['body/flowlibs_githubrepoid'] — record ID
- @outputs('Get_New_Repo_Row')?['body/flowlibs_name'] — re-fetched fields
- @parameters('flowlibs_GitHubOrchestratorOwner') — env var read into Init
- body/client_payload — structured JSON merging variables with @{outputs(...)} expressions