diff --git a/examples/v1alpha1/taskruns/stepaction_clone_build_push.yaml b/examples/v1alpha1/taskruns/stepaction_clone_build_push.yaml new file mode 100644 index 00000000000..b362ae3babe --- /dev/null +++ b/examples/v1alpha1/taskruns/stepaction_clone_build_push.yaml @@ -0,0 +1,110 @@ +apiVersion: tekton.dev/v1alpha1 +kind: StepAction +metadata: + name: git-clone +spec: + params: + - name: outputpath + - name: url + - name: verbose + default: "true" + - name: gitInitImage + default: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2" + results: + - name: commit + description: The precise commit SHA that was fetched by this Task. + - name: url + description: The precise URL that was fetched by this Task. + - name: committer-date + description: The epoch timestamp of the commit that was fetched by this Task. + image: "$(params.gitInitImage)" + script: | + #!/usr/bin/env sh + set -eu + + if [ "$(params.verbose)" = "true" ] ; then + set -x + fi + git config --global --add safe.directory $(params.outputpath) + git config --global init.defaultBranch main + git clone $(params.url) $(params.outputpath) + cd $(params.outputpath) + RESULT_SHA="$(git rev-parse HEAD)" + RESULT_COMMITTER_DATE="$(git log -1 --pretty=%ct)" + printf "%s" "${RESULT_COMMITTER_DATE}" > "$(step.results.committer-date.path)" + printf "%s" "${RESULT_SHA}" > "$(step.results.commit.path)" + printf "%s" "$(params.url)" > "$(step.results.url.path)" +--- +apiVersion: tekton.dev/v1alpha1 +kind: StepAction +metadata: + name: kaniko +spec: + params: + - name: IMAGE + description: Name (reference) of the image to build. + - name: DOCKERFILE + description: Path to the Dockerfile to build. + default: ./Dockerfile + - name: CONTEXT + description: The build context used by Kaniko. + default: ./ + - name: EXTRA_ARGS + type: array + default: [] + - name: BUILDER_IMAGE + description: The image on which builds will run (default is v1.5.1) + default: gcr.io/kaniko-project/executor:v1.5.1@sha256:c6166717f7fe0b7da44908c986137ecfeab21f31ec3992f6e128fff8a94be8a5 + - name: sourcePath + results: + - name: IMAGE_DIGEST + description: Digest of the image just built. + workingDir: $(params.sourcePath) + image: $(params.BUILDER_IMAGE) + args: + - $(params.EXTRA_ARGS) + - --dockerfile=$(params.DOCKERFILE) + - --context=$(params.sourcePath)/$(params.CONTEXT) # The user does not need to care the workspace and the source. + - --destination=$(params.IMAGE) + - --digest-file=$(step.results.IMAGE_DIGEST.path) +--- +apiVersion: tekton.dev/v1 +kind: TaskRun +metadata: + name: clone-build-push +spec: + params: + - name: url + value: https://github.com/chitrangpatel/repo1M + - name: IMAGE + value: us-central1-docker.pkg.dev/chitrang-tekton/chitrang/ci + workspaces: + - name: source + emptyDir: {} + TaskSpec: + results: + - name: commit + value: $(steps.clone.results.commit) + - name: url + value: $(steps.clone.results.url) + - name: committer-date + value: $(steps.clone.results.committer-date) + - name: image_digest + value: $(steps.build-push.results.IMAGE_DIGEST) + steps: + - name: clone + ref: + name: git-clone + params: + - name: url + value: $(params.url) + - name: outputpath + value: $(workspaces.source.path) + - name: build-push + ref: + name: kaniko + params: + - name: sourcePath + value: $(workspaces.source.path) + - name: IMAGE + value: $(params.IMAGE) diff --git a/examples/v1alpha1/taskruns/stepaction_trused_artifacts.yaml b/examples/v1alpha1/taskruns/stepaction_trused_artifacts.yaml new file mode 100644 index 00000000000..85991ebe54c --- /dev/null +++ b/examples/v1alpha1/taskruns/stepaction_trused_artifacts.yaml @@ -0,0 +1,195 @@ +apiVersion: tekton.dev/v1alpha1 +kind: StepAction +metadata: + name: upload-artifact-gcs +spec: + params: + - name: sourcePath + - name: location + description: The address (including "gs://") where you'd like to upload files to. + results: + - name: anArtifact + type: object + properties: + path: + type: string + url: + type: string + hash: + type: string + type: + type: string + image: gcr.io/google.com/cloudsdktool/cloud-sdk:379.0.0-slim@sha256:d844877c7aaa06a0072979230c68417ddb0f27087277f29747c7169d6ed0d2b9 + script: | + #!/usr/bin/env bash + if [ -f $(params.sourcePath) ]; then + A_FILE_HASH=$(md5sum "$(params.sourcePath)" | awk '{ print $1 }') + gsutil cp $(params.sourcePath) $(params.location) + TYPE=file + else + tar czf $(params.sourcePath).tar.gz $(params.sourcePath) + A_FILE_HASH=$(md5sum "$(params.sourcePath).tar.gz" | awk '{ print $1 }') + gsutil cp $(params.sourcePath).tar.gz $(params.location) + TYPE=folder + fi + cat <