Created
March 26, 2021 14:04
-
-
Save PartTimeLegend/74e24d0df5226d80bef930ae2f47a9cc to your computer and use it in GitHub Desktop.
Prune ACR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $registry = "myRegistry" | |
| $keep = 5 | |
| $prAgo = "7d" | |
| $masterAgo = "90d" | |
| $prCron = "0 0 * * *" | |
| $masterCron = "0 0 * * *" | |
| $repositories = @("foo.bar", | |
| "bar.foo", | |
| "foobar.boofoo", | |
| "barfoo.foobar" | |
| ") | |
| foreach ($repository in $repositories) | |
| { | |
| $prefix = $repository.Replace(".","") | |
| $prCmd = "acr purge --filter '${repository}:.*-PullRequest.*' --ago $prago" | |
| Write-Output $prCmd | |
| $prTaskCmd = "az acr task create --name ""${prefix}purgePRTask"" --cmd ""$prCmd"" --schedule ""$prCron"" --registry $registry --context /dev/null" | |
| Write-Output $prTaskCmd | |
| Invoke-Expression $prTaskCmd | |
| #[Console]::ReadKey() | |
| $masterCmd = "acr purge --filter '${repository}:.*' --ago $masterAgo --keep $keep" | |
| Write-Output $masterCmd | |
| $masterTaskCmd = "az acr task create --name ""${prefix}purgeMasterTask"" --cmd ""$masterCmd"" --schedule ""$masterCron"" --registry $registry --context /dev/null" | |
| Write-Output $masterTaskCmd | |
| Invoke-Expression $masterTaskCmd | |
| #[Console]::ReadKey() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment