-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,739 additions
and
3,677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# THIS IS BASE IMAGE | ||
FROM php:8.3-cli-alpine | ||
|
||
RUN apk add --no-cache git git-subtree | ||
|
||
RUN git config --system --add safe.directory /github/workspace | ||
|
||
RUN git config --system --add safe.directory /tmp/monorepo_split/build_directory | ||
|
||
# directory inside docker | ||
WORKDIR /splitter | ||
|
||
# make local content available inside docker - copies to /splitter | ||
COPY entrypoint.sh . | ||
|
||
# see https://nickjanetakis.com/blog/docker-tip-86-always-make-your-entrypoint-scripts-executable | ||
ENTRYPOINT ["sh", "/splitter/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: 'Monorepo Split' | ||
description: 'Split monorepo folder to repository' | ||
author: "Martin Poirier Théorêt <[email protected]>" | ||
|
||
inputs: | ||
user_name: | ||
description: 'Git User Name' | ||
required: true | ||
user_email: | ||
description: 'Git User Email' | ||
required: true | ||
access_token: | ||
description: 'GitHub Access Token' | ||
required: true | ||
git_ref: | ||
description: 'Git Ref' | ||
required: true | ||
source_repository: | ||
description: 'Source Repository' | ||
required: true | ||
source_directory: | ||
description: 'Local package directory' | ||
required: true | ||
target_repository: | ||
description: 'Target Repository' | ||
required: true | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
# "GitHub stores input parameters as environment variables" - important!!! | ||
- ${{ inputs.user_name }} # => INPUT_USER_NAME | ||
- ${{ inputs.user_email }} | ||
- ${{ inputs.access_token }} | ||
- ${{ inputs.git_ref }} | ||
- ${{ inputs.source_repository }} | ||
- ${{ inputs.source_directory }} | ||
- ${{ inputs.target_repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
echo "Configure git with user email ${INPUT_USER_EMAIL} and user name ${INPUT_USER_NAME}" | ||
git config --global user.email "${INPUT_USER_EMAIL}" | ||
git config --global user.name "${INPUT_USER_NAME}" | ||
|
||
echo "Clone the source repository repository https://github.com/${INPUT_SOURCE_REPOSITORY}" | ||
git clone https://${INPUT_ACCESS_TOKEN}@github.com/${INPUT_SOURCE_REPOSITORY} to_split | ||
cd to_split | ||
|
||
echo "Add the remote repository" | ||
git remote add split https://${INPUT_ACCESS_TOKEN}@github.com/${INPUT_TARGET_REPOSITORY}.git | ||
|
||
# Extract the tag or branch name from GITHUB_REF | ||
REF_NAME="${INPUT_GIT_REF##*/}" | ||
|
||
echo "INPUT_GIT_REF: ${INPUT_GIT_REF}" | ||
echo "REF_NAME: ${REF_NAME}" | ||
|
||
# Check if we are on a tag or branch | ||
if git show-ref --tags "$REF_NAME" >/dev/null 2>&1; then | ||
echo "We are on a tag" | ||
|
||
git checkout -b temp_branch ${REF_NAME} | ||
git subtree split --prefix=${INPUT_SOURCE_DIRECTORY} -b temp_split_branch | ||
git push split temp_split_branch:refs/tags/${REF_NAME} | ||
else | ||
echo "We are on a branch" | ||
|
||
git checkout ${REF_NAME} | ||
git subtree split --prefix=${INPUT_SOURCE_DIRECTORY} -b temp_split_branch | ||
git push split temp_split_branch:refs/heads/${REF_NAME} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Split Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
tags: | ||
- '*' | ||
|
||
jobs: | ||
split: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
packages: | ||
- application | ||
- aws-tool-kit | ||
- console | ||
- core | ||
- cron-job | ||
- dependency-injection | ||
- doctrine-extra | ||
- entity-migrator | ||
- fixer | ||
- framework-extra-bundle | ||
- log | ||
- mailer | ||
- messenger | ||
- open-api | ||
- process | ||
- profiling | ||
- security | ||
- sonata-import-bundle | ||
- sonata-integration-bundle | ||
- sonata-extra-bundle | ||
- tester | ||
- tester-bundle | ||
- user-bundle | ||
- validator | ||
- workflow | ||
steps: | ||
- | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- | ||
uses: "./.github/actions/git-split" | ||
with: | ||
user_name: 'mpoiriert' | ||
user_email: '[email protected]' | ||
access_token: '${{ secrets.GH_ACCESS_TOKEN }}' | ||
git_ref: '${{ github.ref }}' | ||
source_repository: 'mpoiriert/test-monorepo' | ||
source_directory: 'split/${{ matrix.packages }}' | ||
target_repository: 'mpoiriert/${{ matrix.packages }}' |
Oops, something went wrong.