From a28871c4c079929a4006c3371bbf5b458d581b4a Mon Sep 17 00:00:00 2001 From: Georgi Matev Date: Fri, 24 Mar 2023 16:36:24 -0700 Subject: [PATCH] Parametrize libraries (#2942) Add a secret for configuring SP libraries to purge --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [x] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .github/actions/purge-m365-user-data/action.yml | 4 +++- .github/workflows/ci_test_cleanup.yml | 1 + src/cmd/purge/scripts/onedrivePurge.ps1 | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/purge-m365-user-data/action.yml b/.github/actions/purge-m365-user-data/action.yml index a642d15f1..c346c4fde 100644 --- a/.github/actions/purge-m365-user-data/action.yml +++ b/.github/actions/purge-m365-user-data/action.yml @@ -18,6 +18,8 @@ inputs: description: User whose data is to be purged. site: description: Sharepoint site where data is to be purged. + libraries: + description: List of library names within site where data is to be purged. folder-prefix: description: Name of the folder to be purged. If falsy, will purge the set of static, well known folders instead. older-than: @@ -65,7 +67,7 @@ runs: M365_TENANT_ADMIN_USER: ${{ inputs.m365-admin-user }} M365_TENANT_ADMIN_PASSWORD: ${{ inputs.m365-admin-password }} run: | - ./onedrivePurge.ps1 -Site ${{ inputs.site }} -FolderPrefixPurgeList ${{ inputs.folder-prefix }} -PurgeBeforeTimestamp ${{ inputs.older-than }} + ./onedrivePurge.ps1 -Site ${{ inputs.site }} -LibraryNameList ${{ inputs.libraries }} -FolderPrefixPurgeList ${{ inputs.folder-prefix }} -PurgeBeforeTimestamp ${{ inputs.older-than }} - name: Reset retention for all mailboxes to 0 if: ${{ inputs.user == '' }} diff --git a/.github/workflows/ci_test_cleanup.yml b/.github/workflows/ci_test_cleanup.yml index bb82cbe46..0ad37811d 100644 --- a/.github/workflows/ci_test_cleanup.yml +++ b/.github/workflows/ci_test_cleanup.yml @@ -30,6 +30,7 @@ jobs: user: ${{ secrets[matrix.user] }} site: ${{ secrets.CORSO_M365_TEST_SITE_URL}} folder-prefix: "Corso_Restore_, TestRestore, testfolder, incrementals_ci_, Alcion_Restore_" + libraries: ${{ secrets.CORSO_M365_TEST_SITE_LIBRARIES }} older-than: ${{ env.HALF_HOUR_AGO }} azure-client-id: ${{ secrets.CLIENT_ID }} azure-client-secret: ${{ secrets.CLIENT_SECRET }} diff --git a/src/cmd/purge/scripts/onedrivePurge.ps1 b/src/cmd/purge/scripts/onedrivePurge.ps1 index 0389f8857..641445c1f 100644 --- a/src/cmd/purge/scripts/onedrivePurge.ps1 +++ b/src/cmd/purge/scripts/onedrivePurge.ps1 @@ -70,6 +70,8 @@ function Purge-Library { [String[]]$SiteSuffix ) + Write-Host "`nPurging library: $LibraryName" + $foldersToPurge = @() $folders = Get-PnPFolderItem -FolderSiteRelativeUrl $LibraryName -ItemType Folder