Skip to content
Prev Previous commit
Next Next commit
default to main on empty repo
  • Loading branch information
witmicko committed Dec 9, 2025
commit ecc9d0af3d7cc2e051059f745971f9e752abaebf
8 changes: 7 additions & 1 deletion .github/workflows/onboard-new-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ jobs:

# Auto-detect default branch from the repository
echo "Detecting default branch for $REPO..."
BASE_BRANCH=$(gh api "repos/$REPO" --jq '.default_branch')
BASE_BRANCH=$(gh api "repos/$REPO" --jq '.default_branch' 2>/dev/null || echo "")

# If repo is empty or API call failed, default to 'main'
if [ -z "$BASE_BRANCH" ] || [ "$BASE_BRANCH" = "null" ]; then
echo "Repository is empty or default branch not found. Defaulting to 'main'"
BASE_BRANCH="main"
fi

echo "repository=$REPO" >> "$GITHUB_OUTPUT"
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"
Expand Down
Loading