diff --git a/.drone.yml b/.drone.yml index 0134386..d68a3fd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,25 +21,25 @@ steps: commands: # - set # - nix run .#login - - echo -n "$${PLUGIN_PASSWORD}" | podman login --username $${PLUGIN_USERNAME} --password-stdin $${PLUGIN_REGISTRY} + # - echo -n "$${PLUGIN_PASSWORD}" | podman login --username $${PLUGIN_USERNAME} --password-stdin $${PLUGIN_REGISTRY} - nix build .#nixos-runner - # - nix run .#push-container -- result - - podman load --input result | sed -n -e "s/Loaded image:.\\(.*\\)/\\1/p" > loaded-image - - cat loaded-image - - podman images - - podman tag "$$( loaded-image + # - cat loaded-image + # - podman images + # - podman tag "$$(.*)" | get 0.rest + + let repository = ( + if ($repository | is-empty) { + if not ($env | get -i PLUGIN_REPOSITORY | is-empty) { + $env.PLUGIN_REPOSITORY + } else if not ($env | get -i REPOSITORY | is-empty) { + $env.REPOSITORY + } else { + print "No repository specified!" + exit 1 + } + } else { + $repository + } + ) + + alias regctl = ^@regctl@ --verbosity info + alias gzip = ^@gzip@ + + regctl registry login $registry --user $auth.username --pass $auth.password + + print "decompressing image: start" + + open $input | gzip --decompress | save --force --progress $"($input).tar" + + print "decompressing image: stop" + + # let load_result = (do { regctl load --input $input } | complete) + # if $load_result.exit_code != 0 { + # print $load_result.stderr + # exit 1 + # } + + # let old_image = ($load_result.stdout | str trim | parse "Loaded image: {image}" | get 0.image) + + $tags | enumerate | each { + |item| + if $item.index == 0 { + let new_image = $"($registry)/($repository):($item.item)" + print $"Pushing ($new_image)" + regctl image import $new_image $"($input).tar" + # let tag_result = (do { regctl image import $new_image $"($input).tar" } | complete) + # if $tag_result.exit_code != 0 { + # print $tag_result.stderr + # exit 1 + # } + print $"Pushed ($new_image)" + } else { + let old_image = $"($registry)/($repository):($tags | get 0)" + let new_image = $"($registry)/($repository):($item.item)" + print $"Copying ($old_image) ($new_image)" + regctl image copy $old_image $new_image + # let tag_result = (do { regctl image copy $old_image $new_image } | complete) + # if $tag_result.exit_code != 0 { + # print $tag_result.stderr + # exit 1 + # } + print $"Copied ($old_image) ($new_image)" + } + } + + regctl registry logout $registry +}