Skip to content
Latchkey

How to Sync Shared Files Across Repos With Bot Pull Requests

Syncing files across repos means a job checks out each target, writes the canonical file, and opens a PR so each repo reviews the change before merging.

A workflow in the template repo loops over targets: check out each with a token, copy the canonical file in, and open a PR with peter-evans/create-pull-request so nothing lands unreviewed.

Steps

  • Keep the canonical file in a template repo.
  • Check out each target repo into its own path with a cross-repo token.
  • Copy the file in and open a pull request per target.

Sync workflow

.github/workflows/sync-files.yml
jobs:
  sync:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        repo: [api, web, worker]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/checkout@v4
        with:
          repository: my-org/${{ matrix.repo }}
          path: target
          token: ${{ secrets.CROSS_REPO_PAT }}
      - run: cp .github/editorconfig-canonical target/.editorconfig
      - uses: peter-evans/create-pull-request@v6
        with:
          path: target
          token: ${{ secrets.CROSS_REPO_PAT }}
          commit-message: "chore: sync .editorconfig"
          branch: sync/editorconfig
          title: "Sync .editorconfig from template"

Gotchas

  • Open a PR rather than pushing directly so each repo owner can review and CI can validate.
  • Use a stable branch name so re-runs update the existing PR instead of piling up new ones.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →