Gitea icon

Gitea

Interact with Gitea via API

Actions393

Overview

This node operation allows you to edit branch protection settings for a specific repository in Gitea. Branch protection is a critical feature that helps enforce rules and restrictions on branches, ensuring code quality and preventing unauthorized changes. This operation is useful for repository administrators who want to programmatically configure or update branch protection policies such as required approvals, push restrictions, status checks, and more.

Practical examples include:

  • Automatically enforcing that certain branches require multiple code review approvals before merging.
  • Restricting force pushes or merges to specific teams or users.
  • Enabling status checks to ensure CI pipelines pass before allowing merges.
  • Managing whitelists for users or teams allowed to push or merge to protected branches.

Properties

Name Meaning
Owner The owner of the repository (user or organization).
Repo The name of the repository.
Name The name of the branch to protect.
Approvals Whitelist Teams JSON array of team names allowed to bypass approval requirements.
Approvals Whitelist Username JSON array of usernames allowed to bypass approval requirements.
Block Admin Merge Override Boolean to block administrators from overriding merge restrictions.
Block On Official Review Requests Boolean to block merges if there are official review requests pending.
Block On Outdated Branch Boolean to block merges if the branch is outdated compared to the base branch.
Block On Rejected Reviews Boolean to block merges if there are rejected reviews.
Dismiss Stale Approvals Boolean to automatically dismiss stale pull request approvals when new commits are pushed.
Enable Approvals Whitelist Boolean to enable the approvals whitelist feature.
Enable Force Push Boolean to allow force pushing to the branch.
Enable Force Push Allowlist Boolean to enable a whitelist for force pushing.
Enable Merge Whitelist Boolean to enable a whitelist for merging.
Enable Push Boolean to allow pushing to the branch.
Enable Push Whitelist Boolean to enable a whitelist for pushing.
Enable Status Check Boolean to require status checks before merging.
Force Push Allowlist Deploy Keys Boolean to allow deploy keys to force push.
Force Push Allowlist Teams JSON array of teams allowed to force push.
Force Push Allowlist Usernames JSON array of usernames allowed to force push.
Ignore Stale Approvals Boolean to ignore stale approvals instead of dismissing them.
Merge Whitelist Teams JSON array of teams allowed to merge.
Merge Whitelist Usernames JSON array of usernames allowed to merge.
Priority Numeric priority of the branch protection rule.
Protected File Patterns String pattern(s) specifying files that are protected by this rule.
Push Whitelist Deploy Keys Boolean to allow deploy keys to push.
Push Whitelist Teams JSON array of teams allowed to push.
Push Whitelist Usernames JSON array of usernames allowed to push.
Require Signed Commits Boolean to require commits to be signed.
Required Approvals Number of required approvals before merging.
Status Check Contexts JSON array of status check contexts that must pass before merging.
Unprotected File Patterns String pattern(s) specifying files that are excluded from protection.

Output

The node outputs JSON data representing the updated branch protection configuration after applying the changes. This typically includes details about the branch protection rules set on the specified branch, such as enabled features, whitelists, required approvals, and other settings.

If the node supports binary data output, it would generally relate to file contents or attachments, but in this case, the output is purely JSON describing branch protection state.

Dependencies

  • Requires an API key credential with access rights to the Gitea instance.
  • Needs the base URL of the Gitea server configured in credentials.
  • The node uses the Gitea REST API v1 endpoints to manage branch protection.

Troubleshooting

  • Authentication errors: Ensure the API key credential has sufficient permissions to modify repository settings.
  • Invalid repository or branch names: Verify that the "Owner", "Repo", and "Name" fields are correct and exist in the Gitea instance.
  • JSON parsing errors: When providing JSON arrays (e.g., whitelists), ensure valid JSON syntax is used.
  • Permission denied errors: Confirm that the authenticated user has admin rights on the repository.
  • Conflicting settings: Some boolean flags may conflict; review the branch protection policy logic in Gitea documentation if unexpected behavior occurs.

Links and References

Discussion