Created
March 20, 2024 22:07
-
-
Save sheldonhull/6a7886aeaad0c300f85290fa4437b576 to your computer and use it in GitHub Desktop.
example of azure devops cli + local automation using yq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'stop' | |
$OrgName = '' | |
$ProjectName = '' | |
$WorkItemID = 554287 | |
$GitRepoDir = Join-Path $HOME 'git' | |
$FileToEdit = 'build/myyamlfile.yaml' | |
az devops login --organization https://dev.azure.com/$OrgName | |
# Review matching files | |
rg 'deployment:' --glob '**/build.yaml' | |
# Repos to run through can be programmatic or manually set | |
$Repos = @( | |
) | |
foreach ($RepoName in $Repos) { | |
Set-Location $GitRepoDir | |
git config git-town.main-branch main | |
# git remote remove upstream | |
git switch main | |
git pull | |
Get-Content $FileToEdit -Raw | yq '.extends.parameters.deployment' | |
git town hack 'refactor/edit-file' | |
yq e 'del(.extends.parameters.deployment)' -i $FileToEdit | |
git add $FileToEdit | |
git commit -am'ci: remove deployment from build yaml' | |
git sync | |
& az repos pr create --title 'ci: remove deployment from build yaml' --detect false --auto-complete true --source-branch "$(git currentbranch)" --delete-source-branch true --target-branch 'main' --repository $(Get-Location | Split-Path -Leaf) --project $ProjectName --open --transition-work-items false --work-items $WorkItemID --output table --description 'Remove item from yaml via yq.' # --required-reviewers '' | |
Set-Location $GitRepoDir | |
gum confirm 'proceed?' | |
if ($LASTEXITCODE -ne 0) { | |
throw 'stopping' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment