2
2
set -euo pipefail
3
3
4
4
# ---- Config (override with env vars) ----
5
+ # Set GH_TOKEN environment variable for CI authentication (will use HTTPS instead of SSH)
5
6
DEFAULT_BRANCH=" ${DEFAULT_BRANCH:- trunk} "
6
7
VISIBILITY=" ${VISIBILITY:- public} " # public|private|internal (internal only for orgs)
7
8
TOPICS=" ${TOPICS:- php,composer,monorepo,split} "
@@ -49,7 +50,14 @@ create_repo_if_needed() {
49
50
50
51
split_and_push () {
51
52
local pkg_dir=" $1 " org=" $2 " repo_name=" $3 "
52
- local repo_ssh=
" [email protected] :${org} /${repo_name} .git"
53
+ local repo_url
54
+
55
+ # Use HTTPS with token if GH_TOKEN is available, otherwise fall back to SSH
56
+ if [[ -n " ${GH_TOKEN:- } " ]]; then
57
+ repo_url=" https://${GH_TOKEN} @github.com/${org} /${repo_name} .git"
58
+ else
59
+ repo_url=
" [email protected] :${org} /${repo_name} .git"
60
+ fi
53
61
54
62
echo " ==> Splitting ${pkg_dir} -> ${org} /${repo_name} "
55
63
@@ -65,7 +73,7 @@ split_and_push() {
65
73
git checkout -q " ${DEFAULT_BRANCH} "
66
74
fi
67
75
git remote remove origin 2> /dev/null || true
68
- git remote add origin " $repo_ssh "
76
+ git remote add origin " $repo_url "
69
77
git push -u origin --all
70
78
git push origin --tags || true
71
79
popd > /dev/null
@@ -74,7 +82,7 @@ split_and_push() {
74
82
# Fallback: subtree split creates a synthetic branch with the path history
75
83
local split_branch=" split-$( basename " $pkg_dir " ) -$( date +%s) "
76
84
git subtree split --prefix=" $pkg_dir " -b " $split_branch " > /dev/null
77
- git push " $repo_ssh " " $split_branch :${DEFAULT_BRANCH} "
85
+ git push " $repo_url " " $split_branch :${DEFAULT_BRANCH} "
78
86
# Push tags that include this history is non-trivial with subtree; skipping here
79
87
git branch -D " $split_branch " > /dev/null
80
88
fi
0 commit comments