teleport/dronegen/gha.go
Trent Clarke e2c795a4b1
Drone and tagging updates trigger GHA buildsfrom drone (#19830)
This patch performs the (hopefully final) switchover that will make drone
defer to GHA in order to build Teleport ion arm64.

This patch:
 - Replaces all of the Dronegen code to generate arm64 builds locally with
   steps that invoke the GHA builder workflow
 - Changes the release tagging behavior in the Makefile to tag `teleport.e`
   with the same tag as teleport. This is required to for Drone to identify
   the revision of the arm64 build workflow to invoke
 - Updates the e reference to include a revision of `teleport.e` that 
   contains the builder workflows

Thanks to everyone involved in getting this working.
2023-01-04 23:28:50 +00:00

71 lines
2.1 KiB
Go

// Copyright 2023 Gravitational, Inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import "fmt"
type ghaBuildType struct {
buildType
trigger
namePrefix string
uploadArtifacts bool
srcRefVar string
workflowRefVar string
slackOnError bool
}
func ghaBuildPipeline(b ghaBuildType) pipeline {
p := newKubePipeline(fmt.Sprintf("%sbuild-%s-%s", b.namePrefix, b.os, b.arch))
p.Trigger = b.trigger
p.Workspace = workspace{Path: "/go"}
p.Environment = map[string]value{
"BUILDBOX_VERSION": buildboxVersion,
"RUNTIME": goRuntime,
"UID": {raw: "1000"},
"GID": {raw: "1000"},
}
p.Steps = []step{
{
Name: "Check out code",
Image: "docker:git",
Environment: map[string]value{
"GITHUB_PRIVATE_KEY": {fromSecret: "GITHUB_PRIVATE_KEY"},
},
Commands: pushCheckoutCommands(b.buildType),
},
{
Name: "Delegate build to GitHub",
Image: fmt.Sprintf("golang:%s-alpine", GoVersion),
Environment: map[string]value{
"GHA_APP_KEY": {fromSecret: "GITHUB_WORKFLOW_APP_PRIVATE_KEY"},
},
Commands: []string{
`cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"`,
`go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e -workflow release-linux-arm64.yml ` +
fmt.Sprintf(`-workflow-ref=${%s} `, b.workflowRefVar) +
fmt.Sprintf(`-input oss-teleport-ref=${%s} `, b.srcRefVar) +
fmt.Sprintf(`-input upload-artifacts=%t`, b.uploadArtifacts),
},
},
}
if b.slackOnError {
p.Steps = append(p.Steps, sendErrorToSlackStep())
}
return p
}