mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
Feat(workflow): Add op.#Task action (#2220)
* Feat(workflow): tekton task * Feat(tools): random string * Fix(example): defintion fmt * Fix(rand): gosec weak random
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user