Split PHP package to auto-html-i18n-php #7
This file contains hidden or 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
| name: Split PHP package to auto-html-i18n-php | |
| # Mirrors packages/php/ to the auto-html-i18n-php repo using splitsh/lite — preserves | |
| # git history so the split repo looks like a real package, not a flat dump. | |
| # Push to main → main (latest source). Tag push or workflow_dispatch with tag → tag (frozen version). | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to mirror (leave blank to mirror main only)' | |
| required: false | |
| type: string | |
| jobs: | |
| split: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # full history needed for splitsh | |
| - uses: webfactory/ssh-agent@v0.9.1 | |
| with: | |
| ssh-private-key: ${{ secrets.PHP_SPLIT_DEPLOY_KEY }} | |
| - name: Trust github.com SSH host key | |
| run: | | |
| mkdir -p ~/.ssh && chmod 700 ~/.ssh | |
| ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null | |
| - name: Install splitsh-lite | |
| run: | | |
| mkdir -p /tmp/splitsh | |
| curl -sL https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz | tar -xz -C /tmp/splitsh | |
| sudo mv /tmp/splitsh/splitsh-lite /usr/local/bin/ | |
| - name: Determine ref to mirror | |
| id: ref | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then | |
| echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" | |
| echo "checkout=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" | |
| elif [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| echo "checkout=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=" >> "$GITHUB_OUTPUT" | |
| echo "checkout=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout target ref | |
| run: git checkout "${{ steps.ref.outputs.checkout }}" | |
| - name: Split packages/php and push | |
| env: | |
| TAG: ${{ steps.ref.outputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| git remote add split git@github.com:gabepri/auto-html-i18n-php.git | |
| SHA=$(splitsh-lite --prefix=packages/php) | |
| echo "Split SHA: $SHA" | |
| if [ -z "$TAG" ]; then | |
| echo "Mirroring main → main" | |
| git push split "$SHA:refs/heads/main" | |
| else | |
| echo "Mirroring $TAG → tag $TAG" | |
| git push split --force "$SHA:refs/tags/$TAG" | |
| fi |