diff --git a/.tekton/push.yaml b/.tekton/push.yaml index e8cca52499..5c70e22641 100644 --- a/.tekton/push.yaml +++ b/.tekton/push.yaml @@ -148,6 +148,11 @@ spec: value: "$(params.revision)" - name: GIT_URL value: "$(params.git-url)" + - name: GITHUB_TOKEN + valueFrom: + secretKeyRef: + name: "{{ git_auth_secret }}" + key: "git-provider-token" script: | #!/bin/bash set -euo pipefail diff --git a/.tekton/scripts/build-acceptable-bundles.sh b/.tekton/scripts/build-acceptable-bundles.sh index 6a2b9599a3..3034baa96f 100755 --- a/.tekton/scripts/build-acceptable-bundles.sh +++ b/.tekton/scripts/build-acceptable-bundles.sh @@ -7,10 +7,14 @@ set -o pipefail DATA_BUNDLE_REPO="${DATA_BUNDLE_REPO:-quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles}" mapfile -t BUNDLES < <(cat "$@") +pr_number=$(gh search prs --repo konflux-ci/build-definitions --merged "${REVISION}" --json number --jq '.[].number') + +# changed files in a PR +mapfile -t changed_files < <(gh pr view "https://github.com/konflux-ci/build-definitions/pull/${pr_number}" --json files --jq '.files.[].path') # store a list of changed task files task_records=() # loop over all changed files -for path in $(git log -m -1 --name-only --pretty="format:" "${REVISION}"); do +for path in "${changed_files[@]}"; do # check that the file modified is the task file if [[ "${path}" == task/*/*/*.yaml ]]; then IFS='/' read -r -a path_array <<< "${path}" @@ -30,6 +34,11 @@ printf '%s\n' "${task_records[@]}" echo "Bundles to be added:" printf '%s\n' "${BUNDLES[@]}" +if [[ -z ${task_records[*]} && -z ${BUNDLES[*]} ]]; then + echo Nothing to do... + exit 0 +fi + # The OPA data bundle is tagged with the current timestamp. This has two main # advantages. First, it prevents the image from accidentally not having any tags, # and getting garbage collected. Second, it helps us create a timeline of the