Skip to main content

Create or update file contents

GitHub create or update file contents action to create a new file or update an existing file in a GitHub repository. This is a write action that creates a commit with the file changes, including support for custom commit metadata such as author, committer, branch, and SHA validation.

Prerequisites

  • Your admin must install and configure the GitHub connector, add the GitHub actions pack under Admin > Actions, and enable this action.

  • A GitHub app must be installed on the relevant organization(s) and linked to the correct GitHub datasource in the Glean admin console.

  • The GitHub app must have write permissions to repository contents.

Supported parameters

ParameterTypeRequiredDescription
OwnerStringYesThe account owner of the repository (case-insensitive).
RepositoryStringYesThe name of the repository without the .git extension (case-insensitive).
File pathStringYesThe full path to the file in the repository, including filename and extension.
ContentStringYesThe new file content, Base64 encoded (e.g., "SGVsbG8gV29ybGQ=" for "Hello World").
Commit messageStringYesThe commit message for this file creation or update.
BranchStringNoThe branch name to create or update the file on (defaults to repository's default branch).
Author nameStringNoThe commit author's name (requires author email if provided).
Author emailStringNoThe commit author's email (requires author name if provided).
Author dateStringNoThe author's timestamp in ISO 8601 format (defaults to committer date).
Committer nameStringNoThe committer's name (requires committer email if provided).
Committer emailStringNoThe committer's email (requires committer name if provided).
Committer dateStringNoThe committer's timestamp in ISO 8601 format (defaults to current time).
SHAStringNoThe blob SHA of the file being replaced for validation (auto-fetched if omitted).

Note: If author and committer details are omitted, GitHub uses the authenticated user's identity for both.

Usage examples

  • "Create a new README.md file in the 'myorg/myproject' repository with the content 'Welcome to My Project'."

  • "Update the config.json file in 'facebook/react' on the 'develop' branch with new configuration settings."

  • "Add a new API documentation file at 'docs/api/endpoints.md' in the 'microsoft/vscode' repository."

Troubleshooting

FAQs