---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  labels:
    app.kubernetes.io/instance: guestbook
    app.kubernetes.io/name: guestbook
    operator.tekton.dev/operand-name: openshift-pipelines-addons
    pipeline.openshift.io/strategy: docker
    pipeline.openshift.io/type: kubernetes
  name: guestbook-deploy
  namespace: guestbook
spec:
  params:
    - default: guestbook
      name: APP_NAME
      type: string
    - default: 'https://github.com/jmhbnz/talks.git'
      name: GIT_REPO
      type: string
    - default: main
      name: GIT_REVISION
      type: string
    - default: 'image-registry.openshift-image-registry.svc:5000/guestbook/guestbook'
      name: IMAGE_NAME
      type: string
    - default: 2023-07-31-acs-workflows/guestbook
      name: PATH_CONTEXT
      type: string
  tasks:
    - name: fetch-repository
      params:
        - name: url
          value: $(params.GIT_REPO)
        - name: revision
          value: $(params.GIT_REVISION)
        - name: subdirectory
          value: ''
        - name: deleteExisting
          value: 'true'
      taskRef:
        kind: ClusterTask
        name: git-clone
      workspaces:
        - name: output
          workspace: workspace
    - name: image-scan
      params:
        - name: image
          value: image-registry.openshift-image-registry.svc:5000/guestbook/guestbook
        - name: rox_api_token
          value: roxsecrets
        - name: rox_central_endpoint
          value: roxsecrets
        - name: output_format
          value: json
      runAfter:
        - fetch-repository
      taskRef:
        kind: ClusterTask
        name: rox-image-scan
    - name: image-check
      params:
        - name: image
          value: image-registry.openshift-image-registry.svc:5000/guestbook/guestbook
        - name: rox_api_token
          value: roxsecrets
        - name: rox_central_endpoint
          value: roxsecrets
      runAfter:
        - image-scan
      taskRef:
        kind: ClusterTask
        name: rox-image-check
    - name: deploy
      params:
        - name: SCRIPT
          value: ls -la && oc apply -f 2023-07-31-acs-workflows/guestbook/manifests/deployment.yaml && oc rollout status deploy/$(params.APP_NAME)
      runAfter:
        - image-check
      taskRef:
        kind: ClusterTask
        name: openshift-client
      workspaces:
        - name: manifest-dir
          workspace: workspace
  workspaces:
    - name: workspace
