Skip to content

Commit 9881cc8

Browse files
committed
CI deploys – setup gh token
1 parent e916274 commit 9881cc8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bin/split-code.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -euo pipefail
33

44
# ---- Config (override with env vars) ----
5+
# Set GH_TOKEN environment variable for CI authentication (will use HTTPS instead of SSH)
56
DEFAULT_BRANCH="${DEFAULT_BRANCH:-trunk}"
67
VISIBILITY="${VISIBILITY:-public}" # public|private|internal (internal only for orgs)
78
TOPICS="${TOPICS:-php,composer,monorepo,split}"
@@ -49,7 +50,14 @@ create_repo_if_needed() {
4950

5051
split_and_push() {
5152
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
5361

5462
echo "==> Splitting ${pkg_dir} -> ${org}/${repo_name}"
5563

@@ -65,7 +73,7 @@ split_and_push() {
6573
git checkout -q "${DEFAULT_BRANCH}"
6674
fi
6775
git remote remove origin 2>/dev/null || true
68-
git remote add origin "$repo_ssh"
76+
git remote add origin "$repo_url"
6977
git push -u origin --all
7078
git push origin --tags || true
7179
popd >/dev/null
@@ -74,7 +82,7 @@ split_and_push() {
7482
# Fallback: subtree split creates a synthetic branch with the path history
7583
local split_branch="split-$(basename "$pkg_dir")-$(date +%s)"
7684
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}"
7886
# Push tags that include this history is non-trivial with subtree; skipping here
7987
git branch -D "$split_branch" >/dev/null
8088
fi

0 commit comments

Comments
 (0)