Skip to content

Commit

Permalink
20230625I
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Jun 25, 2023
1 parent b94eed1 commit 1b31502
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,16 @@ Try {
Catch {}
If ($Null -ine $CommandDocker) {
If ($RemoveDockerImage.Count -gt 0) {
[String[]]$DockerImageListRaw = docker image ls --all --format '{{json .}}'
$DockerImageListRaw |
Write-GitHubActionsDebug
[PSCustomObject[]]$DockerImageList = (
$DockerImageListRaw |
docker image ls --all --format '{{json .}}' |
Join-String -Separator ',' -OutputPrefix '[' -OutputSuffix ']' |
ConvertFrom-Json -Depth 100
) ?? @()
ForEach ($Item In (
$DockerImageList |
Where-Object -FilterScript { Test-StringMatchRegEx -Item "$($_.Repository)$(($_.Tag.Length -gt 0) ? ":$($_.Tag)" : '')" -Matcher $RemoveDockerImage }
)) {
[String]$ItemName = "$($_.Repository)$(($_.Tag.Length -gt 0) ? ":$($_.Tag)" : '')"
[String]$ItemName = "$($Item.Repository)$(($Item.Tag.Length -gt 0) ? ":$($Item.Tag)" : '')"
Write-Host -Object "Remove Docker image ``$ItemName``."
docker image rm "$ItemName"
}
Expand Down

0 comments on commit 1b31502

Please sign in to comment.