Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
maximize-2

GitHub Action

Monorepo Split

2.0

Monorepo Split

maximize-2

Monorepo Split

Split monorepo packages to many repositories

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Monorepo Split

uses: danharrin/[email protected]

Learn more about this action in danharrin/monorepo-split-github-action

Choose a version

GitHub Action for Monorepo Split

Do you have a monorepo project on GitHub and need split packages to many repositories? Add this GitHub Action to your workflow and let it split your packages on every commit and tag.

How does the Split Result Look Like?

This repository splits tests into symplify/monorepo-split-github-action-test repository.

Not on every commit, but only if contents of /tests/packages/some-package directory changes. Try it yourself - send PR with change in that directory.


Config

Split is basically git push or local directory to remote git repository. This remote repository can be located on GitHub or Gitlab. To be able to do that, it needs GITHUB_TOKEN or GITLAB_TOKEN with write repository access:

env:
    GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

Make sure to add this access token in "Secrets" of package settings: https://github.com/<organization>/<package>/settings/secrets/actions


Split Packages Without and With Tag

name: 'Packages Split'

on:
    push:
        branches:
            - main
        tags:
            - '*'

jobs:
    packages_split:
        runs-on: ubuntu-latest

        steps:
            -
                uses: actions/checkout@v2
                # this is required for "WyriHaximus/github-action-get-previous-tag" workflow
                # see https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
                with:
                    fetch-depth: 0

            # no tag
            -
                if: "!startsWith(github.ref, 'refs/tags/')"
                uses: "symplify/[email protected]"
                with:
                    # ↓ split "packages/easy-coding-standard" directory
                    package-directory: 'packages/easy-coding-standard'

                    # ↓ into https://github.com/symplify/easy-coding-standard repository
                    split-repository-organization: 'symplify'
                    split-repository-name: 'easy-coding-standard'

                    # ↓ the user signed under the split commit
                    user-name: "kaizen-ci"
                    user-email: "[email protected]"

            # with tag
            -
                if: "startsWith(github.ref, 'refs/tags/')"
                uses: "symplify/[email protected]"
                with:
                    tag: ${GITHUB_REF#refs/tags/}

                    # ↓ split "packages/easy-coding-standard" directory
                    package-directory: 'packages/easy-coding-standard'

                    # ↓ into https://github.com/symplify/easy-coding-standard repository
                    split-repository-organization: 'symplify'
                    split-repository-name: 'easy-coding-standard'

                    # ↓ the user signed under the split commit
                    user-name: "kaizen-ci"
                    user-email: "[email protected]"