apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: manage-preview namespace: tekton-pipelines spec: params: - name: app-name - name: pr-number - name: action # "apply" or "delete" - name: image-tag default: "latest" workspaces: - name: source # Workspace containing the app's code (to find preview/values.yaml) steps: - name: preview-logic image: bitnami/kubectl:latest workingDir: $(workspaces.source.path) script: | # Use a specific naming convention for the PR namespace NS="$(params.app-name)-pr-$(params.pr-number)" if [ "$(params.action)" = "delete" ]; then echo "Cleaning up PR environment..." kubectl delete namespace $NS --ignore-not-found exit 0 fi echo "Deploying PR environment to namespace: $NS" kubectl create namespace $NS --dry-run=client -o yaml | kubectl apply -f - # Check if the app repo has custom preview values VALUES_REF_YAML="" if [ -f "preview/values.yaml" ]; then kubectl create configmap preview-values --from-file=values.yaml=preview/values.yaml \ -n $NS --dry-run=client -o yaml | kubectl apply -f - VALUES_REF_YAML="- kind: ConfigMap\n name: preview-values" fi # Apply the HelmRelease for this specific PR cat <