Multiple Repos per Skiff2 Project
This guide walks you through the manual steps of adding multiple repositories to a single Skiff2 GCP project.
In this scenario, you will have one "primary" repository that is added to the Skiff2 project config via the repo property,
and one or more "remote" repositories that are added to the Skiff2 project config via the remoteRepos property to deploy services to the same GCP project.
For the sake of Example, we will refer to the primary repository as allenai/primary-repo and the remote repository as allenai/remote-repo.
Step 1: Set up Project
Make sure you have set up a Skiff2 application project following the Getting Started guide, referencing the primary repository
in the *-project-config.json. In addition to setting up the primary repository, you will also configure any remote repositories by adding them to the
remoteRepos array. This will also add the appropriate permissions to the GCP project to allow these remote repositories to deploy to it. This will
also add the appropriate variables to the Github Actions workflow in the remote repositories like the primary repository.
{
"repo": "allenai/primary-repo",
"remoteRepos": [
"allenai/remote-repo"
],
...
}
See Getting Started for creating a new Skiff2 project referencing the primary repository.
Step 2: Set up skiff2.json files
See the skiff2.json reference for more information on options available.
Merge changes into the remote repository's main branch before merging into the primary repository's main branch, to make sure infra deployment in the primary repository has the necessary assets to deploy remote services.
The dependsOn property in skiff2.json is not currently supported for services deployed from a remote repository, so make sure to avoid using this property for any remote services.
Primary Repository skiff2.json
If you followed the Getting Started guide, your primary repository should
have a skiff2.json file in its root directory describing the services deployed from that repository. In addition to
describing the services deployed from the primary repository, you must also include descriptions of the services deployed
from the remote repository in the primary repository's skiff2.json file via the remoteServices property.
This is necessary to ensure that Infra setup is aware of all the services deployed to the GCP project and can manage them properly.
{
"services": [
{
"name": "service",
"cwd": ".",
"isRootService": true,
"customDomain": [
"service.example.com"
],
}
],
"remoteServices": [
{
"name": "other-service",
"customDomain": [
"other-service.example.com"
]
}
]
}
Remote Repository skiff2.json
The remote repository must also have a skiff2.json file in its root directory. This file should only describe the services deployed from the remote repository,
and should not include any services deployed from the primary repository.
{
"services": [
{
"name": "other-service",
"cwd": ".",
"customDomain": [
"other-service.example.com"
]
}
]
}
Step 3: Set up Github Actions workflow in Remote Repository
The remote repository must have a Github Actions workflow configured to deploy the services described in its skiff2.json file.
Just copy the same workflow that was set up in the primary repository to the remote repository,
making sure to remove the step associated with Skiff2 Deploy Infra:
...
# Remove this step from remote repository workflow
# - name: Skiff2 Deploy Infra
# if: github.ref_name == 'main'
# uses: allenai/skiff2-actions/shared-actions/deploy-infra@main
# with:
# project_id: ${{ vars.SKIFF2_PROJECT_ID }}
# command: apply
...
Skiff2 Deploy Infra should only be ran from the primary repository to prevent configuration collisions in the GCP project.
Summary
To have multiple repositories associated with the same Skiff2 GCP project, you need to:
- Set up a primary repository and Skiff2 project as normal, following the Getting Started guide
and add any remote repositories to the Skiff2 project config via the
remoteReposproperty - Add a
skiff2.jsonto the remote repository describing the services deployed from that repository, and make sure the primary repository'sskiff2.jsonalso describes these services with deploy disabled - Set up a Github Actions workflow in the remote repository to deploy the services described in its
skiff2.json, making sure to remove theSkiff2 Deploy Infrastep from the remote repository's workflow