# Gitea Pull Request<no value>

// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

== Description

The `gitea/pullrequest` action opens (or updates) a link:https://docs.gitea.com/usage/pull-request[Gitea pull request] once a target linked to the same scm has changed something and the change has been pushed.

It is the second half of the Gitea workflow: the link:/docs/plugins/scm/gitea/[`gitea` scm] commits to a working branch and pushes it, this action turns that branch into a pull request. Without it, the branch is pushed and nothing else happens.

NOTE: `kind: gitea` is a deprecated alias for `kind: gitea/pullrequest`. It still works and logs a warning.

== Requirements

include::content/en/docs/plugins/_actionScm.adoc[]

== Parameters

{{< resourceparameters "actions" "gitea/pullrequest" >}}

The spec includes `title`, `body`, `assignees`, `merge`, and `mergemethod`, on top of the identity fields inherited from the scm. Labels and reviewers are not exposed by this plugin.

`body`:: Replaces the description Updatecli generates from the pipeline run. Useful to add context a reviewer needs, such as a changelog URL.
`assignees`:: Gitea usernames, who must have access to the repository. They are set when the pull request is created and not reapplied afterwards.

=== Merge behaviour

`merge.strategy` accepts the following values (case-insensitive):

`manual`::
The default, also used when `merge` is omitted or `strategy` is empty. Updatecli opens the pull request without requesting or cancelling auto-merge.

`auto`::
Requests server-side auto-merge for a new or existing pull request. This requires Gitea 1.22+ or Forgejo 8+. Configure required checks and branch protections on the repository. A pull request that is already mergeable may merge immediately.

`mergemethod` selects how the merge is performed: `merge`, `rebase`, `rebase-merge`, `squash`, or `fast-forward-only`. Leave it empty to use the repository's default merge style. Values are case-insensitive, and the selected method must be allowed on the repository.

Existing auto-merge schedules are left unchanged. Changing `mergemethod` does not change the method of an already scheduled pull request.

Updatecli only requests auto-merge when target changes trigger the action. A run without target changes reports the existing pull request without retrying a rejected auto-merge request. Dry-runs do not request auto-merge.

=== Updating an existing pull request

When a pull request is already open between the two branches in the same repository, this plugin does not refresh its title or description with the latest run, unlike the GitHub, GitLab, Bitbucket Cloud, and Azure DevOps plugins. The report still links to it. With `merge.strategy: auto`, the action also requests auto-merge as described above.

[WARNING]
====
With `merge.strategy: auto`, errors from creating the pull request or requesting auto-merge fail the action. With `manual` or an empty strategy, a failed creation call logs `Gitea pullrequest not created, skipping` without failing the pipeline. Run with `--debug` to see the response body when a pull request you expected does not appear.
====

[WARNING]
====
The `sourcebranch` and `targetbranch` descriptions in the table above have their defaults *swapped*: `sourcebranch` inherits the scm's **working** branch (the one carrying the commits) and `targetbranch` inherits the scm's `branch`, the one the pull request is opened against. Leave both unset and the inheritance is correct regardless.
====

=== Cleanup

Cleanup is *not implemented* for this plugin. `updatecli apply --clean-git-branches` removes working branches that ended up with no changes, but a pull request already opened for one of them is not closed automatically (that stays a manual step).

The same goes for the options this plugin does not expose, such as labels and reviewers. If closing stale pull requests, or anything else missing here, is something you would use, say so on link:https://github.com/updatecli/updatecli/issues[the Updatecli issue tracker] (these gaps are unimplemented rather than deliberate, and interest is what gets them prioritised).

== Example

The manifest below opens a pull request and requests auto-merge using the `squash` method.

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/plugins/actions/gitea_pullrequest/updatecli.yaml">}}
----

== Links

* link:https://docs.gitea.com/usage/pull-request[Documentation: Gitea pull requests]
