apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  annotations:
    build.appstudio.openshift.io/repo: https://github.com/openshift/source-to-image?rev={{revision}}
    build.appstudio.redhat.com/commit_sha: '{{revision}}'
    build.appstudio.redhat.com/target_branch: '{{target_branch}}'
    pipelinesascode.tekton.dev/max-keep-runs: "3"
    pipelinesascode.tekton.dev/on-cel-expression: |
      event == "push" &&
      target_branch == "master" &&
      (
        files.all.exists(x, x.matches('cmd/|pkg/')) ||
        files.all.exists(x, x.matches('go.mod|go.sum|rhel8.Dockerfile')) ||
        files.all.exists(x, x.matches('.tekton/source-to-image-rhel8-push.yaml'))
      )
  creationTimestamp: null
  labels:
    appstudio.openshift.io/application: source-to-image
    appstudio.openshift.io/component: source-to-image-rhel8
    pipelines.appstudio.openshift.io/type: build
  name: source-to-image-rhel8-on-push
  namespace: ocp-tools-s2i-tenant
spec:
  params:
  - name: git-url
    value: '{{source_url}}'
  - name: revision
    value: '{{revision}}'
  - name: output-image
    value: quay.io/redhat-user-workloads/ocp-tools-s2i-tenant/source-to-image-rhel8:{{revision}}
  - name: dockerfile
    value: rhel8.Dockerfile
  - name: build-source-image
    value: "true"
  - name: hermetic
    value: "true"
  - name: run-unit-test
    value: "true"
  - name: build-platforms
    value:
    - linux/x86_64
    - linux/arm64
    - linux/ppc64le
    - linux/s390x
  - name: prefetch-input
    value: '{"packages": [{"type": "gomod"}]}'
  pipelineSpec:
    params:
      - description: Source Repository URL
        name: git-url
        type: string
      - default: ""
        description: Revision of the Source Repository
        name: revision
        type: string
      - name: component
        type: string
        default: ""
        description: "Component name"
      - name: branch
        type: string
        default: ""
      - name: repository-url
        type: string
        default: ""
      - name: test-event
        type: string
        default: ""
      - name: pull-request-number
        type: string
        default: ""
      - description: Fully Qualified Output Image
        name: output-image
        type: string
      - default: .
        description: Path to the source code of an application's component from where
          to build image.
        name: path-context
        type: string
      - default: Dockerfile
        description: Path to the Dockerfile inside the context specified by parameter
          path-context
        name: dockerfile
        type: string
      - default: "false"
        description: Force rebuild image
        name: rebuild
        type: string
      - default: "false"
        description: Skip checks against built image
        name: skip-checks
        type: string
      - default: "false"
        description: Execute the build with network isolation
        name: hermetic
        type: string
      - default: ""
        description: Build dependencies to be prefetched by Cachi2
        name: prefetch-input
        type: string
      - default: "false"
        description: Enable dev-package-managers in prefetch task
        name: prefetch-dev-package-managers
        type: string
      - default: ""
        description: Image tag expiration time, time values could be something like
          1h, 2d, 3w for hours, days, and weeks, respectively.
        name: image-expires-after
      - default: "false"
        description: Build a source image.
        name: build-source-image
        type: string
      - default: "true"
        description: Add built image into an OCI image index
        name: build-image-index
        type: string
      - default: []
        description: Array of --build-arg values ("arg=value" strings) for buildah
        name: build-args
        type: array
      - default: ""
        description: Path to a file with build arguments for buildah, see https://www.mankier.com/1/buildah-build#--build-arg-file
        name: build-args-file
        type: string
      - default:
          - linux/x86_64
        description: List of platforms to build the container images on. The available
          set of values is determined by the configuration of the multi-platform-controller.
        name: build-platforms
        type: array
      - default: "true"
        description: Whether to append the platform string to the end of the build image tag
        name: image-append-platform
        type: string
      - default: "false"
        description: Set 'true' to run unit tests
        name: run-unit-test
        type: string
      - default: docker
        description: The format for the resulting image's mediaType. Valid values are oci (default) or docker.
        name: buildah-format
        type: string
    results:
      - description: ""
        name: IMAGE_URL
        value: $(tasks.build-image-index.results.IMAGE_URL)
      - description: ""
        name: IMAGE_DIGEST
        value: $(tasks.build-image-index.results.IMAGE_DIGEST)
      - description: ""
        name: CHAINS-GIT_URL
        value: $(tasks.clone-repository.results.url)
      - description: ""
        name: CHAINS-GIT_COMMIT
        value: $(tasks.clone-repository.results.commit)
    finally:
      - name: show-sbom
        params:
          - name: IMAGE_URL
            value: $(tasks.build-image-index.results.IMAGE_URL)
        taskRef:
          params:
            - name: name
              value: show-sbom
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-show-sbom:0.1@sha256:beb0616db051952b4b861dd8c3e00fa1c0eccbd926feddf71194d3bb3ace9ce7
            - name: kind
              value: task
          resolver: bundles
    tasks:
      - name: init
        params:
          - name: image-url
            value: $(params.output-image)
          - name: rebuild
            value: $(params.rebuild)
          - name: skip-checks
            value: $(params.skip-checks)
        taskRef:
          params:
            - name: name
              value: init
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:b349d24cb896573695802d6913d311640b44675ec082b3ad167721946a6a0a71
            - name: kind
              value: task
          resolver: bundles
      - name: clone-repository
        params:
          - name: url
            value: $(params.git-url)
          - name: revision
            value: $(params.revision)
          - name: ociStorage
            value: $(params.output-image).git
          - name: ociArtifactExpiresAfter
            value: $(params.image-expires-after)
        runAfter:
          - init
        taskRef:
          params:
            - name: name
              value: git-clone-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta:0.1@sha256:0a89e1a6304076525e9766f63a4cd006763d21d5aca6863281fc427537a23c6f
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(tasks.init.results.build)
            operator: in
            values:
              - "true"
        workspaces:
          - name: basic-auth
            workspace: git-auth
      - name: prefetch-dependencies
        params:
          - name: input
            value: $(params.prefetch-input)
          - name: SOURCE_ARTIFACT
            value: $(tasks.clone-repository.results.SOURCE_ARTIFACT)
          - name: ociStorage
            value: $(params.output-image).prefetch
          - name: ociArtifactExpiresAfter
            value: $(params.image-expires-after)
          - name: dev-package-managers
            value: $(params.prefetch-dev-package-managers)
        runAfter:
          - clone-repository
        taskRef:
          params:
            - name: name
              value: prefetch-dependencies-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-prefetch-dependencies-oci-ta:0.2@sha256:3e5e834290a1ed57fd14c0082e5a10789c8fe382ed682ef7f981475a7b316b49
            - name: kind
              value: task
          resolver: bundles
        workspaces:
          - name: git-basic-auth
            workspace: git-auth
          - name: netrc
            workspace: netrc
      - name: unit-test
        runAfter:
          - prefetch-dependencies
        taskRef:
          name: source-to-image-unit-test
        params:
          - name: SOURCE_ARTIFACT
            value: $(tasks.clone-repository.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        when:
          - input: $(params.run-unit-test)
            operator: in
            values:
              - "true"
      - matrix:
          params:
            - name: PLATFORM
              value:
                - $(params.build-platforms)
        name: build-images
        params:
          - name: IMAGE
            value: $(params.output-image)
          - name: DOCKERFILE
            value: $(params.dockerfile)
          - name: CONTEXT
            value: $(params.path-context)
          - name: HERMETIC
            value: $(params.hermetic)
          - name: PREFETCH_INPUT
            value: $(params.prefetch-input)
          - name: IMAGE_EXPIRES_AFTER
            value: $(params.image-expires-after)
          - name: COMMIT_SHA
            value: $(tasks.clone-repository.results.commit)
          - name: BUILD_ARGS
            value:
              - $(params.build-args[*])
          - name: BUILD_ARGS_FILE
            value: $(params.build-args-file)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
          - name: IMAGE_APPEND_PLATFORM
            value: $(params.image-append-platform)
          - name: BUILDAH_FORMAT
            value: $(params.buildah-format)
        runAfter:
          - prefetch-dependencies
          - unit-test
        taskRef:
          params:
            - name: name
              value: buildah-remote-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-buildah-remote-oci-ta:0.7@sha256:ef1c062b10c9fb17951350de76bce6bb54a4ea75fca4f37ea136d626c444bf78
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(tasks.init.results.build)
            operator: in
            values:
              - "true"
      - name: build-image-index
        params:
          - name: IMAGE
            value: $(params.output-image)
          - name: COMMIT_SHA
            value: $(tasks.clone-repository.results.commit)
          - name: IMAGE_EXPIRES_AFTER
            value: $(params.image-expires-after)
          - name: ALWAYS_BUILD_INDEX
            value: $(params.build-image-index)
          - name: IMAGES
            value:
              - $(tasks.build-images.results.IMAGE_REF[*])
          - name: BUILDAH_FORMAT
            value: $(params.buildah-format)
        runAfter:
          - build-images
        taskRef:
          params:
            - name: name
              value: build-image-index
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.2@sha256:39561ac43e325159497c10c0284cf61dfddf39e39100ca5e3df6b73c5d96db8b
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(tasks.init.results.build)
            operator: in
            values:
              - "true"
      - name: build-source-image
        params:
          - name: BINARY_IMAGE
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: BINARY_IMAGE_DIGEST
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: source-build-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-source-build-oci-ta:0.3@sha256:4abb2dbc9dcfad52d56b490a2f25f99989a2cb2bbd9881223025272db60fd75e
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(tasks.init.results.build)
            operator: in
            values:
              - "true"
          - input: $(params.build-source-image)
            operator: in
            values:
              - "true"
      - name: deprecated-base-image-check
        params:
          - name: IMAGE_URL
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: IMAGE_DIGEST
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: deprecated-image-check
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-deprecated-image-check:0.5@sha256:462baed733dfc38aca5395499e92f19b6f13a74c2e88fe5d86c3cffa2f899b57
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: clair-scan
        params:
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: clair-scan
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-clair-scan:0.3@sha256:a5fa66ed5b8c107e7bc29cb084edcc07e394f818cc59ef2db2f9dcb0cd1fa3dc
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: ecosystem-cert-preflight-checks
        params:
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: ecosystem-cert-preflight-checks
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-ecosystem-cert-preflight-checks:0.2@sha256:04f75593558f79a27da2336400bc63d460bf0c5669e3c13f40ee2fb650b1ad1e
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: sast-snyk-check
        params:
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: sast-snyk-check-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-sast-snyk-check-oci-ta:0.4@sha256:0eca130f289a1a1069a1b92943479f79aa7324e4e68d6396fd777ccd97058f50
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: clamav-scan
        params:
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: clamav-scan
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.3@sha256:f3d2d179cddcc07d0228d9f52959a233037a3afa2619d0a8b2effbb467db80c3
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: sast-coverity-check
        params:
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: IMAGE
            value: $(params.output-image)
          - name: DOCKERFILE
            value: $(params.dockerfile)
          - name: CONTEXT
            value: $(params.path-context)
          - name: HERMETIC
            value: $(params.hermetic)
          - name: PREFETCH_INPUT
            value: $(params.prefetch-input)
          - name: IMAGE_EXPIRES_AFTER
            value: $(params.image-expires-after)
          - name: COMMIT_SHA
            value: $(tasks.clone-repository.results.commit)
          - name: BUILD_ARGS
            value:
              - $(params.build-args[*])
          - name: BUILD_ARGS_FILE
            value: $(params.build-args-file)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        runAfter:
          - coverity-availability-check
        taskRef:
          params:
            - name: name
              value: sast-coverity-check-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-sast-coverity-check-oci-ta:0.3@sha256:78f5244a8cfd28c890ed62db7e4ff1fc97ff39876d37fb19f1b0c2c286a4002c
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
          - input: $(tasks.coverity-availability-check.results.STATUS)
            operator: in
            values:
              - success
      - name: coverity-availability-check
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: coverity-availability-check
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-coverity-availability-check:0.2@sha256:36400873d3031df128c55aa71ee11d322c3e55fd8f13dc5779098fbc117c0aa3
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: sast-shell-check
        params:
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: sast-shell-check-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-sast-shell-check-oci-ta:0.1@sha256:d44336d7bcbd1f7cedee639357a493bd1f661e2859e49e11a34644bdf6819c4e
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: sast-unicode-check
        params:
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
          - name: CACHI2_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: sast-unicode-check-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-sast-unicode-check-oci-ta:0.3@sha256:e5a8d3e8e7be7246a1460385b95c084ea6e8fe7520d40fe4389deb90f1bf5176
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
      - name: apply-tags
        params:
          - name: IMAGE
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: IMAGE_URL
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: IMAGE_DIGEST
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: apply-tags
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.2@sha256:e4017ec351a0891ef95989f35bd20b8c3f091fa1a3da364c4d4e975e99f3063c
            - name: kind
              value: task
          resolver: bundles
      - name: push-dockerfile
        params:
          - name: IMAGE
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: IMAGE_DIGEST
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
          - name: DOCKERFILE
            value: $(params.dockerfile)
          - name: CONTEXT
            value: $(params.path-context)
          - name: SOURCE_ARTIFACT
            value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: push-dockerfile-oci-ta
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-push-dockerfile-oci-ta:0.1@sha256:08bba4a659ecd48f871bef00b80af58954e5a09fcbb28a1783ddd640c4f6535e
            - name: kind
              value: task
          resolver: bundles
      - name: rpms-signature-scan
        params:
          - name: image-url
            value: $(tasks.build-image-index.results.IMAGE_URL)
          - name: image-digest
            value: $(tasks.build-image-index.results.IMAGE_DIGEST)
        runAfter:
          - build-image-index
        taskRef:
          params:
            - name: name
              value: rpms-signature-scan
            - name: bundle
              value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:0b10508c82ccb0f5a06a66ce7af56e9bfd40651ddefdf0f499988e897771ee28
            - name: kind
              value: task
          resolver: bundles
        when:
          - input: $(params.skip-checks)
            operator: in
            values:
              - "false"
    workspaces:
      - name: git-auth
        optional: true
      - name: netrc
        optional: true
  taskRunTemplate:
    serviceAccountName: build-pipeline-source-to-image-rhel8
status: {}
