Skip to content

Automatic Sync PRs for Github to ADO#4227

Open
benrr101 wants to merge 1 commit intomainfrom
dev/russellben/automate-sync-prs
Open

Automatic Sync PRs for Github to ADO#4227
benrr101 wants to merge 1 commit intomainfrom
dev/russellben/automate-sync-prs

Conversation

@benrr101
Copy link
Copy Markdown
Contributor

Completely untested, but considering there's competing PRs for what I've been assigned to work on as DRI, might as well just throw it out there. If people actually want this approach, I'll finish it up.

🤖

This is just a first draft from the 🤖

@benrr101 benrr101 added this to the 7.1.0-preview2 milestone Apr 22, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 20:06
@benrr101 benrr101 added the Area\Engineering Use this for issues that are targeted for changes in the 'eng' folder or build systems. label Apr 22, 2026
@benrr101 benrr101 requested a review from a team as a code owner April 22, 2026 20:06
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board 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 a new Azure DevOps pipeline intended to keep the ADO internal/main branch aligned with the public GitHub main branch by creating/updating an automation sync PR.

Changes:

  • Introduces a scheduled ADO YAML pipeline that fetches GitHub main, fast-forward checks internal/main, force-updates a sync branch, and creates/updates a PR with optional auto-complete.
  • Adds parameters for repo/branch targets and debug/auto-complete behavior.

Comment on lines +185 to +198
if [ -z "${pr_id}" ]; then
echo "Creating a new sync PR."
create_payload="$(python3 <<'PY'
import json
import os

print(json.dumps({
"sourceRefName": os.environ["SYNC_REF"],
"targetRefName": os.environ["TARGET_PR_REF"],
"title": os.environ["PR_TITLE"],
"description": os.environ["PR_DESCRIPTION"],
}))
PY
)"
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 Python heredoc used to build create_payload is not indented under the bash: | block (e.g., import json, import os, and the PY terminator are at YAML top-level). This makes the pipeline YAML invalid and will fail to parse. Indent the heredoc content/terminator so it stays inside the bash literal block, or switch to generating the JSON payload without a heredoc (e.g., python3 -c ...).

Copilot uses AI. Check for mistakes.
Comment on lines +222 to +242
import json
import os

payload = {
"title": os.environ["PR_TITLE"],
"description": os.environ["PR_DESCRIPTION"],
"completionOptions": {
"deleteSourceBranch": True,
"mergeStrategy": "rebase",
"transitionWorkItems": False,
},
}

requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "")
enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true"

if enable_auto_complete and requested_for_id:
payload["autoCompleteSetBy"] = {"id": requested_for_id}

print(json.dumps(payload))
PY
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.

Same YAML parsing issue for update_payload: the Python heredoc content (import json, import os, etc.) and PY terminator are not indented under the bash: | step, so they are treated as top-level YAML lines and break the pipeline definition. Indent the heredoc consistently within the bash block (or avoid heredocs).

Suggested change
import json
import os
payload = {
"title": os.environ["PR_TITLE"],
"description": os.environ["PR_DESCRIPTION"],
"completionOptions": {
"deleteSourceBranch": True,
"mergeStrategy": "rebase",
"transitionWorkItems": False,
},
}
requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "")
enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true"
if enable_auto_complete and requested_for_id:
payload["autoCompleteSetBy"] = {"id": requested_for_id}
print(json.dumps(payload))
PY
import json
import os
payload = {
"title": os.environ["PR_TITLE"],
"description": os.environ["PR_DESCRIPTION"],
"completionOptions": {
"deleteSourceBranch": True,
"mergeStrategy": "rebase",
"transitionWorkItems": False,
},
}
requested_for_id = os.environ.get("BUILD_REQUESTEDFORID", "")
enable_auto_complete = os.environ.get("ENABLE_AUTO_COMPLETE", "false").lower() == "true"
if enable_auto_complete and requested_for_id:
payload["autoCompleteSetBy"] = {"id": requested_for_id}
print(json.dumps(payload))
PY

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +110
- bash: |
set -euo pipefail

if [ "${DEBUG_ENABLED}" = "true" ]; then
set -x
fi

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.

This pipeline inlines a fairly large/complex multi-step sync implementation inside a single bash: | block, which is brittle to YAML indentation issues (and already led to parsing errors in the heredocs below). Consider moving the logic into a checked-in script (e.g., under eng/pipelines/steps/ or a dedicated eng/scripts/ location) and invoking it from the YAML, to improve maintainability and reduce YAML fragility.

Copilot generated this review using guidance from repository custom instructions.
@cheenamalhotra
Copy link
Copy Markdown
Member

I got this: #4221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Engineering Use this for issues that are targeted for changes in the 'eng' folder or build systems.

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

3 participants