Skip to main content
RunBook Academy

← All break/fix scenarios in Git, CI/CD & GitOps

advancedcicd-pipeline~30 min

Repository restructuring breaks pipeline (paths changed in actions)

Reported symptoms

  • CI workflows fail with `Error: Cannot find any files matching the pattern "infra/terraform/modules/**/main.tf"` or `no files matched the search pattern`
  • Workflow `paths` filters reference the old paths and now match nothing; workflows that should run on every PR no longer trigger
  • `actions/checkout` works (the checkout is the whole repo), but `paths-ignore` and `paths` filter out the workflow for every PR
  • Argo CD `Application`s whose `spec.source.path` points at `overlays/prod/<app>` now fail with `repository not found` or `path does not exist in repo`, depending on whether the path was renamed or moved
  • `git log --all --oneline --diff-filter=R --summary | grep "infra/terraform"` shows the renames in the recent history
  • Documentation links, CODEOWNERS entries, and Dependabot config files reference the old paths and now resolve to nothing
  • A `git mv` was performed locally and force-pushed; the new reflog entry shows the move was a rename (R) in the diff, but no follow-up touched the workflow files
  • The restructure PR was approved without a CI run that exercised the post-restructure paths (the PR was merged on the rename alone)

Evidence

  • · `git log --diff-filter=R --name-status | grep "R.*infra/terraform"` shows the file moves with their old and new paths
  • · `cat .github/workflows/ci.yml | grep -E "(paths|paths-ignore)"` references the old `infra/terraform/...` paths
  • · `kubectl get application -n argocd -o custom-columns=NAME:.metadata.name,PATH:.spec.source.path` lists paths that do not exist in the repo (`infra/terraform/<svc>` was renamed to `platform/infra/terraform/<svc>`)
  • · `git ls-tree HEAD infra/terraform/` returns empty; `git ls-tree HEAD platform/infra/terraform/` returns the renamed files
  • · CODEOWNERS references the old paths: `grep -E "infra/terraform" CODEOWNERS` returns matches that no longer resolve to a file in the repo
  • · `gh api repos/<org>/<repo>/contents/.github/dependabot.yml` shows `package-ecosystem: terraform` directories that match the old path; Dependabot now reports `Could not find any directories to check`
  • · A test PR that touches a file at the new path does not trigger the workflow whose `paths` filter still references the old path; the CI summary shows no runs
  • · `argocd app manifests <app>` fails with `Manifest generation error: path does not exist` because the Application `spec.source.path` no longer resolves in the repo
Diagnosis and resolutionclick to reveal

Root cause

Repository restructuring is a structural change: the move of a directory changes the meaning of every path that referenced it, including CI workflows (paths filters, `paths-ignore`, file globs in steps), GitOps `Application` manifests (`spec.source.path`), CODEOWNERS, Dependabot config, and documentation. The structural failure is treating the move as a single PR with only the file moves: the rename is half the change, and updating every reference is the other half. The references are usually invisible at PR review time because they live in workflow YAML, CRDs, and CODEOWNERS — not in the renamed files themselves. The result is a repo whose tree is correct but whose automation is broken, and the failure surfaces only at the next CI run, the next Argo CD sync, or the next Dependabot scan.

Remediation

Find every reference to the old paths. Run `git grep -l "infra/terraform/"` against the current `HEAD` to enumerate all text references; the diff-filter=R rename history confirms the moves but is not authoritative for downstream references. Update each in a single coordinated PR: workflow `paths` filters, `paths-ignore`, and any `run` steps that reference files at the old paths; Argo CD `Application.spec.source.path` fields; CODEOWNERS entries; Dependabot `directories` lists; and any documentation, runbook, or onboarding guide. For Argo CD specifically, edit the `Application` CRD in the cluster (`kubectl edit application -n argocd`) and update the `spec.source.path`, then sync — or update the Application manifest in git and let Argo CD reconcile. For CI, the workflow file in `.github/workflows/` must be updated to reference the new path; without the update, the `paths` filter excludes every PR touching the new path and the workflow silently stops running. Add a CI verifier that runs `git grep -l "<old-path>"` and fails the build if any reference to a renamed path remains; this should be a one-time check, run on the restructure PR and then removed once the tree is clean.

Verification

`git grep -l "infra/terraform/"` returns nothing (all references updated). A test PR that touches a file at the new path triggers the workflow (visible in the Actions tab). An Argo CD Application whose `spec.source.path` was updated shows `Sync Status: Synced` after the change; the manifests resolve and apply. CODEOWNERS references resolve to files in the new path. Dependabot scans the new directories and opens or suppresses PRs as expected. The restructure PR itself has a CI run that exercised the post-restructure paths and a comment confirming the workflow, Argo CD, CODEOWNERS, and Dependabot references were updated.

Prevention

A restructure is a structural change and must be planned as such. Before the move: enumerate every reference to the affected paths (CI workflows, Argo CD Applications, CODEOWNERS, Dependabot config, docs, runbooks) and update them in the same PR as the move. Use a single PR that includes the move and the reference updates, with a CI run that exercises the new paths and a CODEOWNERS-aware review. For larger restructures, use `git mv` and atomic commits so the rename history is clean; avoid a series of small moves that compound the risk of a stale reference. Add a CI verifier (a `git grep` against the old paths, or a `pathlint`-style tool) that runs on every PR and fails if any reference to a known-renamed path remains; the verifier can be scoped to a small set of recent renames and updated as the rename history ages out. For Argo CD, prefer Application manifests in git that use relative paths (`overlays/prod/<app>`) and ensure the Application `spec.source.path` is tracked in the same repo as the manifests, so a rename in one is a rename in the other. The principle is that a directory move is not a single change, it is a coordinated change across every reference, and the coordination must be in the same PR.

A directory move changes the meaning of every path that referenced it. The rename is half the change; updating CI workflows, Argo CD Applications, CODEOWNERS, and Dependabot is the other half. Plan the restructure as a single coordinated PR with a CI run that exercises the post-restructure paths, and add a verifier that fails any PR that leaves a reference to a renamed path behind.