github.com/oam-dev/kubevela@v1.9.11/docs/examples/workflow/source-to-image/step-definition.yaml (about) 1 apiVersion: core.oam.dev/v1beta1 2 kind: WorkflowStepDefinition 3 metadata: 4 name: build 5 namespace: vela-system 6 spec: 7 schematic: 8 cue: 9 template: |- 10 import ("vela/op") 11 12 parameter: { 13 // +usage=Specify the SSH URL of git repository for your source codes, e.g. git@git.woa.com:my-git-repo/demo.git 14 repoUrl: string 15 16 // +usage=Specify the branch which you want to be checked out and built 17 branch: string 18 19 // +usage=Specify the filename of Dockerfile under the root folder in your git repository 20 dockerfile: string 21 22 // +usage=Specify the secret name for the docker repository in your namespace in your K8S cluster 23 dockerSecret: string 24 25 // +usage=Specify the address where the image built is pushed into 26 image: string 27 } 28 29 build: op.#Task & { 30 name: "\(context.name)-build-\(context.stepSessionID)" 31 namespace: context.namespace 32 33 toolImage: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint:v0.27.2" 34 baseImage: "busybox:1.34" 35 36 // Declare workspaces that used to share data. 37 workspaces: { 38 "code-dir": {} 39 } 40 41 secrets: { 42 "\(parameter.dockerSecret)": { 43 items: [{ 44 key: ".dockerconfigjson" 45 path: "config.json" 46 }] 47 } 48 } 49 50 steps: [ 51 // git clone code repo. 52 { 53 name: "git-clone" 54 image: "bitnami/git:2.34.1" 55 workspaceMounts: [{workspace: workspaces["code-dir"], mountPath: "/data/code"}] 56 script: """ 57 #!/bin/bash 58 git clone -b \(parameter.branch) \(parameter.repoUrl) /data/code 59 """ 60 }, 61 // build and push image. 62 { 63 name: "build-image" 64 image: "gcr.io/kaniko-project/executor:debug" 65 workspaceMounts: [{workspace: workspaces["code-dir"], mountPath: "/data/build"}] 66 secretMounts: [{secret: secrets["\(parameter.dockerSecret)"], mountPath: "/kaniko/.docker/"}] 67 script: """ 68 #!/busybox/sh 69 /kaniko/executor --dockerfile=/data/build/\(parameter.dockerfile) --context=/data/build --destination=\(parameter.image) 70 """ 71 }] 72 } 73 74 // wait until deployment ready 75 wait: op.#ConditionalWait & { 76 continue: build.apply.value.status.phase == "Succeeded" 77 } 78