github.code.update_file ​
Create or update a file in a GitHub repository
Create or update a file in a GitHub repository via a commit.
To UPDATE an existing file, sha must be the current blob SHA (get it from github.code.get_file). To CREATE a new file, omit sha.
Inputs:
- owner: Repository owner (required).
- repo: Repository name (required).
- path: File path relative to repo root (required).
- content: UTF-8 file content to write (required).
- commit_message: Commit message (required).
- sha: Current blob SHA — required to update an existing file (optional).
- branch: Working branch to commit to. Required in practice: the default branch, and an omitted branch (which GitHub resolves to the default branch), are refused unless allow_default_branch_write is true.
- default_branch: Known default branch name (optional). Only a hint: a match refuses without a metadata read; a mismatch is verified against GitHub.
- allow_default_branch_write: Founder/human-only override (optional, default: false). Never set it from a Staff or agent tool binding.
Outputs (terminal state_data):
- sha: str — new blob SHA of the file
- commit_sha: str — commit SHA
- commit_url: str — HTML URL of the commit
- file_url: str — HTML URL of the file
Guard: the ltinteg org has no branch protection, and some repositories deploy to production on every push to the default branch, so this workflow refuses a default-branch commit with a non-retryable DEFAULT_BRANCH_WRITE_REFUSED error.
Compensation: Call update_file again with the previous sha and content to revert. 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 |
path | string | Yes | — | File path relative to repo root |
content | string | Yes | — | UTF-8 file content to write |
commit_message | string | Yes | — | Commit message |
sha | string | No | — | Current blob SHA (required when updating existing file) |
branch | string | No | — | Working branch to commit to; the default branch is refused |
default_branch | string | No | — | Known repository default branch (hint; never trusted to allow a write) |
allow_default_branch_write | boolean | No | — | Allow committing to the default branch. Founder/human-only override, default false. Never set from Staff or agent tool bindings, and never map it from caller input in a composition. |
Output Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
commit_sha | string | No | — | — |
commit_url | string | No | — | — |
file_url | string | No | — | — |
sha | string | No | — | — |
branch | string | No | — | — |
default_branch | string | No | — | — |
allow_default_branch_write | boolean | No | — | — |
commit_message | string | No | — | — |
content | string | No | — | — |
owner | string | No | — | — |
path | 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.update_file",
"initial_data": {
"owner": "value",
"repo": "value",
"path": "value",
"content": "value"
}
}