diff --git a/OneBranchPipelines/github-ado-sync.yml b/OneBranchPipelines/github-ado-sync.yml deleted file mode 100644 index fd859b0a..00000000 --- a/OneBranchPipelines/github-ado-sync.yml +++ /dev/null @@ -1,138 +0,0 @@ -# GitHub-to-ADO Sync Pipeline -# Syncs main branch from public GitHub to internal Azure DevOps daily at 5pm IST -# -# SYNC STRATEGY RATIONALE: -# This pipeline uses a "replace-all" approach rather than traditional git merge/rebase because: -# 1. DIVERGENT HISTORY: ADO repository contains commits from early development that don't exist -# in GitHub. These historical commits were made before GitHub became the source of truth. -# 2. AVOIDING CONFLICTS: Standard git operations (merge, rebase, reset --hard) fail when -# repositories have divergent commit histories. Attempting to merge results in conflicts -# that cannot be automatically resolved. -# 3. IMPLEMENTATION: We use 'git fetch + git rm + git checkout' to completely replace ADO's -# working tree with GitHub's files without attempting to reconcile git history. This creates -# a clean sync commit that updates all files to match GitHub exactly. -# 4. CHANGE DETECTION: The pipeline checks if any files actually differ before creating PRs, -# avoiding unnecessary sync operations when repositories are already aligned. - -name: GitHub-Sync-$(Date:yyyyMMdd)$(Rev:.r) - -schedules: - - cron: "30 11 * * *" - displayName: "Daily sync at 5pm IST" - branches: - include: - - main - always: true - -trigger: none -pr: none - -jobs: -- job: SyncFromGitHub - displayName: 'Sync main branch from GitHub' - pool: - vmImage: 'windows-latest' - - steps: - - checkout: self - persistCredentials: true - - - task: CmdLine@2 - displayName: 'Add GitHub remote' - inputs: - script: | - git remote add github https://github.com/microsoft/mssql-python.git - git fetch github main - - - task: CmdLine@2 - displayName: 'Create timestamped sync branch' - inputs: - script: | - echo Getting current timestamp... - powershell -Command "Get-Date -Format 'yyyyMMdd-HHmmss'" > timestamp.txt - set /p TIMESTAMP= branchname.txt - echo Creating sync branch: %SYNC_BRANCH% - git checkout -b %SYNC_BRANCH% - echo ##vso[task.setvariable variable=SYNC_BRANCH;isOutput=true]%SYNC_BRANCH% - - - task: CmdLine@2 - displayName: 'Sync with GitHub main' - inputs: - script: | - echo Syncing with GitHub main... - git config user.email "sync@microsoft.com" - git config user.name "ADO Sync Bot" - - git fetch github main - git rm -rf . - git checkout github/main -- . - echo timestamp.txt >> .git\info\exclude - echo branchname.txt >> .git\info\exclude - git diff --cached --quiet - if %ERRORLEVEL% EQU 0 ( - echo No changes detected. Skipping commit. - echo ##vso[task.setvariable variable=HAS_CHANGES]false - ) else ( - echo Changes detected. Creating commit... - git add . && git commit -m "Sync from GitHub main" - echo ##vso[task.setvariable variable=HAS_CHANGES]true - ) - - - task: CmdLine@2 - displayName: 'Push branch to Azure DevOps' - condition: eq(variables['HAS_CHANGES'], 'true') - inputs: - script: | - set /p SYNC_BRANCH= pr_id.txt - set /p PR_ID=