From 9ff63d697a0089149b3bd29c3998bc5ff80c94ac Mon Sep 17 00:00:00 2001 From: James Amner Date: Fri, 24 May 2024 11:19:03 +0100 Subject: [PATCH] Use SplitSH to split monorepo --- .github/workflows/packages.yml | 41 +++++++++++----------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index acb8f69..576540a 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -4,8 +4,8 @@ on: push: branches: - main - tags: - - "*" + # tags: # Todo - handle tags, ie publishing a new version from the mono-repo to all the sub-repos. + # - "*" permissions: contents: write @@ -40,30 +40,15 @@ jobs: - name: Remove `/packages/*/build` from gitignore run: | sed -i '/\/packages\/\*\/build/d' .gitignore - - # no tag - - name: Split Monorepo - if: "!startsWith(github.ref, 'refs/tags/')" - uses: "symplify/monorepo-split-github-action@v2.3.0" - env: - GITHUB_TOKEN: ${{ secrets.BOXUK_WP_ROBOT_ACCESS_TOKEN }} - with: - package_directory: "packages/${{ matrix.packages.local_path }}" - repository_organization: "boxuk" - repository_name: "${{ matrix.packages.target_repo }}" - user_name: "BoxUK Automated Package Management" - user_email: "developers@boxuk.com" - # with tag - - name: Split Monorepo with Tag - if: "startsWith(github.ref, 'refs/tags/')" - uses: "symplify/monorepo-split-github-action@v2.3.0" - env: - GITHUB_TOKEN: ${{ secrets.BOXUK_WP_ROBOT_ACCESS_TOKEN }} - with: - tag: ${GITHUB_REF#refs/tags/} - package_directory: "packages/${{ matrix.packages.local_path }}" - repository_organization: "boxuk" - repository_name: "${{ matrix.packages.target_repo }}" - user_name: "BoxUK Automated Package Management" - user_email: "developers@boxuk.com" + - name: Install Splitsh + shell: bash + run: | + apt-get update && apt-get install -y libgit2 golang-go + go build -o splitsh-lite github.com/splitsh/lite + - name: Split MonoRepo + shell: bash + run: | + git remote add ${{ matrix.packages.target_repo }} git@github.com:boxuk/${{ matrix.packages.target_repo }}.git || true + SHA1=`splitsh-lite --prefix=pacakges/${{ matrix.packages.local_path }}` + git push ${{ matrix.packages.target_repo }} "$SHA1:refs/heads/main" -f