Skip to content

Commit e0d143c

Browse files
Push container images properly:
Because of the way CI is built (2 self-hosted runners), CI was not pushing container images when building on main. This was because PR's would build the images and the would be locally in the Docker cache. Then when main ran, hook-lk-containers.sh would run and see that the image existed in the local Docker cache already and stop before pushing. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 9323116 commit e0d143c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bash/hook-lk-containers.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ function build_hook_linuxkit_container() {
3131
log debug "Checking if image ${container_oci_ref} exists in local registry"
3232
if [[ -n "$(docker images -q "${container_oci_ref}")" ]]; then
3333
log info "Image ${container_oci_ref} exists in local registry, skipping build"
34+
# we try to push here because a previous build may have created the image
35+
# this is the case for GitHub Actions CI because we build PRs on the same self-hosted runner
36+
push_hook_linuxkit_container "${container_oci_ref}"
3437
return 0
3538
fi
3639

@@ -55,6 +58,15 @@ function build_hook_linuxkit_container() {
5558

5659
log info "Built ${container_oci_ref} from ${container_dir} for platform ${DOCKER_ARCH}"
5760

61+
push_hook_linuxkit_container "${container_oci_ref}"
62+
63+
return 0
64+
}
65+
66+
67+
function push_hook_linuxkit_container() {
68+
declare container_oci_ref="${1}"
69+
5870
# Push the image to the registry, if DO_PUSH is set to yes
5971
if [[ "${DO_PUSH}" == "yes" ]]; then
6072
docker push "${container_oci_ref}" || {
@@ -64,6 +76,4 @@ function build_hook_linuxkit_container() {
6476
else
6577
log info "Skipping push of ${container_oci_ref} to registry; set DO_PUSH=yes to push."
6678
fi
67-
68-
return 0
6979
}

0 commit comments

Comments
 (0)