diff --git a/import-repo.yml b/import-repo.yml new file mode 100644 index 0000000..4b98080 --- /dev/null +++ b/import-repo.yml @@ -0,0 +1,49 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +steps: +- checkout: self + clean: true + +- task: PowerShell@2 + inputs: + targetType: 'inline' + script: | + $devopsPAT = "$env:SYSTEM_ACCESSTOKEN" + $devopsProject = "pipeline_templates" + $githubOrg = "bordertech" + + git branch --remotes | findstr /v "\->" | ForEach-Object { + $br=$_.TrimStart(); git branch --track $br.TrimStart("origin/") $br + } + + $repoName = "$env:BUILD_REPOSITORY_NAME".split('/')[1] + echo $repoName + + $devopsRepoUri = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI".Substring(8) + "$devopsProject/_git/$repoName" + echo $devopsRepoUri + + $githubRepoUri = "github.com/$githubOrg/$repoName" + echo $githubRepoUri + + git remote add devops "https://$devopsPAT@$devopsRepoUri" + git branch --remotes | findstr /v "\->" | ForEach-Object { + $br=$_.TrimStart().Substring("origin/".Length) + Write-Host "Pushing $br to Azure DevOps" + git push -u devops $br + } + + git push devops --tags + + git remote remove devops + + env: + SYSTEM_ACCESSTOKEN: $(system.accesstoken)