set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/util.sh"
found_unused=0
mapfile -t ci_scripts < <(find scripts/ci -type f -perm +111 | sort)
if [ ${#ci_scripts[@]} -eq 0 ]; then
warn "No scripts found in scripts/ci/"
exit 0
fi
info "Checking that all scripts in scripts/ci/ are referenced in GitHub Actions workflows..."
for script in "${ci_scripts[@]}"; do
if grep -q "${script}" .github/workflows/*.yml 2>/dev/null; then
info "✓ ${script}"
else
warn "${script} - NOT FOUND in any workflow"
found_unused=1
fi
done
if [ ${found_unused} -ne 0 ]; then
err "Some scripts in scripts/ci/ are not referenced in any workflow. Either use these scripts in a workflow or remove them if they're no longer needed."
else
info "All scripts in scripts/ci/ are in active use!"
exit 0
fi