From 296f24032479b2d14e69b66728c59f6e98f40123 Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Fri, 11 Nov 2022 13:44:55 +1100 Subject: [PATCH] ci: fix docker tag manifest hashes (#4354) --- cmd/authelia-scripts/cmd/docker.go | 27 ++++++++++++---------- cmd/authelia-scripts/cmd/helpers_docker.go | 9 ++++++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cmd/authelia-scripts/cmd/docker.go b/cmd/authelia-scripts/cmd/docker.go index c06385a80..57456f4ca 100644 --- a/cmd/authelia-scripts/cmd/docker.go +++ b/cmd/authelia-scripts/cmd/docker.go @@ -100,15 +100,14 @@ func cmdDockerPushManifestRun(_ *cobra.Command, _ []string) { log.Infof("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3]) login(docker, dockerhub) login(docker, ghcr) - deployManifest(docker, tags[1]) - publishDockerReadme(docker) - if !ignoredSuffixes.MatchString(ciTag) { - deployManifest(docker, tags[2]) - deployManifest(docker, tags[3]) - deployManifest(docker, "latest") - publishDockerReadme(docker) + if ignoredSuffixes.MatchString(ciTag) { + deployManifest(docker, tags[1]) + } else { + deployManifest(docker, tags[1], tags[2], tags[3], "latest") } + + publishDockerReadme(docker) } else { log.Fatal("Docker manifest will not be published, the specified tag does not conform to the standard") } @@ -182,13 +181,17 @@ func login(docker *Docker, registry string) { } } -func deployManifest(docker *Docker, tag string) { - log.Infof("Docker manifest %s:%s will be deployed on %s and %s", DockerImageName, tag, dockerhub, ghcr) +func deployManifest(docker *Docker, tag ...string) { + tags = make([]string, 0) - dockerhub := dockerhub + "/" + DockerImageName + ":" + tag - ghcr := ghcr + "/" + DockerImageName + ":" + tag + log.Infof("The following Docker manifest(s) will be deployed on %s and %s", dockerhub, ghcr) - if err := docker.Manifest(dockerhub, ghcr); err != nil { + for _, t := range tag { + log.Infof("- %s:%s", DockerImageName, t) + tags = append(tags, dockerhub+"/"+DockerImageName+":"+t, ghcr+"/"+DockerImageName+":"+t) + } + + if err := docker.Manifest(tags); err != nil { log.Fatal(err) } } diff --git a/cmd/authelia-scripts/cmd/helpers_docker.go b/cmd/authelia-scripts/cmd/helpers_docker.go index 11fd93fe8..f05eba9ac 100644 --- a/cmd/authelia-scripts/cmd/helpers_docker.go +++ b/cmd/authelia-scripts/cmd/helpers_docker.go @@ -42,8 +42,13 @@ func (d *Docker) Login(username, password, registry string) error { } // Manifest push a docker manifest to dockerhub. -func (d *Docker) Manifest(tag1, tag2 string) error { - args := []string{"build", "-t", tag1, "-t", tag2} +func (d *Docker) Manifest(tags []string) error { + args := []string{"build"} + + for _, tag := range tags { + args = append(args, "-t", tag) + } + annotations := "" buildMetaData, err := getBuild(ciBranch, os.Getenv("BUILDKITE_BUILD_NUMBER"), "")