ci: fix docker tag manifest hashes (#4354)

pull/4355/head
Amir Zarrinkafsh 2022-11-11 13:44:55 +11:00 committed by GitHub
parent 7a305faab8
commit 296f240324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -100,15 +100,14 @@ func cmdDockerPushManifestRun(_ *cobra.Command, _ []string) {
log.Infof("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3]) log.Infof("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3])
login(docker, dockerhub) login(docker, dockerhub)
login(docker, ghcr) login(docker, ghcr)
deployManifest(docker, tags[1])
publishDockerReadme(docker)
if !ignoredSuffixes.MatchString(ciTag) { if ignoredSuffixes.MatchString(ciTag) {
deployManifest(docker, tags[2]) deployManifest(docker, tags[1])
deployManifest(docker, tags[3]) } else {
deployManifest(docker, "latest") deployManifest(docker, tags[1], tags[2], tags[3], "latest")
publishDockerReadme(docker)
} }
publishDockerReadme(docker)
} else { } else {
log.Fatal("Docker manifest will not be published, the specified tag does not conform to the standard") 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) { func deployManifest(docker *Docker, tag ...string) {
log.Infof("Docker manifest %s:%s will be deployed on %s and %s", DockerImageName, tag, dockerhub, ghcr) tags = make([]string, 0)
dockerhub := dockerhub + "/" + DockerImageName + ":" + tag log.Infof("The following Docker manifest(s) will be deployed on %s and %s", dockerhub, ghcr)
ghcr := ghcr + "/" + DockerImageName + ":" + tag
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) log.Fatal(err)
} }
} }

View File

@ -42,8 +42,13 @@ func (d *Docker) Login(username, password, registry string) error {
} }
// Manifest push a docker manifest to dockerhub. // Manifest push a docker manifest to dockerhub.
func (d *Docker) Manifest(tag1, tag2 string) error { func (d *Docker) Manifest(tags []string) error {
args := []string{"build", "-t", tag1, "-t", tag2} args := []string{"build"}
for _, tag := range tags {
args = append(args, "-t", tag)
}
annotations := "" annotations := ""
buildMetaData, err := getBuild(ciBranch, os.Getenv("BUILDKITE_BUILD_NUMBER"), "") buildMetaData, err := getBuild(ciBranch, os.Getenv("BUILDKITE_BUILD_NUMBER"), "")