-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow_transform_gitlab.go
48 lines (40 loc) · 1.14 KB
/
workflow_transform_gitlab.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package project
import (
"fmt"
"github.com/eden-framework/eden-framework/pkg/executil"
str "github.com/eden-framework/eden-framework/pkg/strings"
"strings"
)
var DefaultCICache = CICache{
Key: "${CI_BUILD_REF}_${CI_BUILD_REF_NAME}",
UnTracked: true,
}
func (w *Workflow) ToCIConfig(project *Project) *CIConfig {
ciConfig := NewCIConfig().
WithCache(DefaultCICache).
WithStages(STAGE_TEST, STAGE_BUILD, STAGE_SHIP, STAGE_DEPLOY)
for branch, branchFlow := range w.BranchFlows {
if !branchFlow.Skip {
for _, job := range branchFlow.Jobs {
if !job.Skip {
envVars := executil.EnvVars{}
envVars.LoadFromEnviron()
ciJob := NewCIJob(job.Stage).
WithTags(project.Group).
WithEnv(branchFlow.Env["GOENV"]).
WithImage(fmt.Sprintf("${%s}/${%s}", EnvKeyDockerRegistryKey, strings.ToUpper(envVars.Parse(job.Builder)))).
WithArtifacts(job.Artifacts).
WithScript(job.Run...)
if branch != "*" {
ciJob = ciJob.WithOnly(branch)
}
ciConfig = ciConfig.AddJob(
fmt.Sprintf("%s_%s", str.ToLowerCamelCase(branch), job.Stage),
ciJob,
)
}
}
}
}
return ciConfig
}