Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions bin/split-repo-workflow.yml

This file was deleted.

27 changes: 1 addition & 26 deletions bin/sync-split-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
set -euo pipefail

GITHUB_ORG="${GITHUB_ORG:-marko-php}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKFLOW_FILE="$SCRIPT_DIR/split-repo-workflow.yml"

# Prerequisites
command -v gh >/dev/null 2>&1 || { echo "Error: gh CLI not installed. https://cli.github.com"; exit 1; }
gh auth status >/dev/null 2>&1 || { echo "Error: Not authenticated with gh. Run: gh auth login"; exit 1; }

[[ -f "$WORKFLOW_FILE" ]] || { echo "Error: $WORKFLOW_FILE not found"; exit 1; }

# Allow targeting a single repo or all child repos
TARGET_REPO="${1:-}"

Expand All @@ -20,40 +16,19 @@ else
mapfile -t repos < <(gh repo list "$GITHUB_ORG" --limit 200 --json name --jq '.[].name' | grep -v '^marko$' | sort)
fi

WORKFLOW_CONTENT=$(base64 < "$WORKFLOW_FILE")
WORKFLOW_PATH=".github/workflows/close-pull-requests.yml"

echo "Syncing split repo config for ${#repos[@]} repo(s)..."

for repo in "${repos[@]}"; do
full_repo="${GITHUB_ORG}/${repo}"
echo " ${full_repo}..."

# Configure repo settings (idempotent)
# Configure repo settings (idempotent, safe on empty repos).
gh api "repos/${full_repo}" \
--method PATCH \
--field has_projects=false \
--field homepage="https://github.com/marko-php/marko" \
--silent 2>/dev/null || true

# Push the workflow file (create or update)
existing_sha=$(gh api "repos/${full_repo}/contents/${WORKFLOW_PATH}" --jq '.sha' 2>/dev/null || echo "")

if [[ -n "$existing_sha" ]]; then
gh api "repos/${full_repo}/contents/${WORKFLOW_PATH}" \
--method PUT \
--field message="chore: update close-pull-requests workflow" \
--field content="$WORKFLOW_CONTENT" \
--field sha="$existing_sha" \
--silent
else
gh api "repos/${full_repo}/contents/${WORKFLOW_PATH}" \
--method PUT \
--field message="chore: add close-pull-requests workflow" \
--field content="$WORKFLOW_CONTENT" \
--silent
fi

echo " ✓ done"
done

Expand Down