1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
# Expects azuresdk-github-pat is set to the PAT for azure-sdk
# Expects the buildtools to be cloned
parameters:
BaseBranchName: $(Build.SourceBranch)
PRBranchName: not-specified
PROwner: azure-sdk
CommitMsg: not-specified
RepoOwner: Azure
RepoName: $(Build.Repository.Name)
PushArgs:
WorkingDirectory: $(System.DefaultWorkingDirectory)
PRTitle: not-specified
PRBody: ''
ScriptDirectory: eng/common/scripts
GHReviewersVariable: ''
GHTeamReviewersVariable: ''
GHAssignessVariable: ''
# Multiple labels seperated by comma, e.g. "bug, APIView"
PRLabels: ''
SkipCheckingForChanges: false
CloseAfterOpenForTesting: false
steps:
- pwsh: |
echo "git add -A"
git add -A
echo "git diff --name-status --cached --exit-code"
git diff --name-status --cached --exit-code
if ($LastExitCode -ne 0) {
echo "##vso[task.setvariable variable=HasChanges]$true"
echo "Changes detected so setting HasChanges=true"
}
else {
echo "##vso[task.setvariable variable=HasChanges]$false"
echo "No changes so skipping code push"
}
displayName: Check for changes
condition: and(succeeded(), eq(${{ parameters.SkipCheckingForChanges }}, false))
workingDirectory: ${{ parameters.WorkingDirectory }}
ignoreLASTEXITCODE: true
- pwsh: |
# Remove the repo owner from the front of the repo name if it exists there
$repoName = "${{ parameters.RepoName }}" -replace "^${{ parameters.RepoOwner }}/", ""
echo "##vso[task.setvariable variable=RepoNameWithoutOwner]$repoName"
echo "RepoName = $repoName"
displayName: Remove Repo Owner from Repo Name
condition: succeeded()
workingDirectory: ${{ parameters.WorkingDirectory }}
- task: PowerShell@2
displayName: Push changes
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
inputs:
pwsh: true
workingDirectory: ${{ parameters.WorkingDirectory }}
filePath: ${{ parameters.ScriptDirectory }}/git-branch-push.ps1
arguments: >
-PRBranchName "${{ parameters.PRBranchName }}"
-CommitMsg "${{ parameters.CommitMsg }}"
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/$(RepoNameWithoutOwner).git"
-PushArgs "${{ parameters.PushArgs }}"
-SkipCommit $${{ parameters.SkipCheckingForChanges }}
- task: PowerShell@2
displayName: Create pull request
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
inputs:
pwsh: true
workingDirectory: ${{ parameters.WorkingDirectory }}
filePath: ${{ parameters.ScriptDirectory }}/Submit-PullRequest.ps1
arguments: >
-RepoOwner "${{ parameters.RepoOwner }}"
-RepoName "$(RepoNameWithoutOwner)"
-BaseBranch "${{ parameters.BaseBranchName }}"
-PROwner "${{ parameters.PROwner }}"
-PRBranch "${{ parameters.PRBranchName }}"
-AuthToken "$(azuresdk-github-pat)"
-PRTitle "${{ parameters.PRTitle }}"
-PRBody "${{ coalesce(parameters.PRBody, parameters.CommitMsg, parameters.PRTitle) }}"
-PRLabels "${{ parameters.PRLabels }}"
-UserReviewers "${{ parameters.GHReviewersVariable }}"
-TeamReviewers "${{ parameters.GHTeamReviewersVariable }}"
-Assignees "${{ parameters.GHAssignessVariable }}"
-CloseAfterOpenForTesting $${{ coalesce(parameters.CloseAfterOpenForTesting, 'false') }}
|