diff --git a/.tekton/tasks/task-switchboard.yaml b/.tekton/tasks/task-switchboard.yaml index b4cb4a2495..4c496b9266 100644 --- a/.tekton/tasks/task-switchboard.yaml +++ b/.tekton/tasks/task-switchboard.yaml @@ -46,15 +46,18 @@ spec: ec opa check --v1-compatible "${rules}" - pr_number="$(gh search prs --repo konflux-ci/build-definitions "$(params.revision)" --json number --jq '.[].number')" + rev="$(params.revision)" + changed_files=() + for pr_number in $(gh search prs --repo konflux-ci/build-definitions "${rev}" --json number --jq '.[].number'); do + echo "Found revision ${rev} in pull request number ${pr_number}" - echo "Determined pull request number ${pr_number}" - - changed="$(gh pr view "https://github.com/konflux-ci/build-definitions/pull/${pr_number}" --json files --jq '[.files.[].path'])" - echo Changed files: - echo "${changed}" | jq -r '.[]' + changed="$(gh pr view "https://github.com/konflux-ci/build-definitions/pull/${pr_number}" --json files --jq '[.files.[].path'])" + echo Changed files: + echo "${changed}" | jq -r '.[]' + changed_files+=("${changed}") + done - echo "${changed}" | ec opa eval --v1-compatible --data "${rules}" --stdin-input \ + echo "${changed_files[@]}" | jq -s 'add | unique' | ec opa eval --v1-compatible --data "${rules}" --stdin-input \ 'data[_]' \ | jq '[.result.[].expressions.[].value | to_entries | .[] | select(.value == true) | .key]' \ | tee "$(results.bindings.path)"