diff --git a/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml b/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml index b455fec2100..1524ae8e1b8 100644 --- a/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml +++ b/eng/common/pipelines/templates/steps/eng-common-workflow-enforcer.yml @@ -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}" diff --git a/eng/pipelines/eng-workflows-sync.yml b/eng/pipelines/eng-workflows-sync.yml index 8fb4f898037..87bf1da7e82 100644 --- a/eng/pipelines/eng-workflows-sync.yml +++ b/eng/pipelines/eng-workflows-sync.yml @@ -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 }} diff --git a/eng/pipelines/templates/stages/archetype-sdk-tool-repo-sync.yml b/eng/pipelines/templates/stages/archetype-sdk-tool-repo-sync.yml index ea21f57d0d1..3cb555c5391 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tool-repo-sync.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tool-repo-sync.yml @@ -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 }} diff --git a/eng/pipelines/templates/steps/sync-directory.yml b/eng/pipelines/templates/steps/sync-directory.yml index 3afbdb35ed6..993bb0a006e 100644 --- a/eng/pipelines/templates/steps/sync-directory.yml +++ b/eng/pipelines/templates/steps/sync-directory.yml @@ -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 }}