GitHub Action
Splitsh Lite Action
Splitsh Lite for Github Actions
A Github Action that allows you to split your monorepo into multiple repositories using splitsh lite.
-
Create a new file in your repository at
.github/workflows/split.yml
-
Copy the following content into the
split.yml
file:name: 'Split monorepo' on: push: branches: - master - '*.x' tags: - 'v*' jobs: split: runs-on: ubuntu-latest strategy: fail-fast: false matrix: package: [ 'package-one', 'package-two' ] steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Split package ${{ matrix.package }} uses: "claudiodekker/splitsh-action@1.0.0" env: GITHUB_TOKEN: ${{ secrets.MONOREPO_SPLITTER_PERSONAL_ACCESS_TOKEN }} with: prefix: "packages/${{ matrix.package }}" remote: "https://github.com/your-username/subsplit-of-${{ matrix.package }}.git" reference: "${{ github.ref_name }}" as_tag: "${{ startsWith(github.ref, 'refs/tags/') }}"
-
Modify the
matrix
'spackage
property to reflect your to-be-split packages (above:package-one
andpackage-two
). -
Modify the
prefix
property to reflect the path to your package in your monorepo. In the above example, the packages are located in apackages/
directory. -
Modify the
remote
property to reflect the URL of the repository you want to split your package into. In the above example, the packages are split tohttps://github.com/your-username/subsplit-of-package-one.git
andhttps://github.com/your-username/subsplit-of-package-two.git
. -
Add a
MONOREPO_SPLITTER_PERSONAL_ACCESS_TOKEN
to your repository's secrets. This is a personal access token with therepo
scope, and is used to push the split repository to GitHub. You can create a new token here. If your monorepo's package directory contains a.github/workflows/
folder, you'll likely need to add theworkflow
scope to the token as well, as otherwise the splitter cannot push the changes to your repository. -
Commit and push the file to your (monorepo) repository.
Once done, the GitHub Action will automatically split your monorepo into the target repositories when a commit is added to the provided branches (in the above example, master
, 1.x
, 2.x
etc.), or when a new tag (e.g. v1.0.0
) is added to the repository.