Gitea icon

Gitea

Interact with Gitea via API

Actions393

Overview

This node operation allows you to merge a pull request in a repository hosted on a Gitea server. It supports various merge strategies such as merge commit, rebase, squash, fast-forward only, and manual merge. This is useful for automating the process of integrating changes from feature branches into main branches within your CI/CD workflows or development pipelines.

Practical examples include:

  • Automatically merging approved pull requests after successful code reviews.
  • Enforcing specific merge strategies (e.g., squash commits) to keep history clean.
  • Deleting feature branches post-merge to maintain repository hygiene.
  • Delaying merges until all required checks succeed.

Properties

Name Meaning
Owner The owner (user or organization) of the repository where the pull request exists.
Repo The name of the repository containing the pull request.
Index The index (number) identifying which pull request to merge.
Do The merge strategy to apply. Options: Merge, Rebase, Rebase Merge, Squash, Fast Forward Only, Manually Merged.
Merge Commit ID Optional commit ID to use for the merge commit.
Merge Message Field Optional custom message to include in the merge commit.
Merge Title Field Optional custom title for the merge commit.
Delete Branch After Merge Boolean flag indicating whether to delete the source branch after merging (default: true).
Force Merge Boolean flag to force the merge even if there are conflicts or other issues (default: true).
Head Commit Id Optional commit ID of the head commit of the pull request branch.
Merge When Checks Succeed Boolean flag to delay the merge until all status checks pass (default: true).

Output

The node outputs JSON data representing the result of the merge operation. This typically includes details about the merged pull request, such as its updated state, merge commit information, and any relevant metadata returned by the Gitea API.

No binary data output is produced by this operation.

Dependencies

  • Requires access to a Gitea instance with API enabled.
  • Needs an API authentication token credential configured in n8n to authorize requests.
  • The base URL of the Gitea server must be provided in the credentials configuration.
  • The node uses the Gitea REST API v1 endpoints under /api/v1.

Troubleshooting

  • Common Issues:

    • Invalid repository owner or name will cause the API call to fail.
    • Incorrect pull request index may lead to "pull request not found" errors.
    • Insufficient permissions or invalid API token will result in authorization errors.
    • Trying to merge a pull request that has conflicts without force merge enabled may fail.
    • If "merge when checks succeed" is enabled but checks never complete successfully, the merge will be delayed indefinitely.
  • Error Messages:

    • 404 Not Found: Check that the owner, repo, and pull request index are correct.
    • 401 Unauthorized: Verify that the API token credential is valid and has sufficient permissions.
    • 409 Conflict: Merge conflicts detected; consider enabling force merge or resolving conflicts manually.
    • 422 Unprocessable Entity: Invalid parameters sent, e.g., unsupported merge strategy or malformed commit IDs.

Links and References

Discussion