---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: buildah-knative
  namespace: openshift
  labels:
    pipeline.openshift.io/strategy: docker
    pipeline.openshift.io/type: knative
  annotations:
    operator.tekton.dev/preserve-namespace: "true"
spec:
  params:
    - name: APP_NAME
      type: string
    - name: GIT_REPO
      type: string
    - name: GIT_REVISION
      type: string
    - name: IMAGE_NAME
      type: string
  workspaces:
    - name: workspace
  tasks:
    - name: fetch-repository
      taskRef:
        name: git-clone
        kind: ClusterTask
      workspaces:
        - name: output
          workspace: workspace
      params:
        - name: url
          value: $(params.GIT_REPO)
        - name: revision
          value: $(params.GIT_REVISION)
        - name: subdirectory
          value: ""
        - name: deleteExisting
          value: "true"

    - name: build
      taskRef:
        name: buildah
        kind: ClusterTask
      runAfter:
        - fetch-repository
      workspaces:
        - name: source
          workspace: workspace
      params:
        - name: IMAGE
          value: $(params.IMAGE_NAME)
        - name: TLSVERIFY
          value: "false"

    - name: kn-service-create
      taskRef:
        name: kn
        kind: ClusterTask
      runAfter:
        - build
      params:
        - name: ARGS
          value: ["service", "create", "$(params.APP_NAME)", "--image=$(params.IMAGE_NAME)", "--force"]
