Fix OCI promotion (#22867)

Removes unnecessary workflow arguments from the Drone workflow
invocation. Refactors some of the `dronegen` generators to make
this easier to express insife `dronegen`
This commit is contained in:
Trent Clarke 2023-03-14 12:45:23 +11:00 committed by GitHub
parent 144992b67f
commit a3c70378aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 40 deletions

View file

@ -7744,7 +7744,7 @@ steps:
- cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"
- 'go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e
-tag-workflow -workflow promote-teleport-oci-distroless.yml -workflow-ref=${DRONE_TAG}
-input oss-teleport-repo=${DRONE_REPO} -input oss-teleport-ref=${DRONE_TAG} '
-input "release-source-tag=${DRONE_TAG}" '
environment:
GHA_APP_KEY:
from_secret: GITHUB_WORKFLOW_APP_PRIVATE_KEY
@ -19038,6 +19038,6 @@ volumes:
temp: {}
---
kind: signature
hmac: 21a11c7790b9e369c34f99e45f3b24df20dcd822bc4beb1c3d27f76bec331298
hmac: d17f0dff7d28b2f0beed2fbef216d59e77ac6ea4ba542f9fdc4ab9f57ecd58d0
...

View file

@ -22,13 +22,13 @@ import (
type ghaBuildType struct {
buildType
trigger
pipelineName string
ghaWorkflow string
srcRefVar string
workflowRefVar string
slackOnError bool
dependsOn []string
inputs map[string]string
pipelineName string
ghaWorkflow string
srcRefVar string
workflowRef string
slackOnError bool
dependsOn []string
inputs map[string]string
}
func ghaBuildPipeline(b ghaBuildType) pipeline {
@ -43,10 +43,13 @@ func ghaBuildPipeline(b ghaBuildType) pipeline {
cmd.WriteString(`-repo teleport.e `)
cmd.WriteString(`-tag-workflow `)
fmt.Fprintf(&cmd, `-workflow %s `, b.ghaWorkflow)
fmt.Fprintf(&cmd, `-workflow-ref=${%s} `, b.workflowRefVar)
fmt.Fprintf(&cmd, `-workflow-ref=%s `, b.workflowRef)
cmd.WriteString(`-input oss-teleport-repo=${DRONE_REPO} `)
fmt.Fprintf(&cmd, `-input oss-teleport-ref=${%s} `, b.srcRefVar)
// If we don't need to build teleport...
if b.srcRefVar != "" {
cmd.WriteString(`-input oss-teleport-repo=${DRONE_REPO} `)
fmt.Fprintf(&cmd, `-input oss-teleport-ref=${%s} `, b.srcRefVar)
}
for k, v := range b.inputs {
fmt.Fprintf(&cmd, `-input "%s=%s" `, k, v)

View file

@ -19,12 +19,14 @@ func promoteBuildPipelines() []pipeline {
promotePipelines = append(promotePipelines, promoteBuildOsRepoPipelines()...)
ociPipeline := ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", fips: false},
trigger: triggerPromote,
pipelineName: "promote-teleport-oci-distroless-images",
ghaWorkflow: "promote-teleport-oci-distroless.yml",
srcRefVar: "DRONE_TAG",
workflowRefVar: "DRONE_TAG",
buildType: buildType{os: "linux", fips: false},
trigger: triggerPromote,
pipelineName: "promote-teleport-oci-distroless-images",
ghaWorkflow: "promote-teleport-oci-distroless.yml",
workflowRef: "${DRONE_TAG}",
inputs: map[string]string{
"release-source-tag": "${DRONE_TAG}",
},
})
ociPipeline.Trigger.Target.Include = append(ociPipeline.Trigger.Target.Include, "promote-distroless")

View file

@ -72,14 +72,14 @@ func pushPipelines() []pipeline {
}
ps = append(ps, ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", arch: "arm64"},
trigger: triggerPush,
pipelineName: "push-build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
slackOnError: true,
srcRefVar: "DRONE_COMMIT",
workflowRefVar: "DRONE_BRANCH",
inputs: map[string]string{"upload-artifacts": "false"},
buildType: buildType{os: "linux", arch: "arm64"},
trigger: triggerPush,
pipelineName: "push-build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
slackOnError: true,
srcRefVar: "DRONE_COMMIT",
workflowRef: "${DRONE_BRANCH}",
inputs: map[string]string{"upload-artifacts": "false"},
}))
// Only amd64 Windows is supported for now.

View file

@ -189,23 +189,23 @@ func tagPipelines() []pipeline {
}
ps = append(ps, ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", arch: "arm64", fips: false},
trigger: triggerTag,
pipelineName: "build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
srcRefVar: "DRONE_TAG",
workflowRefVar: "DRONE_TAG",
dependsOn: []string{tagCleanupPipelineName},
inputs: map[string]string{"upload-artifacts": "true"},
buildType: buildType{os: "linux", arch: "arm64", fips: false},
trigger: triggerTag,
pipelineName: "build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
srcRefVar: "DRONE_TAG",
workflowRef: "${DRONE_TAG}",
dependsOn: []string{tagCleanupPipelineName},
inputs: map[string]string{"upload-artifacts": "true"},
}))
ps = append(ps, ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", fips: false},
trigger: triggerTag,
pipelineName: "build-teleport-oci-distroless-images",
ghaWorkflow: "release-teleport-oci-distroless.yml",
srcRefVar: "DRONE_TAG",
workflowRefVar: "DRONE_TAG",
buildType: buildType{os: "linux", fips: false},
trigger: triggerTag,
pipelineName: "build-teleport-oci-distroless-images",
ghaWorkflow: "release-teleport-oci-distroless.yml",
srcRefVar: "DRONE_TAG",
workflowRef: "${DRONE_TAG}",
dependsOn: []string{
tagCleanupPipelineName,
"build-linux-amd64-deb",