@@ -3,7 +3,8 @@ name: Update .gitignore
33on :
44 push :
55 paths :
6- - " **/.gitignore"
6+ - " apps/**/.gitignore"
7+ - " experimental/**/.gitignore"
78 - " .gitignore.initial"
89 workflow_dispatch :
910
@@ -22,12 +23,24 @@ jobs:
2223 run : |
2324 # Start with the initial .gitignore file
2425 cp .gitignore.initial .gitignore
25-
26- # Find all .gitignore files one level down, process each with its path prefix
27- find . -mindepth 2 -maxdepth 2 -name ".gitignore" | while read -r gitignore_file; do
28- dir_path=$(dirname "$gitignore_file" | sed 's|^\./||')
29- echo -e "\n# Patterns from $dir_path/.gitignore" >> .gitignore
30- sed "s|^|$dir_path/|" "$gitignore_file" >> .gitignore
26+
27+ # Process each known parent directory in order.
28+ # Patterns are prefixed with the full path from the repo root so
29+ # they work correctly from the top-level .gitignore.
30+ # The section header names the parent directory so the origin of
31+ # each block is clear.
32+ for parent_dir in apps experimental; do
33+ if [ ! -d "$parent_dir" ]; then
34+ continue
35+ fi
36+
37+ find "$parent_dir" -mindepth 2 -maxdepth 2 -name ".gitignore" | sort | \
38+ while read -r gitignore_file; do
39+ dir_path=$(dirname "$gitignore_file")
40+ echo "" >> .gitignore
41+ echo "# [$parent_dir] $dir_path/.gitignore" >> .gitignore
42+ sed "s|^|$dir_path/|" "$gitignore_file" >> .gitignore
43+ done
3144 done
3245
3346 - name : Check for changes
4659 git config --global user.email "github-actions[bot]@users.noreply.github.com"
4760 git add .gitignore
4861 git commit -m "Update top-level .gitignore with directory paths"
49- git push
62+ git push origin HEAD:${GITHUB_REF_NAME}
0 commit comments