|
| 1 | +# @format |
| 2 | + |
| 3 | +name: 'Packages Split' |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + tags: |
| 10 | + - '*' |
| 11 | + |
| 12 | +env: |
| 13 | + # 1. for Github split |
| 14 | + GITHUB_TOKEN: ${{ secrets.SPLIT_TOKEN }} |
| 15 | +jobs: |
| 16 | + packages-matrix: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + matrix: ${{ steps.matrix.outputs.content }} |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v2 |
| 23 | + - name: Set up PHP |
| 24 | + uses: shivammathur/setup-php@v2 |
| 25 | + with: |
| 26 | + php-version: "${{ inputs.php-version || '8.3' }}" |
| 27 | + - name: PHP Install Dependencies |
| 28 | + uses: ramsey/composer-install@v3 |
| 29 | + with: |
| 30 | + composer-options: '--no-dev --no-scripts' |
| 31 | + - name: Generate package matrix |
| 32 | + id: matrix |
| 33 | + run: | |
| 34 | + echo "content=$(composer show --direct --path --format=json | jq -c --arg pwd "$(pwd)/packages" '{target: [.installed[] | select((.path | startswith($pwd)) and (.source != null)) | { path: (.path | sub($pwd + "/"; "")), organization: (.name | split("/")[0]), name: (.name | split("/")[1])}]}')" >> $GITHUB_OUTPUT |
| 35 | + packages-split: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: packages-matrix |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: ${{ fromJSON(needs.packages-matrix.outputs.matrix) }} |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + # no tag |
| 44 | + - if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 45 | + uses: symplify/monorepo-split-github-action@v2.3.0 |
| 46 | + with: |
| 47 | + # Split the package directory based on the matrix |
| 48 | + package_directory: '${{ matrix.target.path }}' |
| 49 | + |
| 50 | + # Use the organization from the matrix |
| 51 | + repository_organization: '${{ github.repository_owner }}' |
| 52 | + |
| 53 | + # Use the repository name from the matrix |
| 54 | + repository_name: '${{ matrix.target.name }}' |
| 55 | + |
| 56 | + # Use the current committer's username and email for the split commit |
| 57 | + user_name: '${{ github.actor }}' |
| 58 | + user_email: '${{ github.event.pusher.email }}' |
| 59 | + |
| 60 | + # with tag |
| 61 | + - if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 62 | + uses: symplify/monorepo-split-github-action@v2.3.0 |
| 63 | + with: |
| 64 | + tag: ${GITHUB_REF#refs/tags/} |
| 65 | + |
| 66 | + # Split the package directory based on the matrix |
| 67 | + package_directory: '${{ matrix.target.path }}' |
| 68 | + |
| 69 | + # Use the organization from the matrix |
| 70 | + repository_organization: '${{ github.repository_owner }}' |
| 71 | + |
| 72 | + # Use the repository name from the matrix |
| 73 | + repository_name: '${{ matrix.target.name }}' |
| 74 | + |
| 75 | + # Use the current committer's username and email for the split commit |
| 76 | + user_name: '${{ github.actor }}' |
| 77 | + user_email: '${{ github.event.pusher.email }}' |
0 commit comments