Files
kubevela/docs/examples/workflow/source-to-image/step-definition.yaml
Jian.Li 1776859631 Feat(workflow): Add op.#Task action (#2220)
* Feat(workflow): tekton task

* Feat(tools): random string

* Fix(example): defintion fmt

* Fix(rand): gosec weak random
2021-09-02 13:40:10 +08:00

56 lines
1.8 KiB
YAML

apiVersion: core.oam.dev/v1beta1
kind: WorkflowStepDefinition
metadata:
name: build
namespace: vela-system
spec:
schematic:
cue:
template: |-
import ("vela/op")
parameter: {
repoUrl: string
dockerfile: string
image: string
}
let pushImage=image
build: op.#Task & {
name: "\(context.name)-\(context.stepId)"
namespace: context.namespace
// Declare workspaces that used to share data.
workspace: {
"code-dir": {}
}
steps: [
// git clone code repo.
{
name: "git-clone"
image: "git-image-with-pull-ssh"
workspaceMounts: [{workspace: workspace["code-dir"], mountPath: "/data/code"}]
script: """
#! /bin/bash
git clone \(repourl) /data/code
"""
},
// build and push image.
{
name: "build-image"
image: "gcr.io/kaniko-project/executor:v1.3.0"
workspaceMounts: [{workspace: workspace["code-dir"], mountPath: "/data/build"}]
script: """
#! /bin/bash
/kaniko/executor --dockerfile=/data/build/\(dockerfile) --context=/data/build --destination=\(pushImage)
"""
}]
}
// wait until deployment ready
wait: op.#ConditionalWait & {
continue: build.do.status.phase == "successed"
}