Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6606,7 +6606,8 @@ steps:
-timeout 12h0m0s -workflow deploy-packages.yaml -workflow-ref=refs/heads/master
-input "artifact-tag=${DRONE_TAG}" -input "environment=$(cat "/go/vars/release-environment.txt")"
-input "package-name-filter=$($DRONE_REPO_PRIVATE && echo "*ent*" || echo "")"
-input "release-channel=stable" -input "repo-type=apt" -input "version-channel=${DRONE_TAG}" '
-input "package-to-test=teleport-ent" -input "release-channel=stable" -input "repo-type=apt"
-input "version-channel=${DRONE_TAG}" '
environment:
GHA_APP_KEY:
from_secret: GITHUB_WORKFLOW_APP_PRIVATE_KEY
Expand Down Expand Up @@ -6673,7 +6674,8 @@ steps:
-timeout 12h0m0s -workflow deploy-packages.yaml -workflow-ref=refs/heads/master
-input "artifact-tag=${DRONE_TAG}" -input "environment=$(cat "/go/vars/release-environment.txt")"
-input "package-name-filter=$($DRONE_REPO_PRIVATE && echo "*ent*" || echo "")"
-input "release-channel=stable" -input "repo-type=yum" -input "version-channel=${DRONE_TAG}" '
-input "package-to-test=teleport-ent" -input "release-channel=stable" -input "repo-type=yum"
-input "version-channel=${DRONE_TAG}" '
environment:
GHA_APP_KEY:
from_secret: GITHUB_WORKFLOW_APP_PRIVATE_KEY
Expand Down Expand Up @@ -20230,6 +20232,6 @@ image_pull_secrets:
- DOCKERHUB_CREDENTIALS
---
kind: signature
hmac: f050e1682c1fbe155664724f7308ec69f7520672dd0abeb7df1deb59e7e99ac1
hmac: 2d735b23ccff9dfe334b4defcfcd95a03e2a6ccec8d40b4aa0b1a9b3d2a94b25

...
15 changes: 13 additions & 2 deletions build.assets/tooling/cmd/gh-trigger-workflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"flag"
"log"
"net/http"
"strings"
"time"

