Skip to content

Commit

Permalink
more diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
mthalman committed Apr 20, 2024
1 parent 041c209 commit 2172934
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
9 changes: 7 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ runs:
$containerName = "docker-bump-checker"
$containerSrcPath = "/src"
echo "workspace: ${env:GITHUB_WORKSPACE}"
Get-ChildItem "${env:GITHUB_WORKSPACE}../"
# The repo directory will be volume-mounted into the container so the Dockerfile path needs to be modified accordingly
$dockerfile = "$containerSrcPath/$dockerfile"
$result = docker run `
Expand All @@ -63,13 +66,15 @@ runs:
throw "command failed"
}
docker cp ${containerName}:/home/app homedir
Get-ChildItem homedir
docker cp ${containerName}:/home/app/log.txt log.txt
docker cp ${containerName}:/home/app/log1.txt log1.txt
if ($LASTEXITCODE -ne 0) {
throw "command failed"
}
Get-Content log.txt
echo "foo"
Get-Content log1.txt
docker rm $containerName
if ($LASTEXITCODE -ne 0) {
throw "command failed"
Expand Down
13 changes: 10 additions & 3 deletions container/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ $ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-StrictMode -Version 2.0

if (-not $baseImage) {
$baseImage = $(& $PSScriptRoot/get-base-image.ps1 -DockerfilePath $DockerfilePath -BaseStageName $BaseStageName)
Write-Output "x${BaseImage}y" | Out-File $env:HOME/log.txt -Append
if ($BaseImage) {
Write-Output "x${BaseImage}y" | Out-File $env:HOME/log1.txt -Append
}

$triggerWorkflow = $(& $PSScriptRoot/check-image.ps1 -TargetImage $targetImage -BaseImage $baseImage -Architecture $Architecture)
if (-not $BaseImage) {
Write-Output "x" | Out-File $env:HOME/log1.txt -Append
& $PSScriptRoot/get-base-image.ps1 -DockerfilePath $DockerfilePath -BaseStageName $BaseStageName
}

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

return $triggerWorkflow
12 changes: 11 additions & 1 deletion container/get-base-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ $ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-StrictMode -Version 2.0

Write-Output "x" | Out-File $env:HOME/log2.txt -Append

function LogMessage ($Message) {
Write-Output $Message | Out-File $env:HOME/log.txt
Write-Output $Message | Out-File $env:HOME/log.txt -Append
Get-Content $env:HOME/log.txt
}

if (-not $DockerfilePath) {
Expand All @@ -31,6 +34,8 @@ $dfspyArgs = @(
# Otherwise, we need to derive the base image by finding the last stage of the Dockerfile and walking
# its parent chain. To do that, we need the graph layout.

Write-Output foo1

if (-not $BaseStageName) {
LogMessage 'Stage name not provided. Will derive base image by walking parent chain.'
$dfspyArgs += '--layout'
Expand All @@ -44,6 +49,9 @@ if ($LASTEXITCODE -ne 0) {
throw "dfspy failed"
}

Write-Output foo2


if ($BaseStageName) {
$baseImage = $fromOutput | Where-Object { $_.PSObject.Properties.Name -contains "stageName" -and $_.stageName -eq $BaseStageName } | Select-Object -ExpandProperty imageName
} else {
Expand All @@ -59,6 +67,8 @@ if ($BaseStageName) {
$baseImage = $currentNode.fromInstruction.imageName
}

Write-Output foo3

LogMessage "Using base image name '$baseImage'."

return $baseImage

0 comments on commit 2172934

Please sign in to comment.