From 05a7a9dcd7099f86082ea3d4f793ff70beba6fe4 Mon Sep 17 00:00:00 2001 From: James Suplizio Date: Fri, 17 May 2024 08:35:05 -0700 Subject: [PATCH] Remove SAS token from GitHubIO blob storage docs publish --- .../templates/steps/publish-blobs.yml | 18 ++++++++++-------- .../scripts/copy-docs-to-blobstorage.ps1 | 11 +++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/eng/common/pipelines/templates/steps/publish-blobs.yml b/eng/common/pipelines/templates/steps/publish-blobs.yml index 1eadf19ca7..2ba10037e1 100644 --- a/eng/common/pipelines/templates/steps/publish-blobs.yml +++ b/eng/common/pipelines/templates/steps/publish-blobs.yml @@ -1,6 +1,5 @@ parameters: FolderForUpload: '' - BlobSASKey: '' TargetLanguage: '' BlobName: '' ScriptPath: '' @@ -17,17 +16,20 @@ steps: workingDirectory: $(Build.BinariesDirectory) displayName: Download and Extract azcopy Zip -- task: Powershell@2 +- task: AzurePowerShell@5 + displayName: 'Copy Docs to Blob Storage' + continueOnError: false inputs: - filePath: ${{ parameters.ScriptPath }} - arguments: > + azureSubscription: 'Azure SDK Artifacts' + ScriptType: 'FilePath' + ScriptPath: ${{ parameters.ScriptPath }} + ScriptArguments: > -AzCopy $(Resolve-Path "$(Build.BinariesDirectory)/azcopy/azcopy_windows_amd64_*/azcopy.exe")[0] -DocLocation "${{ parameters.FolderForUpload }}" - -SASKey "${{ parameters.BlobSASKey }}" -BlobName "${{ parameters.BlobName }}" -PublicArtifactLocation "${{ parameters.ArtifactLocation }}" -RepoReplaceRegex "(https://github.com/${{ parameters.RepoId }}/(?:blob|tree)/)$(DefaultBranch)" + azurePowerShellVersion: latestVersion pwsh: true - workingDirectory: $(Pipeline.Workspace) - displayName: Copy Docs to Blob - continueOnError: false \ No newline at end of file + env: + AZCOPY_AUTO_LOGIN_TYPE: 'PSCRED' diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index 135d3f2cc8..ff55c7389c 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -4,7 +4,6 @@ param ( $AzCopy, $DocLocation, - $SASKey, $BlobName, $ExitOnError=1, $UploadLatest=1, @@ -176,9 +175,9 @@ function Update-Existing-Versions $sortedVersionObj.LatestGAPackage | Out-File -File "$($DocLocation)/latest-ga" -Force -NoNewLine $sortedVersionObj.LatestPreviewPackage | Out-File -File "$($DocLocation)/latest-preview" -Force -NoNewLine - & $($AzCopy) cp "$($DocLocation)/versions" "$($DocDest)/$($PkgName)/versioning/versions$($SASKey)" --cache-control "max-age=300, must-revalidate" - & $($AzCopy) cp "$($DocLocation)/latest-preview" "$($DocDest)/$($PkgName)/versioning/latest-preview$($SASKey)" --cache-control "max-age=300, must-revalidate" - & $($AzCopy) cp "$($DocLocation)/latest-ga" "$($DocDest)/$($PkgName)/versioning/latest-ga$($SASKey)" --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocLocation)/versions" "$($DocDest)/$($PkgName)/versioning/versions" --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocLocation)/latest-preview" "$($DocDest)/$($PkgName)/versioning/latest-preview" --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocLocation)/latest-ga" "$($DocDest)/$($PkgName)/versioning/latest-ga" --cache-control "max-age=300, must-revalidate" return $sortedVersionObj } @@ -216,7 +215,7 @@ function Upload-Blobs } LogDebug "Uploading $($PkgName)/$($DocVersion) to $($DocDest)..." - & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)" --recursive=true --cache-control "max-age=300, must-revalidate" LogDebug "Handling versioning files under $($DocDest)/$($PkgName)/versioning/" $versionsObj = (Update-Existing-Versions -PkgName $PkgName -PkgVersion $DocVersion -DocDest $DocDest) @@ -229,7 +228,7 @@ function Upload-Blobs if ($UploadLatest -and ($latestVersion -eq $DocVersion)) { LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..." - & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest" --recursive=true --cache-control "max-age=300, must-revalidate" } }