diff --git a/task/acs-determine-image-tag/0.1/README.md b/task/acs-determine-image-tag/0.1/README.md new file mode 100644 index 0000000000..53a3a9adfc --- /dev/null +++ b/task/acs-determine-image-tag/0.1/README.md @@ -0,0 +1,23 @@ +# acs-determine-image-tag task + +## Description + +The `acs-determine-image-tag` Task will determine the tag for the output image using the StackRox convention from 'make tag' output. + +## Params + +| name | description | +|-----------------|-------------------------------------------------------------------------------------| +| IMAGE_TAG_STYLE | Image Tag style to be used, valid options are 'main' or 'operator'. | +| SOURCE_ARTIFACT | The Trusted Artifact URI pointing to the artifact with the application source code. | +| TAG_SUFFIX | Suffix to add to the make tag output. | + +## Results + +| name | description | +|-------------------|-------------------------------| +| IMAGE_TAG | Image Tag determined by custom logic. | + +## Additional links + +- [stackrox/stackrox](https://github.com/stackrox/stackrox) diff --git a/task/acs-determine-image-tag/0.1/acs-determine-image-tag.yaml b/task/acs-determine-image-tag/0.1/acs-determine-image-tag.yaml new file mode 100644 index 0000000000..319990beca --- /dev/null +++ b/task/acs-determine-image-tag/0.1/acs-determine-image-tag.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: acs-determine-image-tag + labels: + app.kubernetes.io/version: "0.1" +spec: + description: The acs-determine-image-tag Task will determine the tag for the + output image using the StackRox convention from 'make tag' output. + params: + - name: TAG_SUFFIX + description: Suffix to append to generated image tag. + type: string + - name: SOURCE_ARTIFACT + description: The Trusted Artifact URI pointing to the artifact with + the application source code. This should be the result of the git-clone task, + results from other tasks might fail as dirty. + type: string + - name: IMAGE_TAG_STYLE + description: Image Tag style to be used, valid options are 'main' or 'operator'. + type: string + default: main + results: + - name: IMAGE_TAG + description: Image Tag determined by custom logic. + volumes: + - name: workdir + emptyDir: {} + stepTemplate: + volumeMounts: + - mountPath: /var/workdir + name: workdir + steps: + - name: use-trusted-artifact + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d + args: + - use + - $(params.SOURCE_ARTIFACT)=/var/workdir/source + - name: determine-image-tag + image: quay.io/konflux-ci/appstudio-utils:ab6b0b8e40e440158e7288c73aff1cf83a2cc8a9@sha256:24179f0efd06c65d16868c2d7eb82573cce8e43533de6cea14fec3b7446e0b14 + workingDir: /var/workdir/source + script: | + #!/usr/bin/env bash + set -euo pipefail + + .konflux/scripts/fail-build-if-git-is-dirty.sh + image_tag="" + image_tag_style="$(params.IMAGE_TAG_STYLE)" + case "$image_tag_style" in + main) + image_tag="$(make --quiet --no-print-directory tag)$(params.TAG_SUFFIX)" + ;; + operator) + image_tag="$(make -C operator --quiet --no-print-directory tag)$(params.TAG_SUFFIX)" + ;; + *) + echo >&2 "Invalid IMAGE_TAG_STYLE '$image_tag_style'" + exit 1 + ;; + esac + echo -n "$image_tag" | tee "$(results.IMAGE_TAG.path)"