Skip to content

Commit ecc9d0a

Browse files
committed
default to main on empty repo
1 parent 27e6a83 commit ecc9d0a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/onboard-new-repo.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ jobs:
3939
4040
# Auto-detect default branch from the repository
4141
echo "Detecting default branch for $REPO..."
42-
BASE_BRANCH=$(gh api "repos/$REPO" --jq '.default_branch')
42+
BASE_BRANCH=$(gh api "repos/$REPO" --jq '.default_branch' 2>/dev/null || echo "")
43+
44+
# If repo is empty or API call failed, default to 'main'
45+
if [ -z "$BASE_BRANCH" ] || [ "$BASE_BRANCH" = "null" ]; then
46+
echo "Repository is empty or default branch not found. Defaulting to 'main'"
47+
BASE_BRANCH="main"
48+
fi
4349
4450
echo "repository=$REPO" >> "$GITHUB_OUTPUT"
4551
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)