Skip to content

Commit

Permalink
Include client payload data
Browse files Browse the repository at this point in the history
  • Loading branch information
mthalman committed May 3, 2024
1 parent 549e3ef commit a3634ea
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
14 changes: 11 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
throw "'dockerfile' input not provided. This is required when 'base-image-name' is not provided."
}
$dockerBumpCheckerVersion = "0.2.0"
$dockerBumpCheckerVersion = "dev"
$containerName = "docker-bump-checker"
$containerSrcPath = "/src"
Expand Down Expand Up @@ -79,15 +79,23 @@ runs:
if ($LASTEXITCODE -ne 0) {
throw "command failed"
}
echo "SEND_DISPATCH=$result" >> "$env:GITHUB_ENV"
echo "Result: $result"
$result = $result | ConvertFrom-Json
echo "Result: $result"
echo "SEND_DISPATCH=$($result.sendDispatch))" >> "$env:GITHUB_ENV"
echo "UPDATE_RESULTS=$($result.updates))" >> "$env:GITHUB_ENV"
- name: Repository Dispatch
if: env.SEND_DISPATCH == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ inputs.token }}
repository: ${{ inputs.repository }}
event-type: ${{ inputs.event-type }}
client-payload: ${{ env.UPDATE_RESULTS }}
- name: Report Status
id: report-status
shell: pwsh
Expand Down
1 change: 1 addition & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY --from=installer /usr/share/powershell /usr/share/powershell
COPY --from=installer /root/.dotnet/tools /home/app/.dotnet/tools
COPY --from=installer ["/symlinks", "/usr/bin"]
COPY *.ps1 /scripts/
COPY *.psm1 /scripts/

# Returns 'true' in the output if the image is out-of-date in relation to its base image; otherwise, 'false'.
ENTRYPOINT ["pwsh", "-c", "/scripts/entrypoint.ps1"]
33 changes: 28 additions & 5 deletions container/check-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,46 @@ param(
[string]$BaseImage,

[Parameter(Mandatory = $True)]
[string]$Architecture
[string]$Architecture,

[string]$DockerfilePath
)

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-StrictMode -Version 2.0

Import-Module $PSScriptRoot/common.psm1
function GetDigest($imageName) {
$digestCmd = "dredge image digest $imageName --os linux --arch $Architecture"
$digest = $(InvokeTool $digestCmd "dredge image digest failed")
return $digest
}

$cmd = "dredge image compare layers --output json $BaseImage $TargetImage --os linux --arch $Architecture"
$layerComparisonStr = $(InvokeTool $cmd "dredge image compare failed")
Import-Module $PSScriptRoot/common.psm1

$compareCmd = "dredge image compare layers --output json $BaseImage $TargetImage --os linux --arch $Architecture"
$layerComparisonStr = $(InvokeTool $compareCmd "dredge image compare failed")
$layerComparison = $layerComparisonStr | ConvertFrom-Json

$imageUpToDate = [bool]$($layerComparison.summary.targetIncludesAllBaseLayers)
$sendDispatch = ([string](-not $imageUpToDate)).ToLower()

$targetDigest = $(GetDigest $TargetImage)
$baseDigest = $(GetDigest $BaseImage)

LogMessage "Send dispatch: $sendDispatch"

return $sendDispatch
$result = @{
sendDispatch = $sendDispatch
updates = @(
@{
targetImageName = $TargetImage
targetImageDigest = $targetDigest
dockerfile = $DockerfilePath
baseImageName = $BaseImage
baseImageDigest = $baseDigest
}
)
} | ConvertTo-Json

return $result
2 changes: 1 addition & 1 deletion container/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ if (-not $BaseImage) {
$BaseImage = $(& $PSScriptRoot/get-base-image.ps1 -DockerfilePath $DockerfilePath -BaseStageName $BaseStageName)
}

$result = $(& $PSScriptRoot/check-image.ps1 -TargetImage $targetImage -BaseImage $BaseImage -Architecture $Architecture)
$result = $(& $PSScriptRoot/check-image.ps1 -TargetImage $targetImage -BaseImage $BaseImage -Architecture $Architecture -DockerfilePath $DockerfilePath)

return $result

0 comments on commit a3634ea

Please sign in to comment.