tekton-pipelines/tasks/update-manifest.yaml
2026-02-08 01:20:35 +01:00

44 lines
1.4 KiB
YAML

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: update-manifest
namespace: tekton-pipelines
spec:
params:
- name: app-name
- name: image-tag
- name: env # staging or production
- name: create-branch
default: "false"
steps:
- name: git-update
image: alpine/git:latest
script: |
git config --global user.email "cicd-bot@nid3.com"
git config --global user.name "Pingu-CI-Bot"
# Clone manifest repo using secrets
git clone https://$(GIT_USER):$(GIT_PASS)@github.com/Pingu-Studio/cicd-deployment-manifests.git m
cd m
if [ "$(params.create-branch)" = "true" ]; then
git checkout -b promote-$(params.app-name)-$(params.image-tag)
fi
# Update the image tag in the specific environment folder
TARGET_FILE="apps/$(params.env)/$(params.app-name)/release.yaml"
if [ -f "$TARGET_FILE" ]; then
sed -i "s/tag: .*/tag: \"$(params.image-tag)\"/" $TARGET_FILE
else
echo "Error: $TARGET_FILE not found"
exit 1
fi
git add .
git commit -m "chore($(params.env)): update $(params.app-name) to $(params.image-tag)"
git push origin $(git rev-parse --abbrev-ref HEAD)
env:
- name: GIT_USER
valueFrom: { secretKeyRef: { name: github-auth, key: username } }
- name: GIT_PASS
valueFrom: { secretKeyRef: { name: github-auth, key: password } }