# `Conditions` are deprecated, use `WhenExpressions` instead
# https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#guard-task-execution-using-whenexpressions
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
  name: is-equal
spec:
  params:
  - name: left
    type: string
  - name: right
    type: string
  check:
    image: alpine
    script: |
      #!/bin/sh
      if [ $(params.left) = $(params.right) ]; then
        echo "$(params.left) == $(params.right)"
        exit 0
      else
        echo "$(params.left) != $(params.right)"
        exit 1
      fi
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: condition-pipeline
spec:
  params:
  - name: one
    type: string
  - name: two
    type: string
  tasks:
  - name: process
    conditions:
    - conditionRef: is-equal
      params:
        - name: left
          value: "1"
        - name: right
          value: $(params.one)
    - conditionRef: is-equal
      params:
        - name: left
          value: "1"
        - name: right
          value: $(params.two)
    taskRef:
      kind: Task
      name: run
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: run
spec:
  steps:
    - name: echo
      image: public.ecr.aws/ubuntu/ubuntu:latest
      script: 'echo hello'
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: condition-pipelinerun
spec:
  params:
  - name: one
    value: "1"
  - name: two
    value: "2"
  pipelineRef:
    name: condition-pipeline
