Add FilePattern support for .github\workflow sync (#8849)
Given we cannot create subfolders under .github\workflow folder and we have repos that want additional workflows then we have in the tools repo we need to setup a file pattern matching for the sync processing to only sync the ones we want to be common. For now just use the existing *event* pattern but we can move them to another pattern similar to *common* or *sync* in the future as we add more common workflows.
This commit is contained in:
Родитель
c37624031e
Коммит
571fc6a541
|
@ -21,7 +21,7 @@ steps:
|
|||
}
|
||||
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-.github/workflows")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
|
||||
{
|
||||
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath '.github/workflows/*' -DiffFilterType ""
|
||||
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath '.github/workflows/*event*' -DiffFilterType ""
|
||||
if (($LASTEXITCODE -eq 0) -and ($filesInCommonDir.Count -gt 0))
|
||||
{
|
||||
Write-Host "##vso[task.LogIssue type=error;]Changes to files under '.github/workflows' directory should not be made in this Repo`n${filesInCommonDir}"
|
||||
|
|
|
@ -6,6 +6,9 @@ parameters:
|
|||
- name: DirectoryToSync
|
||||
type: string
|
||||
default: .github/workflows
|
||||
- name: FilePattern
|
||||
type: string
|
||||
default: '/*event*'
|
||||
- name: Repos
|
||||
type: object
|
||||
default:
|
||||
|
@ -28,10 +31,11 @@ pr:
|
|||
- main
|
||||
paths:
|
||||
include:
|
||||
- .github/workflows
|
||||
- .github/workflows/*event*
|
||||
|
||||
extends:
|
||||
template: /eng/pipelines/templates/stages/archetype-sdk-tool-repo-sync.yml
|
||||
parameters:
|
||||
DirectoryToSync: ${{ parameters.DirectoryToSync }}
|
||||
FilePattern: ${{ parameters.FilePattern }}
|
||||
Repos: ${{ parameters.Repos }}
|
||||
|
|
|
@ -8,9 +8,12 @@ parameters:
|
|||
- name: DirectoryToSync
|
||||
type: string
|
||||
default: not-specified
|
||||
- name: FilePattern
|
||||
type: string
|
||||
default: ''
|
||||
- name: BaseBranchName
|
||||
type: string
|
||||
default: $(Build.SourceBranch)
|
||||
default: $(DefaultBranch)
|
||||
- name: Repos
|
||||
type: object
|
||||
default: []
|
||||
|
@ -35,7 +38,7 @@ stages:
|
|||
- pwsh: |
|
||||
Set-PsDebug -Trace 1
|
||||
$patchDir = "$(Build.ArtifactStagingDirectory)/patchfiles"
|
||||
$patchfiles = git format-patch --output-directory $patchDir HEAD...origin/$(system.pullRequest.targetBranch) -- "${{ parameters.DirectoryToSync }}"
|
||||
$patchfiles = git format-patch --output-directory $patchDir HEAD...origin/$(system.pullRequest.targetBranch) -- "${{ parameters.DirectoryToSync }}${{ parameters.FilePattern }}"
|
||||
if ($patchfiles -and ($LASTEXITCODE -eq 0)) {
|
||||
echo "##vso[task.setvariable variable=PatchFilesLocation]$patchDir"
|
||||
echo "Setting PatchFilesLocation"
|
||||
|
@ -57,6 +60,7 @@ stages:
|
|||
parameters:
|
||||
CommitMessage: "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository for Tools PR $(System.PullRequest.PullRequestNumber)"
|
||||
DirectoryToSync: ${{ parameters.DirectoryToSync }}
|
||||
FilePattern: ${{ parameters.FilePattern }}
|
||||
UpstreamBranchName: "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
|
||||
BaseBranchName: $(system.pullRequest.targetBranch)
|
||||
SkipCheckingForChanges: true
|
||||
|
@ -189,15 +193,11 @@ stages:
|
|||
vmImage: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
|
||||
parameters:
|
||||
Paths:
|
||||
- ${{ parameters.DirectoryToSync }}
|
||||
|
||||
- template: /eng/pipelines/templates/steps/sync-directory.yml
|
||||
parameters:
|
||||
CommitMessage: Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository
|
||||
DirectoryToSync: ${{ parameters.DirectoryToSync }}
|
||||
FilePattern: ${{ parameters.FilePattern }}
|
||||
UpstreamBranchName: "sync-${{ parameters.DirectoryToSync }}"
|
||||
BaseBranchName: ${{ parameters.BaseBranchName }}
|
||||
Repos: ${{ parameters.Repos }}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
parameters:
|
||||
Repos: []
|
||||
DirectoryToSync: eng/common
|
||||
FilePattern: ''
|
||||
CommitMessage: commit-message-not-set
|
||||
UpstreamBranchName: branch-name-not-set
|
||||
BaseBranchName: $(DefaultBranch)
|
||||
|
@ -27,7 +28,6 @@ steps:
|
|||
|
||||
- ${{ each repo in parameters.Repos }}:
|
||||
- pwsh: |
|
||||
$repoPath = "${{ repo }}/${{ parameters.DirectoryToSync }}"
|
||||
if (Test-Path '$(PatchFilesLocation)')
|
||||
{
|
||||
pushd ${{ repo }}
|
||||
|
@ -152,9 +152,9 @@ steps:
|
|||
- pwsh: |
|
||||
Set-PsDebug -Trace 1
|
||||
$repoPath = "${{ repo }}/${{ parameters.DirectoryToSync }}"
|
||||
Remove-Item -v -r -ErrorAction Ignore $repoPath
|
||||
Remove-Item -v -r -ErrorAction Ignore "$repoPath${{ parameters.FilePattern }}"
|
||||
Copy-Item -v -r `
|
||||
$(System.DefaultWorkingDirectory)/$(Build.Repository.Name)/${{ parameters.DirectoryToSync }} `
|
||||
"$(System.DefaultWorkingDirectory)/$(Build.Repository.Name)/${{ parameters.DirectoryToSync }}${{ parameters.FilePattern }}" `
|
||||
$repoPath
|
||||
Get-ChildItem -r $repoPath
|
||||
displayName: Copy ${{ parameters.DirectoryToSync }} from azure-sdk-tools to ${{ repo }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче