Skip to content
Proud to collaborate with Microsoft for Startups

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 ​

PropertyValue
Workflow typeAtomic
LibraryApp-github
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
ownerstringYes—Repository owner
repostringYes—Repository name
pathstringYes—File path relative to repo root
contentstringYes—UTF-8 file content to write
commit_messagestringYes—Commit message
shastringNo—Current blob SHA (required when updating existing file)
branchstringNo—Working branch to commit to; the default branch is refused
default_branchstringNo—Known repository default branch (hint; never trusted to allow a write)
allow_default_branch_writebooleanNo—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 ​

FieldTypeRequiredDefaultDescription
commit_shastringNo——
commit_urlstringNo——
file_urlstringNo——
shastringNo——
branchstringNo——
default_branchstringNo——
allow_default_branch_writebooleanNo——
commit_messagestringNo——
contentstringNo——
ownerstringNo——
pathstringNo——
repostringNo——
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—execute—
completedNoYesYes——
failedNoYesNo——

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutecompleted—
* (any state)failfailed—

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"
  }
}