Skip to content

Commit

Permalink
gitops-pull-request: skip EC when no image changed
Browse files Browse the repository at this point in the history
task/gather-deploy-images:

Return a "boolean" result that indicates whether there are any images
to check.

---

pipelines/gitops-pull-request-rhtap:

Run the EC task only if gather-deploy-images gathers some images.
Otherwise, the last step of the task (assert) would fail.

Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Mar 19, 2024
1 parent d1bee10 commit 1955039
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pipelines/gitops-pull-request-rhtap/gitops-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ spec:
value: $(params.ec-tuf-mirror)
runAfter:
- gather-deploy-images
when:
- input: $(tasks.gather-deploy-images.results.NOTHING_TO_VERIFY)
operator: notin
values: ["true"]
taskRef:
name: verify-enterprise-contract
version: "0.1"
1 change: 1 addition & 0 deletions task/gather-deploy-images/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Extract images from deployment YAML to pass to EC for validation
|name|description|
|---|---|
|IMAGES_TO_VERIFY|The images to be verified, in a format compatible with https://github.com/redhat-appstudio/build-definitions/tree/main/task/verify-enterprise-contract/0.1|
|NOTHING_TO_VERIFY|"true" if there are no images to be verified, "false" otherwise|

## Workspaces
|name|description|optional|
Expand Down
5 changes: 5 additions & 0 deletions task/gather-deploy-images/0.1/gather-deploy-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
results:
- name: IMAGES_TO_VERIFY
description: The images to be verified, in a format compatible with https://github.com/redhat-appstudio/build-definitions/tree/main/task/verify-enterprise-contract/0.1
- name: NOTHING_TO_VERIFY
description: '"true" if there are no images to be verified, "false" otherwise'
steps:
- name: get-images-per-env
image: quay.io/redhat-appstudio/appstudio-utils:5bd7d6cb0b17f9f2eab043a8ad16ba3d90551bc2@sha256:8c7fcf86af40c71aeb58e4279625c8308af5144e2f6b8e28b0ec7e795260e5f7
Expand Down Expand Up @@ -61,3 +63,6 @@ spec:
"components": map({"containerImage": .})
}
' | tee $(results.IMAGES_TO_VERIFY.path)
nothing_to_verify=$(jq '.components | length == 0' $(results.IMAGES_TO_VERIFY.path))
printf "%s" "$nothing_to_verify" > $(results.NOTHING_TO_VERIFY.path)

0 comments on commit 1955039

Please sign in to comment.