github.code.create_branch ​
Create a new branch in a GitHub repository
Create a new branch in a GitHub repository.
from_ref can be a commit SHA or a branch name. When a branch name is provided, it is resolved to its tip SHA automatically.
Inputs:
- owner: Repository owner (required).
- repo: Repository name (required).
- branch_name: Name for the new branch (required).
- from_ref: Commit SHA or existing branch name to branch from (required).
Outputs (terminal state_data):
- branch_name: str — name of the new branch
- sha: str — commit SHA the branch points to
- ref: str — full ref, e.g. refs/heads/feature/my-feature
Compensation: Delete the branch with github.code.delete_branch. Plugin required: context.get_plugin("github") must expose .token.
Overview ​
| Property | Value |
|---|---|
| Workflow type | Atomic |
| Library | App-github |
| Version | 1.0 |
Input Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
owner | string | Yes | — | Repository owner |
repo | string | Yes | — | Repository name |
branch_name | string | Yes | — | Name for the new branch |
from_ref | string | Yes | — | Commit SHA or existing branch name |
Output Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
branch_name | string | No | — | — |
ref | string | No | — | — |
sha | string | No | — | — |
from_ref | string | No | — | — |
owner | string | No | — | — |
repo | string | No | — | — |
failure_reason | string | No | — | — |
failure_type | string | No | — | — |
failed_action | string | No | — | — |
failed_at_state | string | No | — | — |
failed_step | string | No | — | — |
failed_layer | string | No | — | — |
error | string | No | — | — |
error_type | string | No | — | — |
States ​
| State | Initial | Terminal | Success | Auto-advance | Description |
|---|---|---|---|---|---|
pending | Yes | No | — | execute | — |
completed | No | Yes | Yes | — | — |
failed | No | Yes | No | — | — |
State Diagram ​
Transitions ​
| From | Action | To | Description |
|---|---|---|---|
pending | execute | completed | — |
* (any state) | fail | failed | — |
API Usage ​
bash
POST /api/workflows/start
Content-Type: application/json
{
"workflow_type": "github.code.create_branch",
"initial_data": {
"owner": "value",
"repo": "value",
"branch_name": "value",
"from_ref": "value"
}
}