Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

ci: mirror sdk/php to a standalone repo for Packagist (git subtree split)

Yudhi Armyndharisbc526b3850fe
diff --git a/.github/workflows/split-php-sdk.yml b/.github/workflows/split-php-sdk.yml
new file mode 100644
index 000000000..075215a56
--- /dev/null
+++ b/.github/workflows/split-php-sdk.yml
@@ -0,0 +1,56 @@
+name: Split PHP SDK
+
+# Mirrors the PHP SDK (sdk/php) into the standalone repo rmyndharis/openwa-php,
+# which is what Packagist installs (Packagist needs composer.json at a repo root
+# and does not support subdirectories). Uses a dependency-free `git subtree
+# split` + force-push — no third-party action.
+#
+# IMPORTANT: this only syncs the `main` branch (-> Packagist `dev-main`). The
+# monorepo's `v*` tags are the APP version, NOT the SDK version, so they are
+# deliberately NOT propagated. To cut a versioned SDK release, tag the mirror
+# repo directly (see sdk/php — RELEASING below), e.g. `git tag 0.1.0`.
+#
+# One-time setup:
+# 1. Create an empty GitHub repo: rmyndharis/openwa-php
+# 2. Create a PAT (fine-grained, repo = openwa-php, Contents: read & write)
+# 3. Add it to THIS repo as the secret PHP_SDK_SPLIT_TOKEN
+
+on:
+ push:
+ branches: [main]
+ paths: ['sdk/php/**']
+ workflow_dispatch: {}
+
+permissions:
+ contents: read
+
+concurrency:
+ group: split-php-sdk
+ cancel-in-progress: false
+
+jobs:
+ split:
+ name: Mirror sdk/php -> rmyndharis/openwa-php
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ with:
+ fetch-depth: 0 # full history is required for `git subtree split`
+
+ - name: Split and force-push to the mirror repo
+ env:
+ SPLIT_TOKEN: ${{ secrets.PHP_SDK_SPLIT_TOKEN }}
+ run: |
+ set -euo pipefail
+ if [ -z "${SPLIT_TOKEN:-}" ]; then
+ echo "::notice::PHP_SDK_SPLIT_TOKEN is not set — skipping. Create rmyndharis/openwa-php and add the secret to enable the mirror."
+ exit 0
+ fi
+ git config user.name "rmyndharis"
+ git config user.email "[email protected]"
+ SPLIT_SHA="$(git subtree split --prefix=sdk/php HEAD)"
+ echo "Split SHA: $SPLIT_SHA"
+ git push --force \
+ "https://x-access-token:${SPLIT_TOKEN}@github.com/rmyndharis/openwa-php.git" \
+ "${SPLIT_SHA}:refs/heads/main"
+ echo "Mirrored sdk/php -> rmyndharis/openwa-php@main"