GitHub Action to split a single package from a monorepo into a standalone repository using splitsh-lite.
# .github/workflows/split-packages.yaml
name: Split Packages
on:
push:
branches:
- main
- '[0-9]+.[0-9]+'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
split:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- { directory: 'src/Component/Core', repository: 'Core' }
- { directory: 'src/Component/Product', repository: 'Product' }
- { directory: 'src/Bundle/CoreBundle', repository: 'CoreBundle' }
steps:
- name: Split ${{ matrix.package.repository }}
uses: SyliusLabs/SplitPackageAction@main
with:
directory: ${{ matrix.package.directory }}
repository: ${{ matrix.package.repository }}
token: ${{ secrets.SPLIT_TOKEN }}name: Split Packages (Manual)
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to split (leave empty if splitting a tag)'
required: false
tag:
description: 'Tag to split (takes priority over branch)'
required: false
jobs:
split:
runs-on: ubuntu-latest
steps:
- name: Split Core
uses: SyliusLabs/SplitPackageAction@main
with:
directory: 'src/Component/Core'
repository: 'Core'
token: ${{ secrets.SPLIT_TOKEN }}
branch: ${{ github.event.inputs.branch }}
tag: ${{ github.event.inputs.tag }}| Name | Description | Default | Required |
|---|---|---|---|
directory |
Source directory in monorepo to split (e.g., src/Component/Core) |
(empty) | yes |
repository |
Target repository name without org prefix (e.g., Core or CoreBundle) |
(empty) | yes |
token |
GitHub token with repo permissions for pushing to target repository | (empty) | yes |
branch |
Branch to split. Ignored if tag is specified. |
(empty) | no |
tag |
Tag to split. Takes priority over branch. |
(empty) | no |
organization |
Target organization/user for split repository | github.repository_owner |
no |
repository_prefix |
Prefix for target repository name (e.g., split- for testing) |
(empty) | no |
create_repo_if_missing |
Create target repository if it does not exist | true |
no |
- Resolves target ref - Determines whether to split a branch or tag based on the event type and inputs
- Validates ref exists - For manual dispatch, verifies the specified branch or tag exists
- Checks out repository - Fetches full git history required for splitting
- Installs splitsh-lite - Downloads and caches the splitsh-lite binary
- Creates target repository - If enabled and the target repository doesn't exist, creates it with the same visibility (public/private) as the monorepo
- Splits and pushes - Extracts the package history and pushes to the target repository
The token input requires a GitHub token (typically a Personal Access Token or GitHub App token) with the following permissions:
repo- Full control of private repositories (orpublic_repofor public repositories only)workflow- If the split repository contains GitHub Actions workflows
When splitting to an organization repository, the token owner must also be a member of the target organization with permission to create repositories (if create_repo_if_missing is enabled) and push to existing ones.
The default GITHUB_TOKEN cannot be used as it doesn't have permissions to push to other repositories.