Skip to content

Setup autosync workflow#4221

Open
cheenamalhotra wants to merge 4 commits intomainfrom
dev/cheena/autosync
Open

Setup autosync workflow#4221
cheenamalhotra wants to merge 4 commits intomainfrom
dev/cheena/autosync

Conversation

@cheenamalhotra
Copy link
Copy Markdown
Member

Description

Introduces new pipeline that should trigger daily to open a PR or update a previously opened PR with latest commits from github's main branch.

Auto-Sync Pipeline build: https://dev.azure.com/SqlClientDrivers/ADO.Net/_build/results?buildId=148903&view=results

An exmaple PR is here: dotnet-sqlclient#7339

cheenamalhotra and others added 2 commits April 21, 2026 23:23
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 06:38
@cheenamalhotra cheenamalhotra requested a review from a team as a code owner April 22, 2026 06:38
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Apr 22, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview1 milestone Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Azure DevOps scheduled “autosync” pipeline that mirrors dotnet/SqlClient GitHub commits into the internal ADO repo by force-updating a dedicated sync branch and creating/updating an active PR to internal/main.

Changes:

  • Introduces a new ADO pipeline (github-sync-pipeline.yml) scheduled to run daily and callable manually.
  • Adds a PowerShell sync script that fetches GitHub commits, force-pushes to an ADO sync branch, then creates/updates an ADO PR and posts an update thread.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Implements Git fetch/force-push and ADO REST API PR create/update + comment posting.
eng/pipelines/github-sync-pipeline.yml Defines the scheduled pipeline job that runs the sync script with System.AccessToken.

Comment thread eng/pipelines/github-sync-pipeline.yml
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/github-sync-pipeline.yml Outdated
Copilot AI review requested due to automatic review settings April 22, 2026 07:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/github-sync-pipeline.yml
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Apr 22, 2026
@paulmedynski paulmedynski self-assigned this Apr 22, 2026
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1 Outdated
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/scripts/Sync-GitHubToAdo.ps1
Comment thread eng/pipelines/github-sync-pipeline.yml
@github-project-automation github-project-automation Bot moved this from In review to In progress in SqlClient Board Apr 22, 2026
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 20:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +184 to +199
# Check if the target branch exists and compare SHAs.
$targetRef = git rev-parse "origin/$TargetBranch" 2>&1
$targetExists = ($LASTEXITCODE -eq 0)

if ($targetExists) {
Write-Host "Target HEAD : $targetRef"
}

# Check if the sync branch already exists in origin.
$syncRef = git rev-parse "origin/$SyncBranchName" 2>&1
$syncBranchExists = ($LASTEXITCODE -eq 0)

if ($syncBranchExists -and $syncRef -eq $githubSha) {
Write-Host ""
Write-Host "Sync branch is already at GitHub HEAD. Nothing to do."
exit 0
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script compares against origin/$TargetBranch and origin/$SyncBranchName without explicitly fetching those refs. Because the pipeline allows overriding targetBranch/githubBranch at queue time, this can mis-detect branch existence or produce an incorrect commit summary if the agent checkout doesn’t have the requested remote refs. Consider doing an explicit git fetch origin (or git fetch origin $TargetBranch / $SyncBranchName) before the git rev-parse checks.

Copilot uses AI. Check for mistakes.
Comment on lines +184 to +195
# Check if the target branch exists and compare SHAs.
$targetRef = git rev-parse "origin/$TargetBranch" 2>&1
$targetExists = ($LASTEXITCODE -eq 0)

if ($targetExists) {
Write-Host "Target HEAD : $targetRef"
}

# Check if the sync branch already exists in origin.
$syncRef = git rev-parse "origin/$SyncBranchName" 2>&1
$syncBranchExists = ($LASTEXITCODE -eq 0)

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR/branch parameters are treated as short branch names (e.g., internal/main), but the script later prepends origin/ and refs/heads/ itself. If a caller passes a full ref (e.g., refs/heads/internal/main), git rev-parse "origin/$TargetBranch" and the REST targetRefName/sourceRefName values will be malformed. Consider validating/normalizing TargetBranch and SyncBranchName up front (strip a leading refs/heads/ or throw with a clear error).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants