signaloid-cli github branches
List branches for a GitHub repository.
Synopsis
signaloid-cli github branches --owner <owner> --repo <name>
Description
Lists all branches for a specific GitHub repository. This is useful for selecting branches when creating builds from repositories.
Options
| Option | Description |
|---|---|
--owner <owner> | Repository owner (username or organization) (required) |
--repo <name> | Repository name (required) |
Output
Returns a JSON array of branch objects:
[
{
"name": "main",
"commit": {
"sha": "abc123def456...",
"url": "https://api.github.com/repos/owner/repo/commits/abc123..."
},
"protected": true
},
{
"name": "develop",
"commit": {
"sha": "def789ghi012...",
"url": "https://api.github.com/repos/owner/repo/commits/def789..."
},
"protected": false
}
]
Examples
List All Branches
signaloid-cli github branches \
--owner myusername \
--repo myrepository
Extract Branch Names
# List branch names
signaloid-cli github branches \
--owner myusername \
--repo myrepository | \
jq -r '.[].name'
# Get default branch
signaloid-cli github proxy --path repos/myusername/myrepository | \
jq -r '.default_branch'
Get Latest Commit SHA
# Get latest commit for main branch
signaloid-cli github branches \
--owner myusername \
--repo myrepository | \
jq -r '.[] | select(.name == "main") | .commit.sha'
List Protected Branches
signaloid-cli github branches \
--owner myusername \
--repo myrepository | \
jq '.[] | select(.protected == true) | .name'
Create Build from Branch
#!/bin/bash
OWNER="myusername"
REPO="myrepository"
BRANCH="main"
# Get latest commit SHA
COMMIT_SHA=$(signaloid-cli github branches \
--owner $OWNER \
--repo $REPO | \
jq -r ".[] | select(.name == \"$BRANCH\") | .commit.sha")
echo "Latest commit on $BRANCH: $COMMIT_SHA"
# First, ensure repo is connected to Signaloid
REPO_URL="https://github.com/$OWNER/$REPO"
REPO_RESPONSE=$(signaloid-cli repos connect --url $REPO_URL)
REPO_ID=$(echo $REPO_RESPONSE | jq -r '.RepositoryID')
# Create build from specific commit
BUILD_ID=$(signaloid-cli builds create:repo \
--repo-id $REPO_ID \
--commit $COMMIT_SHA | \
jq -r '.BuildID')
echo "Build created: $BUILD_ID"
# Wait for build
signaloid-cli builds watch --build-id $BUILD_ID
Interactive Branch Selection
#!/bin/bash
OWNER="$1"
REPO="$2"
if [ -z "$OWNER" ] || [ -z "$REPO" ]; then
echo "Usage: $0 <owner> <repo>"
exit 1
fi
# Get branches
BRANCHES=$(signaloid-cli github branches --owner $OWNER --repo $REPO)
# Display branches
echo "Available branches:"
echo $BRANCHES | jq -r '.[].name' | nl
# Prompt for selection
read -p "Select branch number: " NUM
SELECTED=$(echo $BRANCHES | jq -r ".[$((NUM-1))].name")
echo "Selected branch: $SELECTED"
# Get commit SHA
COMMIT=$(echo $BRANCHES | jq -r ".[$((NUM-1))].commit.sha")
echo "Latest commit: $COMMIT"
Branch Activity Report
#!/bin/bash
OWNER="$1"
REPO="$2"
echo "Branch Activity Report"
echo "====================="
BRANCHES=$(signaloid-cli github branches --owner $OWNER --repo $REPO)
# Count branches
TOTAL=$(echo $BRANCHES | jq '. | length')
PROTECTED=$(echo $BRANCHES | jq '[.[] | select(.protected == true)] | length')
echo "Total branches: $TOTAL"
echo "Protected branches: $PROTECTED"
echo ""
# List all branches with commit info
echo "Branches:"
echo $BRANCHES | jq -r '.[] | " \(.name) - \(.commit.sha[0:7])"'
Deploy from Latest Branch
#!/bin/bash
# Deploy from latest commit on main branch
OWNER="myusername"
REPO="myrepository"
BRANCH="main"
# Get branch info
BRANCH_INFO=$(signaloid-cli github branches \
--owner $OWNER \
--repo $REPO | \
jq ".[] | select(.name == \"$BRANCH\")")
COMMIT_SHA=$(echo $BRANCH_INFO | jq -r '.commit.sha')
echo "Deploying from $BRANCH at $COMMIT_SHA"
# Connect repo if not already connected
REPO_URL="https://github.com/$OWNER/$REPO"
REPO_ID=$(signaloid-cli repos list --format json | \
jq -r ".Repositories[] | select(.RemoteURL == \"$REPO_URL\") | .RepositoryID")
if [ -z "$REPO_ID" ]; then
echo "Connecting repository..."
REPO_ID=$(signaloid-cli repos connect --url $REPO_URL | jq -r '.RepositoryID')
fi
# Create and run build
BUILD_ID=$(signaloid-cli builds create:repo \
--repo-id $REPO_ID \
--commit $COMMIT_SHA | jq -r '.BuildID')
echo "Build started: $BUILD_ID"
signaloid-cli builds watch --build-id $BUILD_ID
# Create task if build succeeds
if [ $? -eq 0 ]; then
TASK_ID=$(signaloid-cli tasks create --build-id $BUILD_ID | jq -r '.TaskID')
echo "Task created: $TASK_ID"
signaloid-cli tasks watch --task-id $TASK_ID
fi
Exit Codes
| Code | Description |
|---|---|
0 | Success |
1 | Failed to list branches (repo not found, insufficient permissions) |
Prerequisites
GitHub must be connected and have access to the repository:
# Check connection
signaloid-cli github status
# Verify repo access
signaloid-cli github proxy --path repos/owner/repo
Notes
- Requires read access to the repository
- For private repositories, ensure GitHub integration has
reposcope - Branch protection status is included in results
- Returns all branches including feature and release branches
See Also
- signaloid-cli github repos - List repositories
- signaloid-cli github proxy - Advanced GitHub API access
- signaloid-cli repos connect - Connect repository
- signaloid-cli builds create:repo - Build from repository