ghinst "github.com/bradleyfalzon/ghinstallation/v2"
Expand Down Expand Up @@ -98,7 +99,7 @@ func main() {
// our dispatch event. Note that we pick a time slightly in the past to handle
// any clock skew.
baselineTime := time.Now().Add(-2 * time.Minute)
oldRuns, err := github.ListWorkflowRuns(dispatchCtx, gh.Actions, args.owner, args.repo, args.workflow, args.workflowRef, baselineTime)
oldRuns, err := github.ListWorkflowRuns(dispatchCtx, gh.Actions, args.owner, args.repo, args.workflow, getBranchForRef(args.workflowRef), baselineTime)
if err != nil {
log.Fatalf("Failed to fetch initial task list: %s", err)
}
Expand Down Expand Up @@ -141,6 +142,16 @@ func main() {
log.Printf("Workflow succeeded")
}

// Returns either the branch name for the provided reference (if it refers to a branch), or an empty string.
func getBranchForRef(ref string) string {
branchRefPrefix := "refs/heads/"
if strings.HasPrefix(ref, branchRefPrefix) {
return strings.TrimPrefix(ref, branchRefPrefix)
}

return ""
}

// lookupInstallationID attempts to find an installation of the interface app
// we're using to authenticate.
func lookupInstallationID(ctx context.Context, args args) (int64, error) {
Expand Down Expand Up @@ -172,7 +183,7 @@ func waitForNewWorkflowRun(ctx context.Context, gh *ghapi.Client, args args, tag
log.Fatal("Timed out waiting for workflow run to start")

case <-ticker.C:
newRuns, err := github.ListWorkflowRuns(ctx, gh.Actions, args.owner, args.repo, args.workflow, args.workflowRef, baselineTime)
newRuns, err := github.ListWorkflowRuns(ctx, gh.Actions, args.owner, args.repo, args.workflow, getBranchForRef(args.workflowRef), baselineTime)
if err != nil {
return nil, trace.Wrap(err, "Failed polling for new workflow runs")
}
Expand Down
4 changes: 2 additions & 2 deletions build.assets/tooling/lib/github/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ type WorkflowRuns interface {

// ListWorkflowRuns returns a set of RunIDs, representing the set of all for
// workflow runs created since the supplied start time.
func ListWorkflowRuns(ctx context.Context, actions WorkflowRuns, owner, repo, path, ref string, since time.Time) (RunIDSet, error) {
func ListWorkflowRuns(ctx context.Context, actions WorkflowRuns, owner, repo, path, branch string, since time.Time) (RunIDSet, error) {
listOptions := github.ListWorkflowRunsOptions{
ListOptions: github.ListOptions{
PerPage: 100,
},
Branch: ref,
Branch: branch,
Created: ">" + since.Format(time.RFC3339),
}

Expand Down
34 changes: 20 additions & 14 deletions dronegen/os_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,46 @@ func promoteBuildOsRepoPipelines() []pipeline {
pipelines := []pipeline{}

// Normal release pipelines
pipelines = append(pipelines, buildPromoteOsPackagePipelines("${DRONE_TAG}", `$($DRONE_REPO_PRIVATE && echo "*ent*" || echo "")`, "normal")...)
pipelines = append(pipelines, buildPromoteOsPackagePipelines("${DRONE_TAG}", `$($DRONE_REPO_PRIVATE && echo "*ent*" || echo "")`, "normal", "teleport-ent")...)

// teleport-ent-updater to stable/cloud only pipelines
pipelines = append(pipelines, buildPromoteOsPackagePipelines("cloud", "teleport-ent-updater*", "teleport-ent-updater")...)
pipelines = append(pipelines, buildPromoteOsPackagePipelines("cloud", "teleport-ent-updater*", "teleport-ent-updater", "")...)

return pipelines
}

func buildPromoteOsPackagePipelines(versionChannel, packageNameFilter, pipelineNameSuffix string) []pipeline {
func buildPromoteOsPackagePipelines(versionChannel, packageNameFilter, pipelineNameSuffix, packageToTest string) []pipeline {
return []pipeline{
buildPromoteOsPackagePipeline("apt", versionChannel, packageNameFilter, pipelineNameSuffix),
buildPromoteOsPackagePipeline("yum", versionChannel, packageNameFilter, pipelineNameSuffix),
buildPromoteOsPackagePipeline("apt", versionChannel, packageNameFilter, pipelineNameSuffix, packageToTest),
buildPromoteOsPackagePipeline("yum", versionChannel, packageNameFilter, pipelineNameSuffix, packageToTest),
}
}

func buildPromoteOsPackagePipeline(repoType, versionChannel, packageNameFilter, pipelineNameSuffix string) pipeline {
func buildPromoteOsPackagePipeline(repoType, versionChannel, packageNameFilter, pipelineNameSuffix, packageToTest string) pipeline {
releaseEnvironmentFilePath := "/go/vars/release-environment.txt"
clonePath := "/go/src/github.com/gravitational/teleport"

inputs := map[string]string{
"repo-type": repoType,
"environment": fmt.Sprintf("$(cat %q)", releaseEnvironmentFilePath),
"artifact-tag": "${DRONE_TAG}",
"release-channel": "stable",
"version-channel": versionChannel,
"package-name-filter": packageNameFilter,
}

if packageToTest != "" {
inputs["package-to-test"] = packageToTest
}

pipeline := ghaBuildPipeline(ghaBuildType{
trigger: triggerPromote,
pipelineName: fmt.Sprintf("publish-%s-%s-new-repos", pipelineNameSuffix, repoType),
ghaWorkflow: "deploy-packages.yaml",
timeout: 12 * time.Hour, // DR takes a long time
workflowRef: "refs/heads/master",
shouldTagWorkflow: false,
inputs: map[string]string{
"repo-type": repoType,
"environment": fmt.Sprintf("$(cat %q)", releaseEnvironmentFilePath),
"artifact-tag": "${DRONE_TAG}",
"release-channel": "stable",
"version-channel": versionChannel,
"package-name-filter": packageNameFilter,
},
inputs: inputs,
})

pipeline.Steps = []step{
Expand Down