|
1 | 1 | name: Split PHP package to auto-html-i18n-php |
2 | 2 |
|
3 | | -# Mirrors packages/php/ to the auto-html-i18n-php repo with full git history. |
4 | | -# That mirror is what Packagist watches — it's the single source of "the PHP package as a standalone repo". |
5 | | -# - Push to main → mirror the latest main branch (so the default branch on the split repo stays current) |
6 | | -# - Push tag v* → mirror with the tag attached, which is what triggers Packagist to create a new version |
| 3 | +# Mirrors packages/php/ to the auto-html-i18n-php repo using splitsh/lite — preserves |
| 4 | +# git history so the split repo looks like a real package, not a flat dump. |
| 5 | +# Push to main → main (latest source). Tag push or workflow_dispatch with tag → tag (frozen version). |
7 | 6 | on: |
8 | 7 | push: |
9 | 8 | branches: [main] |
|
16 | 15 | type: string |
17 | 16 |
|
18 | 17 | jobs: |
19 | | - split-php: |
| 18 | + split: |
20 | 19 | runs-on: ubuntu-latest |
21 | 20 | steps: |
22 | 21 | - uses: actions/checkout@v4 |
23 | 22 | with: |
24 | | - fetch-depth: 0 # full history required for clean subtree split |
| 23 | + fetch-depth: 0 # full history needed for splitsh |
25 | 24 |
|
26 | | - - name: Split packages/php → auto-html-i18n-php |
27 | | - uses: symplify/monorepo-split-github-action@v2.3.0 |
| 25 | + - uses: webfactory/ssh-agent@v0.9.1 |
28 | 26 | with: |
29 | | - package_directory: packages/php |
30 | | - repository_organization: gabepri |
31 | | - repository_name: auto-html-i18n-php |
32 | | - branch: main |
33 | | - tag: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || (github.ref_type == 'tag' && github.ref_name) || '' }} |
34 | | - user_name: gabepri |
35 | | - user_email: gabepriyev@incentfit.com |
| 27 | + ssh-private-key: ${{ secrets.PHP_SPLIT_DEPLOY_KEY }} |
| 28 | + |
| 29 | + - name: Trust github.com SSH host key |
| 30 | + run: | |
| 31 | + mkdir -p ~/.ssh && chmod 700 ~/.ssh |
| 32 | + ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null |
| 33 | +
|
| 34 | + - name: Install splitsh-lite |
| 35 | + run: | |
| 36 | + curl -sL https://github.com/splitsh/lite/releases/download/v2.0.0/lite_linux_amd64.tar.gz | tar -xz -C /tmp |
| 37 | + sudo mv /tmp/splitsh-lite /usr/local/bin/ |
| 38 | +
|
| 39 | + - name: Determine ref to mirror |
| 40 | + id: ref |
| 41 | + run: | |
| 42 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then |
| 43 | + echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 44 | + echo "checkout=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 45 | + elif [[ "${{ github.ref_type }}" == "tag" ]]; then |
| 46 | + echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 47 | + echo "checkout=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 48 | + else |
| 49 | + echo "tag=" >> "$GITHUB_OUTPUT" |
| 50 | + echo "checkout=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Checkout target ref |
| 54 | + run: git checkout "${{ steps.ref.outputs.checkout }}" |
| 55 | + |
| 56 | + - name: Split packages/php and push |
36 | 57 | env: |
37 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
38 | | - SSH_PRIVATE_KEY: ${{ secrets.PHP_SPLIT_DEPLOY_KEY }} |
| 58 | + TAG: ${{ steps.ref.outputs.tag }} |
| 59 | + run: | |
| 60 | + set -euo pipefail |
| 61 | + git remote add split git@github.com:gabepri/auto-html-i18n-php.git |
| 62 | + SHA=$(splitsh-lite --prefix=packages/php) |
| 63 | + echo "Split SHA: $SHA" |
| 64 | + if [ -z "$TAG" ]; then |
| 65 | + echo "Mirroring main → main" |
| 66 | + git push split "$SHA:refs/heads/main" |
| 67 | + else |
| 68 | + echo "Mirroring $TAG → tag $TAG" |
| 69 | + git push split --force "$SHA:refs/tags/$TAG" |
| 70 | + fi |
0 commit comments