4b05ad5e86
The detection script was missing infra/, org/, Dockerfile, docker-compose*, and Makefile patterns required by the SDLC spec. Added 11 new test cases covering these patterns. Co-Authored-By: Paperclip <noreply@paperclip.ing>
50 lines
1.3 KiB
Bash
Executable File
50 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Reads a newline-separated list of changed files from stdin.
|
|
# Outputs "pipeline-a" or "pipeline-b" to stdout.
|
|
# Pipeline B: all files are infra-only (config, docs, workflows).
|
|
# Pipeline A: any non-infra file present.
|
|
|
|
detect_pipeline() {
|
|
local all_infra=true
|
|
|
|
while IFS= read -r file; do
|
|
[ -z "$file" ] && continue
|
|
|
|
local filename
|
|
local dir
|
|
filename=$(basename "$file")
|
|
dir=$(dirname "$file")
|
|
|
|
if [[ "$dir" == ".github" || "$dir" == .github/* ]] || \
|
|
[[ "$dir" == "infra" || "$dir" == infra/* ]] || \
|
|
[[ "$dir" == "org" || "$dir" == org/* ]] || \
|
|
[[ "$filename" == *.md ]] || \
|
|
[[ "$filename" == .eslintrc* ]] || \
|
|
[[ "$filename" == .prettierrc* ]] || \
|
|
[[ "$filename" == renovate.json* ]] || \
|
|
[[ "$filename" == .gitignore ]] || \
|
|
[[ "$filename" == .editorconfig ]] || \
|
|
[[ "$filename" == LICENSE ]] || \
|
|
[[ "$filename" == Dockerfile ]] || \
|
|
[[ "$filename" == docker-compose* ]] || \
|
|
[[ "$filename" == Makefile ]]; then
|
|
continue
|
|
else
|
|
all_infra=false
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ "$all_infra" = true ]; then
|
|
echo "pipeline-b"
|
|
else
|
|
echo "pipeline-a"
|
|
fi
|
|
}
|
|
|
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
detect_pipeline
|
|
fi
|