Skip to content

Commit 0af31f9

Browse files
azure-sdkscbeddCopilot
authored
Sync eng/common directory with azure-sdk-tools for PR 15388 (#46632)
* this is backwards compatible. new callers can explicitly add login-to-github and pass the authtoken parameter * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update to add fallback to login. will need to approve serviceConnection for the new builds, but other than that, no impact --------- Co-authored-by: Scott Beddall <scbedd@microsoft.com> Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7112111 commit 0af31f9

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

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

Lines changed: 16 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: '' to auto-login via login-to-github.yml.
34

45
parameters:
56
BaseBranchName: $(Build.SourceBranch)
@@ -21,8 +22,19 @@ 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:
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+
2638
- template: /eng/common/pipelines/templates/steps/git-push-changes.yml
2739
parameters:
2840
BaseRepoBranch: ${{ parameters.PRBranchName }}
@@ -34,6 +46,7 @@ steps:
3446
WorkingDirectory: ${{ parameters.WorkingDirectory }}
3547
ScriptDirectory: ${{ parameters.ScriptDirectory }}
3648
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
49+
AuthToken: ${{ coalesce(parameters.PushAuthToken, parameters.AuthToken, '$(GH_TOKEN)') }}
3750

3851
- task: PowerShell@2
3952
displayName: Create pull request
@@ -48,7 +61,7 @@ steps:
4861
-BaseBranch "${{ parameters.BaseBranchName }}"
4962
-PROwner "${{ parameters.PROwner }}"
5063
-PRBranch "${{ parameters.PRBranchName }}"
51-
-AuthToken "$(azuresdk-github-pat)"
64+
-AuthToken "${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}"
5265
-PRTitle "${{ parameters.PRTitle }}"
5366
-PRBody "${{ coalesce(parameters.PRBody, parameters.CommitMsg, parameters.PRTitle) }}"
5467
-PRLabels "${{ parameters.PRLabels }}"

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

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

1213
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+
1321
- task: PowerShell@2
1422
displayName: 'Verify Package Tags and Create Git Releases'
1523
inputs:
@@ -24,7 +32,7 @@ steps:
2432
pwsh: true
2533
timeoutInMinutes: 5
2634
env:
27-
GH_TOKEN: $(azuresdk-github-pat)
35+
GH_TOKEN: ${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}
2836
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
2937
${{ if ne(parameters.NpmConfigUserConfig, '') }}:
3038
npm_config_userconfig: ${{ parameters.NpmConfigUserConfig }}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ parameters:
55
TargetRepoOwner: Azure
66
TargetRepoName: $(Build.Repository.Name)
77
PushArgs:
8-
WorkingDirectory: $(System.DefaultWorkingDirectory)'
8+
WorkingDirectory: $(System.DefaultWorkingDirectory)
99
ScriptDirectory: eng/common/scripts
1010
SkipCheckingForChanges: false
11+
AuthToken: $(azuresdk-github-pat)
1112

1213
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+
1321
- task: PowerShell@2
1422
displayName: Check for changes
1523
condition: and(succeeded(), eq(${{ parameters.SkipCheckingForChanges }}, false))
@@ -31,7 +39,7 @@ steps:
3139
- template: /eng/common/pipelines/templates/steps/emit-rate-limit-metrics.yml
3240
parameters:
3341
GitHubUser: azure-sdk
34-
GitHubToken: $(azuresdk-github-pat)
42+
GitHubToken: ${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}
3543

3644
- task: PowerShell@2
3745
displayName: Push changes
@@ -43,6 +51,6 @@ steps:
4351
arguments: >
4452
-PRBranchName "${{ parameters.BaseRepoBranch }}"
4553
-CommitMsg "${{ parameters.CommitMsg }}"
46-
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
54+
-GitUrl "https://x-access-token:${{ coalesce(parameters.AuthToken, '$(GH_TOKEN)') }}@github.com/${{ parameters.BaseRepoOwner }}/$(RepoNameWithoutOwner).git"
4755
-PushArgs "${{ parameters.PushArgs }}"
4856
-SkipCommit $${{ parameters.SkipCheckingForChanges }}

0 commit comments

Comments
 (0)