Gitea icon

Gitea

Interact with Gitea via API

Actions393

Overview

This node operation allows you to create a new file in a specified repository on a Git hosting service (Gitea). It is useful when you want to programmatically add files to a repository, such as adding configuration files, documentation, or any other content directly from an automated workflow. For example, you could use this node to automatically add a README file to a newly created repository or upload a script file as part of a CI/CD pipeline.

Properties

Name Meaning
Owner The owner of the repository where the file will be created.
Repo The name of the repository where the file will be created.
Filepath The path (including filename) where the new file will be created inside the repository.
Author JSON object defining the identity of the author of the commit (e.g., name and email).
Branch Optional branch name to base the new file creation on; if omitted, the default branch is used.
Committer JSON object defining the identity of the committer of the commit (e.g., name and email).
Content The content of the file to create, which must be base64 encoded.
Dates JSON object specifying commit date options for author and committer dates (e.g., GIT_AUTHOR_DATE).
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 creating the file.
Signoff Boolean flag to add a "Signed-off-by" trailer by the committer at the end of the commit message. Default is true.

Output

The node outputs JSON data representing the result of the file creation operation. This typically includes details about the commit made, the file created, and metadata returned by the API. The output does not include binary data.

Dependencies

  • Requires connection to a Gitea instance via its API.
  • Needs an API authentication token configured in n8n credentials to authorize requests.
  • The base URL of the Gitea server must be set in the credentials.
  • The content property must be base64 encoded before sending.

Troubleshooting

  • Common issues:
    • Invalid or missing API credentials can cause authentication failures.
    • Providing non-base64 encoded content will result in errors.
    • Specifying a branch that does not exist without providing new_branch may cause failure.
    • Incorrect JSON format in author, committer, or dates fields can lead to parsing errors.
  • Error messages:
    • Authentication errors usually indicate invalid or missing API tokens.
    • Validation errors may occur if required properties like owner, repo, filepath, or content are missing.
    • Branch-related errors happen if the specified branch does not exist and no new branch is created.
  • Resolutions:
    • Ensure all required fields are correctly filled.
    • Encode file content in base64 before input.
    • Verify branch names and create new branches if necessary.
    • Validate JSON inputs for author, committer, and dates.

Links and References

Discussion