init
This commit is contained in:
parent
f621d183c0
commit
fdbf405d2c
@ -14,6 +14,12 @@ spec:
|
|||||||
default: ""
|
default: ""
|
||||||
description: context directory
|
description: context directory
|
||||||
|
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: url
|
- name: url
|
||||||
type: string
|
type: string
|
||||||
description: The Git repository URL to clone.
|
description: The Git repository URL to clone.
|
||||||
@ -122,7 +128,7 @@ spec:
|
|||||||
|
|
||||||
cd /workspace/base/$(params.context)
|
cd /workspace/base/$(params.context)
|
||||||
|
|
||||||
CLONE_DIR="source"
|
CLONE_DIR="$(params.source)"
|
||||||
if [ -z "$CLONE_DIR" ]; then
|
if [ -z "$CLONE_DIR" ]; then
|
||||||
CLONE_DIR="."
|
CLONE_DIR="."
|
||||||
fi
|
fi
|
||||||
|
59
tasks/git-commit-push/task.yaml
Normal file
59
tasks/git-commit-push/task.yaml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1
|
|
||||||
kind: Task
|
|
||||||
metadata:
|
|
||||||
name: git-replace-multi
|
|
||||||
annotations:
|
|
||||||
tekton.dev/pipelines.minVersion: "0.19.0"
|
|
||||||
tekton.dev/categories: GitOps
|
|
||||||
tekton.dev/tags: git, devops
|
|
||||||
tekton.dev/displayName: "replace multiple files/dirs in git repository"
|
|
||||||
tekton.dev/platforms: "linux/amd64"
|
|
||||||
spec:
|
|
||||||
description: |
|
|
||||||
Replaces multiple files or directories in a Git repository, committing and pushing the changes.
|
|
||||||
|
|
||||||
params:
|
|
||||||
- name: repositoryUrl
|
|
||||||
type: string
|
|
||||||
description: Source repository URL
|
|
||||||
|
|
||||||
- name: branch
|
|
||||||
type: string
|
|
||||||
default: main
|
|
||||||
description: Git branch to push to
|
|
||||||
|
|
||||||
- name: targetPaths
|
|
||||||
type: array
|
|
||||||
description: List of target paths in the repo (file or directory, e.g. dir/ or file)
|
|
||||||
|
|
||||||
- name: sourcePaths
|
|
||||||
type: array
|
|
||||||
description: List of source paths in the workspace (file or directory, e.g. dir/ or file)
|
|
||||||
|
|
||||||
- name: commitMessage
|
|
||||||
type: string
|
|
||||||
default: "chore(gitops): replace multiple files or dirs"
|
|
||||||
description: Commit message
|
|
||||||
|
|
||||||
workspaces:
|
|
||||||
- name: base
|
|
||||||
- name: tmp
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone-repository
|
|
||||||
image: alpine/git:latest
|
|
||||||
script: |
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
REPO_URL="$(params.repositoryUrl)"
|
|
||||||
BRANCH="$(params.branch)"
|
|
||||||
WORKSPACE_PATH="$(workspaces.tmp.path)"
|
|
||||||
git clone --branch "${BRANCH}" "${REPO_URL}" "${WORKSPACE_PATH}/repo"
|
|
||||||
cd "${WORKSPACE_PATH}/repo"
|
|
||||||
|
|
||||||
- name: sync-files
|
|
||||||
image: alpine:3.18
|
|
||||||
script: |
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
TARGET_PATHS=($(params.targetPaths[*]))
|
|
||||||
SOURCE_PATHS=($(params.sourcePaths[*]))
|
|
||||||
BASE_PATH="$(workspaces.base.path)/source"
|
|
||||||
REPO_PATH="$(workspaces.tmp.path)/repo"
|
|
||||||
COUNT=${#TARGET_PATHS[@]}
|
|
||||||
if [ $COUNT -ne ${#SOURCE_PATHS[@]} ]; then
|
|
||||||
echo "targetPaths와 sourcePaths의 길이가 다릅니다."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
for i in $(seq 0 $(($COUNT - 1))); do
|
|
||||||
TARGET="${REPO_PATH}/${TARGET_PATHS[$i]}"
|
|
||||||
SOURCE="${BASE_PATH}/${SOURCE_PATHS[$i]}"
|
|
||||||
[ -e "${TARGET}" ] && rm -rf "${TARGET}" || true
|
|
||||||
mkdir -p $(dirname "${TARGET}")
|
|
||||||
cp -r "${SOURCE}" "${TARGET}"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: commit-and-push
|
|
||||||
image: alpine/git:latest
|
|
||||||
script: |
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
cd "$(workspaces.tmp.path)/repo"
|
|
||||||
git config --global user.name "tekton-bot"
|
|
||||||
git config --global user.email "tekton@example.com"
|
|
||||||
git add .
|
|
||||||
git commit -m "$(params.commitMessage)" || exit 0
|
|
||||||
git push origin HEAD:"$(params.branch)"
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: tmp
|
|
||||||
emptyDir: {}
|
|
@ -9,6 +9,12 @@ spec:
|
|||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: workspaceName
|
- name: workspaceName
|
||||||
type: string
|
type: string
|
||||||
description: Nx workspace name to lint and test
|
description: Nx workspace name to lint and test
|
||||||
@ -35,7 +41,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: lint-and-test
|
- name: lint-and-test
|
||||||
image: $(params.nodejsImageName)
|
image: $(params.nodejsImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName)
|
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,13 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: workspaceName
|
- name: workspaceName
|
||||||
type: string
|
type: string
|
||||||
description: Nx workspace project name to lint and test
|
description: Nx workspace project name to lint and test
|
||||||
@ -28,7 +35,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: verify-tag-version
|
- name: verify-tag-version
|
||||||
image: $(params.nodejsImageName)
|
image: $(params.nodejsImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,16 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
- name: output
|
||||||
|
type: string
|
||||||
|
default: "output"
|
||||||
|
description: |
|
||||||
|
output directory (sub directory of context)
|
||||||
|
|
||||||
- name: packageNamePrefix
|
- name: packageNamePrefix
|
||||||
description: Rust crate name prefix
|
description: Rust crate name prefix
|
||||||
@ -42,12 +52,10 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: generate-code
|
- name: generate-code
|
||||||
image: openapitools/openapi-generator-cli:v7.4.0
|
image: openapitools/openapi-generator-cli:v7.4.0
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
# command:
|
|
||||||
# - openapi-generator-cli
|
|
||||||
args:
|
args:
|
||||||
- generate
|
- generate
|
||||||
- -i
|
- -i
|
||||||
@ -55,8 +63,8 @@ spec:
|
|||||||
- -g
|
- -g
|
||||||
- $(params.generator)
|
- $(params.generator)
|
||||||
- -o
|
- -o
|
||||||
- "/workspace/base/$(params.context)/output/$(params.packageNamePrefix)$(params.specDomain)-$(params.version)-$(params.generator)"
|
- "/workspace/base/$(params.context)/$(params.output)"
|
||||||
- --additional-properties=packageName=$(params.packageNamePrefix)$(params.context)
|
- --additional-properties=packageName=$(params.packageNamePrefix)$(params.specDomain)
|
||||||
- --additional-properties=packageVersion=$(params.version)
|
- --additional-properties=packageVersion=$(params.version)
|
||||||
- --additional-properties=publish=true
|
- --additional-properties=publish=true
|
||||||
- --additional-properties=disableValidator=false
|
- --additional-properties=disableValidator=false
|
||||||
@ -66,5 +74,5 @@ spec:
|
|||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
OUTPUT="/workspace/base/$(params.context)/output/$(params.packageNamePrefix)$(params.specDomain)-$(params.version)-$(params.generator)"
|
OUTPUT="/workspace/base/$(params.context)/$(params.output)"
|
||||||
echo -n "${OUTPUT}" > $(results.output.path)
|
echo -n "${OUTPUT}" > $(results.output.path)
|
@ -8,6 +8,13 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: ref
|
- name: ref
|
||||||
type: string
|
type: string
|
||||||
description: Full Git ref string (e.g., refs/tags/v0.2.0)
|
description: Full Git ref string (e.g., refs/tags/v0.2.0)
|
||||||
@ -22,7 +29,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: verify-version
|
- name: verify-version
|
||||||
image: mikefarah/yq:4.24.2
|
image: mikefarah/yq:4.24.2
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
description: home directory
|
description: home directory
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: pythonImageName
|
- name: pythonImageName
|
||||||
type: string
|
type: string
|
||||||
@ -25,7 +30,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-package
|
- name: build-package
|
||||||
image: $(params.pythonImageName)
|
image: $(params.pythonImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
@ -62,7 +67,7 @@ spec:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📂 Checking built artifacts..."
|
echo "📂 Checking built artifacts..."
|
||||||
BUILD_PATH="/workspace/base/$(params.context)/source/dist"
|
BUILD_PATH="/workspace/base/$(params.context)/$(params.source)/dist"
|
||||||
echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path
|
echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path
|
||||||
|
|
||||||
if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A "$BUILD_PATH")" ]; then
|
if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A "$BUILD_PATH")" ]; then
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: pythonImageName
|
- name: pythonImageName
|
||||||
type: string
|
type: string
|
||||||
@ -37,7 +42,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: run-pylint
|
- name: run-pylint
|
||||||
image: $(params.pythonImageName)
|
image: $(params.pythonImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: pythonImageName
|
- name: pythonImageName
|
||||||
type: string
|
type: string
|
||||||
@ -21,7 +26,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: install-dependencies
|
- name: install-dependencies
|
||||||
image: $(params.pythonImageName)
|
image: $(params.pythonImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: ref
|
- name: ref
|
||||||
type: string
|
type: string
|
||||||
@ -29,7 +34,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: verify-tag
|
- name: verify-tag
|
||||||
image: $(params.pythonImageName)
|
image: $(params.pythonImageName)
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
@ -17,6 +17,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: version
|
- name: version
|
||||||
type: string
|
type: string
|
||||||
@ -42,7 +47,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: install-deps
|
- name: install-deps
|
||||||
image: node:18-alpine
|
image: node:18-alpine
|
||||||
workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName)
|
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
@ -57,7 +62,7 @@ spec:
|
|||||||
|
|
||||||
- name: import-projects
|
- name: import-projects
|
||||||
image: node:18-alpine
|
image: node:18-alpine
|
||||||
workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName)
|
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
@ -107,7 +112,7 @@ spec:
|
|||||||
|
|
||||||
- name: git-commit
|
- name: git-commit
|
||||||
image: alpine/git:latest
|
image: alpine/git:latest
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: keys
|
- name: keys
|
||||||
type: string
|
type: string
|
||||||
@ -23,7 +28,7 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: extract
|
- name: extract
|
||||||
image: python:3.11-slim
|
image: python:3.11-slim
|
||||||
workingDir: /workspace/base/$(params.context)/source
|
workingDir: /workspace/base/$(params.context)/$(params.source)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
|
@ -8,6 +8,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
description: "소스코드가 있는 하위 디렉토리 (없을 경우 '')"
|
description: "소스코드가 있는 하위 디렉토리 (없을 경우 '')"
|
||||||
|
- name: source
|
||||||
|
type: string
|
||||||
|
default: "source"
|
||||||
|
description: |
|
||||||
|
source directory (sub directory of context)
|
||||||
|
|
||||||
- name: sonarqubeUrl
|
- name: sonarqubeUrl
|
||||||
type: string
|
type: string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user