#!/usr/bin/env bash # ci-cd.yml › detect — which checks does this pull request need? # Compares the PR head's folder tree hashes with the target branch's. Tree hashes are content # addressed, so this needs no merge-base and works on depth-1 clones. # shellcheck source=common.sh source "$(dirname "${BASH_SOURCE[0]}")/common.sh" : "${BASE_REF:?BASE_REF (the PR target branch) is required}" base="refs/remotes/origin/$BASE_REF" git_remote fetch -q --depth 1 "$REPO_GIT_URL" "+refs/heads/$BASE_REF:$base" # changed — succeeds if any path differs between the target branch and HEAD. changed() { local p for p in "$@"; do if [[ "$(tree_hash "$p")" != "$(tree_hash "$p" "$base")" ]]; then return 0; fi done return 1 } flag() { if changed "$@"; then echo true; else echo false; fi; } set_output backend "$(flag "$BACKEND_PATH" "$BACKEND_TESTS_PATH" Backend/ERPCore.sln)" set_output frontend "$(flag "$FRONTEND_PATH")" set_output e2e "$(flag "$E2E_PATH")" set_output scripts "$(flag deploy .gitea)" set_output frontend_hash "$(tree_hash "$FRONTEND_PATH")"