github.com/profzone/eden-framework@v1.0.10/internal/project/workflow_transform_drone.go (about) 1 package project 2 3 import ( 4 "fmt" 5 "github.com/profzone/eden-framework/internal/project/drone" 6 "github.com/profzone/eden-framework/pkg/executil" 7 str "github.com/profzone/eden-framework/pkg/strings" 8 "strings" 9 ) 10 11 func (w *Workflow) ToDroneConfig(p *Project) *drone.CIDronePipelineDocker { 12 config := drone.NewCIDronePipelineDocker() 13 vol := drone.NewPipelineVolume(). 14 WithName("temp"). 15 WithTemp() 16 config.Volumes = append(config.Volumes, *vol) 17 18 for branch, branchFlow := range w.BranchFlows { 19 if branchFlow.Skip { 20 continue 21 } 22 23 for _, job := range branchFlow.Jobs { 24 if job.Skip { 25 continue 26 } 27 28 envVars := executil.EnvVars{} 29 envVars.LoadFromEnviron() 30 31 vol := drone.NewPipelineStepVolume(). 32 WithName("temp"). 33 WithPath("/go") 34 35 image := fmt.Sprintf("${%s}/${%s}", EnvKeyDockerRegistryKey, strings.ToUpper(envVars.Parse(job.Builder))) 36 image = envVars.Parse(image) 37 step := drone.NewPipelineStep(). 38 WithName(fmt.Sprintf("%s_%s", str.ToLowerCamelCase(branch), job.Stage)). 39 WithEnvs(branchFlow.Env). 40 WithImage(image). 41 WithVolume(*vol). 42 WithCommands(job.Run...) 43 44 if branch != "*" { 45 step.WithBranchInclude(branch) 46 } 47 48 config.Steps = append(config.Steps, *step) 49 } 50 } 51 52 return config 53 }