66 paths :
77 - ' implementations/php/**'
88 - ' .github/workflows/php-split.yml'
9+ workflow_dispatch :
10+ inputs :
11+ tag :
12+ description : ' Tag to split (leave empty for branch-only split)'
13+ required : false
14+ type : string
15+ workflow_call :
16+ inputs :
17+ tag :
18+ description : ' Tag to split (leave empty for branch-only split)'
19+ required : false
20+ type : string
21+ default : ' '
922
1023jobs :
1124 split :
@@ -24,13 +37,64 @@ jobs:
2437 private-key : ${{ secrets.SPLIT_APP_PRIVATE_KEY }}
2538 owner : kduma-OSS-splits
2639
27- - uses : danharrin/monorepo-split-github-action@v2.3.0
40+ - name : Initialize split repo if empty
41+ env :
42+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
43+ run : |
44+ set -euo pipefail
45+ REPO="kduma-OSS-splits/PHP-PCF-lib"
46+ TMPDIR=$(mktemp -d)
47+ git clone "https://x-access-token:${GH_TOKEN}@github.com/$REPO.git" "$TMPDIR" 2>&1 || true
48+ if ! git -C "$TMPDIR" rev-parse HEAD >/dev/null 2>&1; then
49+ echo "Repository $REPO is empty, initializing master with empty commit..."
50+ git -C "$TMPDIR" checkout -b master
51+ git -C "$TMPDIR" config user.name "github-actions[bot]"
52+ git -C "$TMPDIR" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53+ git -C "$TMPDIR" commit --allow-empty -m "Initial commit"
54+ git -C "$TMPDIR" push origin master
55+ else
56+ echo "Repository $REPO already has commits, skipping initialization"
57+ fi
58+ rm -rf "$TMPDIR"
59+
60+ - name : Resolve tag
61+ id : resolve-tag
62+ run : |
63+ if [[ -n "${{ inputs.tag }}" ]]; then
64+ echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
65+ elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
66+ echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
67+ else
68+ echo "tag=" >> "$GITHUB_OUTPUT"
69+ fi
70+
71+ - name : Checkout tag
72+ if : steps.resolve-tag.outputs.tag != ''
73+ run : git checkout "refs/tags/${{ steps.resolve-tag.outputs.tag }}"
74+
75+ - name : Split (no tag)
76+ if : steps.resolve-tag.outputs.tag == ''
77+ uses : danharrin/monorepo-split-github-action@v2.4.0
78+ env :
79+ PAT : x-access-token:${{ steps.app-token.outputs.token }}
2880 with :
2981 package_directory : ' implementations/php'
3082 repository_organization : ' kduma-OSS-splits'
3183 repository_name : ' PHP-PCF-lib'
84+ branch : ' master'
3285 user_name : ' github-actions[bot]'
3386 user_email : ' 41898282+github-actions[bot]@users.noreply.github.com'
34- branch : ' master'
87+
88+ - name : Split (with tag)
89+ if : steps.resolve-tag.outputs.tag != ''
90+ uses : danharrin/monorepo-split-github-action@v2.4.0
3591 env :
36- GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
92+ PAT : x-access-token:${{ steps.app-token.outputs.token }}
93+ with :
94+ tag : ${{ steps.resolve-tag.outputs.tag }}
95+ package_directory : ' implementations/php'
96+ repository_organization : ' kduma-OSS-splits'
97+ repository_name : ' PHP-PCF-lib'
98+ branch : ' master'
99+ user_name : ' github-actions[bot]'
100+ user_email : ' 41898282+github-actions[bot]@users.noreply.github.com'
0 commit comments