refactor(tekton): use remote tasks from Tekton Hub

This commit is contained in:
Khue Doan 2023-01-25 17:26:16 +07:00
parent 330393080a
commit 8df13c3ef4
4 changed files with 8 additions and 59 deletions

View File

@ -8,7 +8,14 @@ spec:
tasks:
- name: git-clone
taskRef:
name: git-clone
resolver: hub
params:
- name: kind
value: task
- name: name
value: git-clone
- name: version
value: "0.7"
workspaces:
- name: output
workspace: shared-data

View File

@ -15,4 +15,3 @@ resources:
# Service account
- serviceaccount.yaml
- clusterrolebinding.yaml
- tasks/

View File

@ -1,47 +0,0 @@
# https://github.com/tektoncd/plumbing/blob/main/tekton/ci/shared/common-tasks.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: check-git-files-changed
annotations:
description: |
Returns "passed" in the "check" result if any of the files changed
in the source on the workspace matches the regular expression.
Returns a "files" result as a list of files modified by the PR that
match the regex in the parameters.
ci.tekton.dev/condition: |
The result of this task is used to evaluate a condition.
Events from this task are ignored downstream, when it comes to update the CI job status.
spec:
params:
- name: gitCloneDepth
description: Number of commits + 1
- name: regex
description: Regular expression to match files changed
workspaces:
- name: input
results:
- name: check
description: passed or failed
- name: files
description: list of files modified that match
steps:
- name: check-files-changed
image: alpine/git
env:
- name: GIT_CLONE_DEPTH
value: $(params.gitCloneDepth)
- name: REGEX
value: $(params.regex)
script: |
#!/bin/sh
set -ex
set -o pipefail
BACK="HEAD~$(( ${GIT_CLONE_DEPTH} - 1 ))"
CHECK="failed"
cd $(workspaces.input.path)
git diff-tree --no-commit-id --name-only -r HEAD $BACK | \
grep -E "${REGEX}" > $(results.files.path) || true
git diff-tree --no-commit-id --name-only -r HEAD $BACK | \
grep -E "${REGEX}" && CHECK="passed"
printf $CHECK > $(results.check.path)

View File

@ -1,10 +0,0 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.7/git-clone.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/gitea-set-status/0.1/gitea-set-status.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/gitleaks/0.1/gitleaks.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/kaniko/0.5/kaniko.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/pull-request/0.1/pull-request.yaml
- check-git-files-changed.yaml