Skip to Content
Platform FeaturesCI/CDMonorepos

Working with monorepos

A Stagenet’s CI/CD setup handles two common monorepo shapes: a single repository where contracts live in a subdirectory, and multiple repositories grouped under one Stagenet.

Contracts in a subdirectory

When your Hardhat or Foundry project isn’t at the repository root — for example contracts live under packages/contracts/ in a Yarn or Nx workspace — set Project root to that subdirectory.

The Stagenet runs install and compile commands from this directory, and the Artifact Selection include/exclude globs are evaluated relative to it.

For example:

my-monorepo/ ├── apps/ │ └── web/ └── packages/ ├── contracts/ ← set Project root: packages/contracts │ ├── foundry.toml │ ├── src/ │ └── lib/ └── sdk/

With Project root set to packages/contracts, the Stagenet runs forge install and forge build inside that directory and imports the artifacts it produces.

Multiple repositories under one Stagenet

A Stagenet can connect to several GitHub repositories at once. Each one is set up the same way as the first — go to CI/CD → Add Repository and configure it independently.

This is useful when:

  • Your protocol’s contracts are split across multiple repos (e.g. core, periphery, hooks).
  • You’re integrating with a third-party repo whose contracts you also want recognized.
  • Different teams own different parts of the deployment and each has their own repo.

Each repository has its own Build Configuration, compilation history, and Imported Contracts. They share the same Stagenet — so a contract from any connected repo can trigger a Workspace activation when deployed.

A repository can only be connected to a project once, so if you have two independent Hardhat/Foundry projects inside a single repo, run a single compile command that builds both (for example forge build at the repo root if they share a build, or a chained cd packages/core && forge build && cd ../packages/periphery && forge build) and use Include patterns to import from both locations.

Last updated on