From 1b3150208989fdb756939a4b956c15491f1588f3 Mon Sep 17 00:00:00 2001 From: hugoalh <32359235+hugoalh@users.noreply.github.com> Date: Sun, 25 Jun 2023 13:39:51 +0800 Subject: [PATCH] 20230625I --- main.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main.ps1 b/main.ps1 index 3c71716..9f7b13c 100644 --- a/main.ps1 +++ b/main.ps1 @@ -55,11 +55,8 @@ 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 ) ?? @() @@ -67,7 +64,7 @@ If ($Null -ine $CommandDocker) { $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" }