Skip to content

Commit 539f954

Browse files
scbeddazure-sdk
authored andcommitted
update to add fallback to login. will need to approve serviceConnection for the new builds, but other than that, no impact
1 parent aa771e7 commit 539f954

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Expects AuthToken to be a valid GitHub token.
22
# Defaults to azuresdk-github-pat for backwards compatibility.
3-
# New callers should pass AuthToken: $(GH_TOKEN) after calling login-to-github.yml.
3+
# New callers should pass AuthToken: '' to auto-login via login-to-github.yml.
44

55
parameters:
66
BaseBranchName: $(Build.SourceBranch)
@@ -28,6 +28,13 @@ parameters:
2828
PushAuthToken: ''
2929

3030
steps:
31+
- ${{ if eq(parameters.AuthToken, '') }}:
32+
- template: /eng/common/pipelines/templates/steps/login-to-github.yml
33+
parameters:
34+
TokenOwners:
35+
- ${{ parameters.RepoOwner }}
36+
ScriptDirectory: ${{ parameters.ScriptDirectory }}
37+
3138
- template: /eng/common/pipelines/templates/steps/git-push-changes.yml
3239
parameters:
3340
BaseRepoBranch: ${{ parameters.PRBranchName }}
@@ -39,7 +46,7 @@ steps:
3946
WorkingDirectory: ${{ parameters.WorkingDirectory }}
4047
ScriptDirectory: ${{ parameters.ScriptDirectory }}
4148
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
42-
AuthToken: ${{ coalesce(parameters.PushAuthToken, parameters.AuthToken) }}
49+
AuthToken: ${{ coalesce(parameters.PushAuthToken, parameters.AuthToken, '$(GH_TOKEN)') }}
4350

4451
- task: PowerShell@2
4552
displayName: Create pull request
@@ -54,7 +61,7 @@ steps:
5461
-BaseBranch "${{ parameters.BaseBranchName }}"
5562
-PROwner "${{ parameters.PROwner }}"
5663
-PRBranch "${{ parameters.PRBranchName }}"
57-
-AuthToken "${{ parameters.AuthToken }}"
64+
-AuthToken "${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}"
5865
-PRTitle "${{ parameters.PRTitle }}"
5966
-PRBody "${{ coalesce(parameters.PRBody, parameters.CommitMsg, parameters.PRTitle) }}"
6067
-PRLabels "${{ parameters.PRLabels }}"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ parameters:
1111
AuthToken: $(azuresdk-github-pat)
1212

1313
steps:
14+
- ${{ if eq(parameters.AuthToken, '') }}:
15+
- template: /eng/common/pipelines/templates/steps/login-to-github.yml
16+
parameters:
17+
TokenOwners:
18+
- ${{ split(parameters.RepoId, '/')[0] }}
19+
ScriptDirectory: ${{ parameters.ScriptDirectory }}
20+
1421
- task: PowerShell@2
1522
displayName: 'Verify Package Tags and Create Git Releases'
1623
inputs:
@@ -25,7 +32,7 @@ steps:
2532
pwsh: true
2633
timeoutInMinutes: 5
2734
env:
28-
GH_TOKEN: ${{ parameters.AuthToken }}
35+
GH_TOKEN: ${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}
2936
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
3037
${{ if ne(parameters.NpmConfigUserConfig, '') }}:
3138
npm_config_userconfig: ${{ parameters.NpmConfigUserConfig }}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ parameters:
1111
AuthToken: $(azuresdk-github-pat)
1212

1313
steps:
14+
- ${{ if eq(parameters.AuthToken, '') }}:
15+
- template: /eng/common/pipelines/templates/steps/login-to-github.yml
16+
parameters:
17+
TokenOwners:
18+
- ${{ parameters.TargetRepoOwner }}
19+
ScriptDirectory: ${{ parameters.ScriptDirectory }}
20+
1421
- task: PowerShell@2
1522
displayName: Check for changes
1623
condition: and(succeeded(), eq(${{ parameters.SkipCheckingForChanges }}, false))
@@ -32,7 +39,7 @@ steps:
3239
- template: /eng/common/pipelines/templates/steps/emit-rate-limit-metrics.yml
3340
parameters:
3441
GitHubUser: azure-sdk
35-
GitHubToken: ${{ parameters.AuthToken }}
42+
GitHubToken: ${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}
3643

3744
- task: PowerShell@2
3845
displayName: Push changes
@@ -44,6 +51,6 @@ steps:
4451
arguments: >
4552
-PRBranchName "${{ parameters.BaseRepoBranch }}"
4653
-CommitMsg "${{ parameters.CommitMsg }}"
47-
-GitUrl "https://x-access-token:${{ parameters.AuthToken }}@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
54+
-GitUrl "https://x-access-token:${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
4855
-PushArgs "${{ parameters.PushArgs }}"
4956
-SkipCommit $${{ parameters.SkipCheckingForChanges }}

0 commit comments

Comments
 (0)