look for github with variables and clean up
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jeffrey C. Ollie 2023-08-29 09:37:09 -05:00
parent a86893556c
commit 7f01fe35a5
Signed by: jeff
GPG key ID: 6F86035A6D97044E

View file

@ -17,6 +17,8 @@ def main [
let tags = if not ($env | get -i PLUGIN_TAGS | is-empty) { let tags = if not ($env | get -i PLUGIN_TAGS | is-empty) {
$tags | append ($env.PLUGIN_TAGS | split row ',' | str trim) $tags | append ($env.PLUGIN_TAGS | split row ',' | str trim)
} else if not ($env | get -i INPUT_TAGS | is-empty) {
$tags | append ($env.INPUT_TAGS | split row ',' | str trim)
} else { } else {
$tags $tags
} }
@ -71,6 +73,13 @@ def main [
) { ) {
print "Got username and password from PLUGIN_USERNAME and PLUGIN_PASSWORD" print "Got username and password from PLUGIN_USERNAME and PLUGIN_PASSWORD"
{username: $env.PLUGIN_USERNAME, password: $env.PLUGIN_PASSWORD} {username: $env.PLUGIN_USERNAME, password: $env.PLUGIN_PASSWORD}
} else if (
(not ($env | get -i INPUT_USERNAME | is-empty))
and
(not ($env | get -i INPUT_PASSWORD | is-empty))
) {
print "Got username and password from INPUT_USERNAME and INPUT_PASSWORD"
{username: $env.INPUT_USERNAME, password: $env.INPUT_PASSWORD}
} else if ( } else if (
(not ($env | get -i GITHUB_ACTOR | is-empty)) (not ($env | get -i GITHUB_ACTOR | is-empty))
and and
@ -88,6 +97,8 @@ def main [
if ($registry | is-empty) { if ($registry | is-empty) {
if not ($env | get -i PLUGIN_REGISTRY | is-empty) { if not ($env | get -i PLUGIN_REGISTRY | is-empty) {
$env.PLUGIN_REGISTRY $env.PLUGIN_REGISTRY
} else if not ($env | get -i INPUT_REGISTRY | is-empty) {
$env.INPUT_REGISTRY
} else if not ($env | get -i REGISTRY | is-empty) { } else if not ($env | get -i REGISTRY | is-empty) {
$env.REGISTRY $env.REGISTRY
} else if ( } else if (
@ -109,6 +120,8 @@ def main [
if ($repository | is-empty) { if ($repository | is-empty) {
if not ($env | get -i PLUGIN_REPOSITORY | is-empty) { if not ($env | get -i PLUGIN_REPOSITORY | is-empty) {
$env.PLUGIN_REPOSITORY $env.PLUGIN_REPOSITORY
} else if not ($env | get -i INPUT_REPOSITORY | is-empty) {
$env.INPUT_REPOSITORY
} else if not ($env | get -i REPOSITORY | is-empty) { } else if not ($env | get -i REPOSITORY | is-empty) {
$env.REPOSITORY $env.REPOSITORY
} else { } else {
@ -123,45 +136,20 @@ def main [
alias regctl = ^@regctl@ --verbosity warning alias regctl = ^@regctl@ --verbosity warning
alias gzip = ^@gzip@ alias gzip = ^@gzip@
regctl version
regctl registry login $registry --user $auth.username --pass $auth.password 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 { $tags | enumerate | each {
|item| |item|
if $item.index == 0 { if $item.index == 0 {
let new_image = $"($registry)/($repository):($item.item)" let new_image = $"($registry)/($repository):($item.item)"
print $"Pushing ($new_image)" print $"Pushing ($new_image)"
regctl image import $new_image $input regctl image import $new_image $input
# 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)" print $"Pushed ($new_image)"
} else { } else {
let old_image = $"($registry)/($repository):($tags | get 0)" let old_image = $"($registry)/($repository):($tags | get 0)"
let new_image = $"($registry)/($repository):($item.item)" let new_image = $"($registry)/($repository):($item.item)"
print $"Copying ($old_image) ($new_image)" print $"Copying ($old_image) ($new_image)"
regctl image copy $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)" print $"Copied ($old_image) ($new_image)"
} }
} }