Gitea icon

Gitea

Interact with Gitea via API

Actions393

Overview

This node operation updates an existing file in a repository hosted on a Gitea server via its API. It allows users to modify the content of a file, optionally specifying commit metadata such as author, committer, commit message, and branch details. This is useful for automating repository maintenance tasks like updating documentation, configuration files, or source code directly from workflows without manual intervention.

Practical examples include:

  • Automatically updating README files with build status badges.
  • Patching configuration files during deployment pipelines.
  • Committing generated reports or logs back into a repository branch.

Properties

Name Meaning
Owner The owner (user or organization) of the repository where the file resides.
Repo The name of the repository containing the file to update.
Filepath The path within the repository to the file that should be updated.
Author JSON object defining the identity of the author of the commit (e.g., name, email).
Branch Optional branch name to base the update on; if omitted, the default branch is used.
Committer JSON object defining the identity of the committer of the commit (e.g., name, email).
Content The new content of the file, which must be base64 encoded.
Dates JSON object specifying commit date options, such as GIT_AUTHOR_DATE and GIT_COMMITTER_DATE.
From Path Optional original file path if the file is being moved or renamed.
Message Optional commit message describing the change; if not provided, a default message is used.
New Branch Optional new branch name to create from the specified branch before applying the update.
Sha The SHA hash of the existing file version to ensure the update applies to the correct file revision.
Signoff Boolean flag indicating whether to add a "Signed-off-by" trailer by the committer in the commit message.

Output

The node outputs JSON data representing the result of the file update operation. This typically includes information about the commit created, such as commit SHA, URL, and file metadata confirming the update. There is no binary output involved.

Dependencies

  • Requires connection to a Gitea instance via its REST API.
  • Needs an API authentication token configured in n8n credentials to authorize requests.
  • The node uses standard HTTP headers for JSON communication.
  • No additional external libraries beyond those bundled with the node are required.

Troubleshooting

  • Common issues:

    • Incorrect or missing SHA value can cause the update to fail due to mismatched file versions.
    • Providing invalid base64 content will result in errors when the API attempts to decode the file content.
    • Specifying a non-existent branch or repository will cause API errors.
    • Insufficient permissions or invalid API tokens will lead to authorization failures.
  • Error messages and resolutions:

    • "File SHA does not match" — Verify you have the correct SHA of the current file version before updating.
    • "Invalid base64 content" — Ensure the file content is properly base64 encoded.
    • "Branch not found" — Confirm the branch name exists or create it using the New Branch property.
    • "Unauthorized" — Check that the API key credential is valid and has sufficient access rights.

Links and References

Discussion