CICD-221 · Changed-directory detection
Encyclopedia · Advanced workflow orchestration · All snippets
Previous · CICD-220 · Next · CICD-222
1. Where it fits
- Placement CI run step or authorized lab terminal.
- Prerequisites authenticated GitHub CLI, approved target repositories, or Actions runner for YAML entries.
- Platforms local-linux, github-actions, gitea-actions.
- Parameters
BASE_SHA.
2. Copy the snippet
bash
git diff --name-only -z "${BASE_SHA:?}...HEAD" -- services/ | python -c 'import sys; print("\n".join(sorted({p.split(b"/")[1].decode() for p in sys.stdin.buffer.read().split(b"\0") if p.count(b"/") >= 2})))'3. How it works
The three-dot Git range compares HEAD with the merge base. The NUL-delimited list survives spaces in filenames and the projection extracts service directory names.
4. Verify the result
Fetch the base and merge base first. Expect one service name per changed directory, including tracked deletions.
Validation syntax-validated (Bash parse). Status definitions.