From 04f83d30e957afb8bfacb7c62bc80088cf26ed57 Mon Sep 17 00:00:00 2001 From: PedroTroller Date: Fri, 23 Jun 2023 11:07:35 +0200 Subject: [PATCH] ci: try to split main repository into sub repositories --- .gitconfig | 2 + .github/workflows/build.yaml | 82 ------------------------------------ .github/workflows/split.yaml | 75 +++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 82 deletions(-) create mode 100644 .gitconfig delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/split.yaml diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 00000000..57623b3b --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[safe] + directory = "*" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index fae48d5a..00000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Build - -on: - pull_request: ~ - push: ~ - -jobs: - check: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - - name: Validate composer.json - run: composer validate --strict --no-check-lock - cs-fixer: - runs-on: ubuntu-20.04 - name: PHP-CS-Fixer - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.3' - - run: composer install --prefer-dist --no-interaction --no-progress --ansi - - run: vendor/bin/php-cs-fixer fix --diff --dry-run --verbose - tests: - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - include: - - description: 'Symfony 6.3 DEV' - php: '8.2' - symfony: '6.3.*@dev' - - description: 'Symfony 6.2' - php: '8.2' - symfony: '6.2.*' - - description: 'Symfony 6.0' - php: '8.1' - symfony: '6.0.*' - - description: 'Symfony 5.0' - php: '7.3' - symfony: '5.0.*' - - description: 'Symfony 4.4' - php: '7.1' - symfony: '4.3.*@dev' - - description: 'Symfony 3.4' - php: '7.3' - symfony: '3.4.*' - - description: 'Beta deps' - php: '7.2' - beta: true - name: PHP ${{ matrix.php }} tests (${{ matrix.description }}) - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Cache - uses: actions/cache@v3 - with: - path: ~/.composer/cache/files - key: composer-${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.composer_option }} - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - run: | - sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json; - if: matrix.symfony - - run: | - composer config minimum-stability dev - composer config prefer-stable true - if: matrix.beta - - name: remove cs-fixer for Symfony 6 - if: contains(matrix.symfony, '6.3.*@dev') - run: | - composer remove --dev friendsofphp/php-cs-fixer pedrotroller/php-cs-custom-fixer --no-update - - run: composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_option }} - - run: vendor/bin/phpunit - - run: vendor/bin/phpstan analyse --ansi --no-progress diff --git a/.github/workflows/split.yaml b/.github/workflows/split.yaml new file mode 100644 index 00000000..83ac4c1c --- /dev/null +++ b/.github/workflows/split.yaml @@ -0,0 +1,75 @@ +--- +name: 'Packages Split' + +on: + push: + branches: + - v2-unstable-* + - v2-unstable # Remove before releasing v2 + - master + tags: + - '*' + +env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + +concurrency: + group: "Packages Split" + cancel-in-progress: false + +jobs: + split: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - remote: 'knplabs/snappy-core' + path: 'src/Core' + - remote: 'knplabs/snappy-bundle' + path: 'src/Bundle' + - remote: 'knplabs/snappy-wkhtmltopdf' + path: 'src/Backend/WkHtmlToPdf' + steps: + - run: | + git config --global user.name "knpEdgar" + git config --global user.email "hello@knplabs.com" + - uses: actions/checkout@v2 + with: + path: ./monolyth + - run: mkdir ./readonly + - run: mkdir ./build + - name: git clone + run: | + cd ./readonly + git clone -- https://${{ secrets.ACCESS_TOKEN }}@github.com/${{ matrix.package.remote }} . + git fetch + - name: cleanup + run: cp --verbose -ra ./readonly/.git ./build/.git + - run: cp --verbose -ra ./monolyth/${{ matrix.package.path }}/* ./build + - run: ls -la ./build + - name: git add . + id: git_status + run: | + cd ./build + git status --porcelain + echo "STATUS=$(git status --porcelain)" >> $GITHUB_OUTPUT + git add . --verbose + - name: git commit + if: ${{ '' != steps.git_status.outputs.STATUS }} + run: | + cd ./monolyth + COMMIT_MESSAGE=$(git show -s --format=%B ${GITHUB_SHA}) + cd ../build + git commit --message "$COMMIT_MESSAGE" + - name: git push + if: ${{ '' != steps.git_status.outputs.STATUS }} + run: | + cd ./build + git push --quiet origin main + - name: git tag + if: "startsWith(github.ref, 'refs/tags/')" + run: | + cd ./build + git tag %s -m "${GITHUB_REF#refs/tags/}" + git push --quiet origin "${GITHUB_REF#refs/tags/}"