ci: sanitize orphan submodule configs before sync/update to avoid missing .gitmodules entries
Some checks failed
dev-test-2 / build-and-push (push) Failing after 5s

This commit is contained in:
Nicolas Cantu 2025-09-10 13:40:33 +02:00
parent 1d1f21be74
commit a5de9701cb

View File

@ -31,6 +31,17 @@ jobs:
password: ${{ secrets.TOKEN }}
- name: Init submodules (ensure up-to-date)
run: |
echo "Sanitize submodule config"
ALLOWED_PATHS=$(git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $3}' || true)
for NAME in $(git config --local --name-only --get-regexp '^submodule\..*\.path$' | sed 's/\.path$//' || true); do
P=$(git config --local --get "$NAME.path" || true)
if ! printf "%s\n" "$ALLOWED_PATHS" | grep -qx "$P"; then
echo "[ci] deinit orphan submodule: $P ($NAME)"
git submodule deinit -f -- "$P" || true
git config --local --remove-section "$NAME" || true
rm -rf ".git/modules/$P" || true
fi
done
git submodule sync --recursive
git submodule update --init --recursive
- name: Build and push images