Skip to content

Commit bc4a291

Browse files
scbeddazure-sdk
authored andcommitted
this is backwards compatible. new callers can explicitly add login-to-github and pass the authtoken parameter
1 parent 73df99a commit bc4a291

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

eng/common/pipelines/templates/steps/create-pull-request.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Expects azuresdk-github-pat is set to the PAT for azure-sdk
2-
# Expects the buildtools to be cloned
1+
# Expects AuthToken to be a valid GitHub token.
2+
# Defaults to azuresdk-github-pat for backwards compatibility.
3+
# New callers should pass AuthToken: $(GH_TOKEN) after calling login-to-github.yml.
34

45
parameters:
56
BaseBranchName: $(Build.SourceBranch)
@@ -21,6 +22,10 @@ parameters:
2122
SkipCheckingForChanges: false
2223
CloseAfterOpenForTesting: false
2324
OpenAsDraft: false
25+
AuthToken: $(azuresdk-github-pat)
26+
# PushAuthToken: for cross-org pushes (pushing to PROwner's fork in a different org).
27+
# Defaults to AuthToken when not specified.
28+
PushAuthToken: ''
2429

2530
steps:
2631
- template: /eng/common/pipelines/templates/steps/git-push-changes.yml
@@ -34,6 +39,7 @@ steps:
3439
WorkingDirectory: ${{ parameters.WorkingDirectory }}
3540
ScriptDirectory: ${{ parameters.ScriptDirectory }}
3641
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
42+
AuthToken: ${{ coalesce(parameters.PushAuthToken, parameters.AuthToken) }}
3743

3844
- task: PowerShell@2
3945
displayName: Create pull request
@@ -48,7 +54,7 @@ steps:
4854
-BaseBranch "${{ parameters.BaseBranchName }}"
4955
-PROwner "${{ parameters.PROwner }}"
5056
-PRBranch "${{ parameters.PRBranchName }}"
51-
-AuthToken "$(azuresdk-github-pat)"
57+
-AuthToken "${{ parameters.AuthToken }}"
5258
-PRTitle "${{ parameters.PRTitle }}"
5359
-PRBody "${{ coalesce(parameters.PRBody, parameters.CommitMsg, parameters.PRTitle) }}"
5460
-PRLabels "${{ parameters.PRLabels }}"

eng/common/pipelines/templates/steps/create-tags-and-git-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
ScriptDirectory: eng/common/scripts
99
NpmConfigUserConfig: ''
1010
NpmConfigRegistry: ''
11+
AuthToken: $(azuresdk-github-pat)
1112

1213
steps:
1314
- task: PowerShell@2
@@ -24,7 +25,7 @@ steps:
2425
pwsh: true
2526
timeoutInMinutes: 5
2627
env:
27-
GH_TOKEN: $(azuresdk-github-pat)
28+
GH_TOKEN: ${{ parameters.AuthToken }}
2829
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
2930
${{ if ne(parameters.NpmConfigUserConfig, '') }}:
3031
npm_config_userconfig: ${{ parameters.NpmConfigUserConfig }}

eng/common/pipelines/templates/steps/git-push-changes.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
WorkingDirectory: $(System.DefaultWorkingDirectory)'
99
ScriptDirectory: eng/common/scripts
1010
SkipCheckingForChanges: false
11+
AuthToken: $(azuresdk-github-pat)
1112

1213
steps:
1314
- task: PowerShell@2
@@ -31,7 +32,7 @@ steps:
3132
- template: /eng/common/pipelines/templates/steps/emit-rate-limit-metrics.yml
3233
parameters:
3334
GitHubUser: azure-sdk
34-
GitHubToken: $(azuresdk-github-pat)
35+
GitHubToken: ${{ parameters.AuthToken }}
3536

3637
- task: PowerShell@2
3738
displayName: Push changes
@@ -43,6 +44,6 @@ steps:
4344
arguments: >
4445
-PRBranchName "${{ parameters.BaseRepoBranch }}"
4546
-CommitMsg "${{ parameters.CommitMsg }}"
46-
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
47+
-GitUrl "https://x-access-token:${{ parameters.AuthToken }}@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
4748
-PushArgs "${{ parameters.PushArgs }}"
4849
-SkipCommit $${{ parameters.SkipCheckingForChanges }}

0 commit comments

Comments
 (0)