60 lines
1.5 KiB
YAML
60 lines
1.5 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: git-commit-push
|
|
spec:
|
|
description: |
|
|
This task clones a Git repository and checks out a specified branch if it exists.
|
|
Supports SSH, basic-auth, custom CA certs, sparse checkout, submodules, shallow clone, and proxy settings.
|
|
The commit SHA, committer date, and fetched URL are exposed as Task results.
|
|
|
|
params:
|
|
- name: context
|
|
type: string
|
|
default: ""
|
|
description: context directory
|
|
|
|
- name: source
|
|
type: string
|
|
default: "source"
|
|
description: |
|
|
source directory (sub directory of context)
|
|
|
|
- name: remote
|
|
type: string
|
|
description: Specifies the name of the remote repository (e.g., origin).
|
|
default: "origin"
|
|
|
|
- name: branch
|
|
type: string
|
|
description: Specifies the name of the local branch to push.
|
|
default: "main"
|
|
|
|
|
|
- name: commitMessage
|
|
type: string
|
|
default: "chore: commpit projects"
|
|
description: commit message
|
|
|
|
|
|
workspaces:
|
|
- name: base
|
|
description: The workspace where the repository will be cloned.
|
|
|
|
steps:
|
|
- name: clone
|
|
image: alpine/git:latest
|
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
|
env:
|
|
- name: HOME
|
|
value: /workspace/base/$(params.context)/home
|
|
script: |
|
|
#!/bin/sh
|
|
set -eu
|
|
|
|
git add .
|
|
git commit -m "$(params.commitMessage)" || exit 0
|
|
git push origin HEAD:main
|
|
|
|
|