This is a script that does various maintenance chores for go-gitea/gitea.
First, the script will fetch Gitea's current development versions from GitHub's API.
The script will look for pull requests that have the label
backport/v{gitea_version} but do not have the label backport/done. It will
clone your fork of gitea. It will then attempt to cherry-pick the pull request
merged commit into the release branch release/v{gitea_version}, where
{gitea_version} is major.minor for 1.x (1.27) and major for later
versions (28). If the cherry-pick is successful, it will push the branch to
the remote and create a pull request with the labels from the original pull
request.
The script will also look for merged pull requests that have the labels
reviewed/wait-merge or reviewed/prioritize-merge and remove them.
It will also search for pull requests that target release branches and remove
any backport/* labels from them.
It will also make sure any pull requests that have ## :warning: BREAKING in
their description have the pr/breaking label.
The script will also look for pull requests that have the label
reviewed/wait-merge and are still open. It will merge the upstream changes
into the pull request head branch. If a merge conflict occurs, it will remove
the pull request from the merge queue.
When a pull request is created, the script will assign it a milestone based on
its target branch (except pull requests targeting main, we'll assign those on
merge). The script makes sure that unmerged closed pull requests are not
included in any milestone.
The script will maintain each pull request's LGTM count. It will add the
appropriate label (one of lgtm/need 2, lgtm/need 1, lgtm/done, or
lgtm/blocked) based on the number of approvals (or change requests) the pull
request has. It will also set the commit status to success if the pull request
has 2 or more approvals without changes requested (pending if not or failure
if changes are requested).
The script will also comment if a pull request is opened with non-English translation files changed, directing the user to the crowdin project.
The script will also lock issues and pull requests that have been closed for 3 months. If the issue was commented on in the last two weeks, a comment will be posted suggesting opening a new issue to continue the discussion.
The script will close issues with the label issue/needs-feedback if a month
has passed since they were updated.
The script can execute some actions like updating a PR's branch if requested by
a maintainer through a giteabot/* label.
The script will close PRs with the label pr/last-call if two weeks have passed
since they were updated. If one week has passed since they were updated, it will
remind the TOC to review the PR.
- Create a GitHub personal access token with access to
go-gitea/giteaand your fork. - Store the following secrets in the target repository:
BACKPORTER_GITHUB_TOKEN= # GitHub personal access token
BACKPORTER_GITEA_FORK= # Fork of go-gitea/gitea (e.g. yardenshoham/gitea), only needed for the backport check
- Add a workflow that invokes this action. A minimal example:
name: Gitea Backporter
on:
push:
branches:
- main
pull_request_target:
types: [
opened,
synchronize,
labeled,
unlabeled,
closed,
review_requested,
review_request_removed,
]
workflow_run:
workflows: [Gitea Backporter Review]
types: [requested]
schedule:
- cron: "15 3 * * *"
workflow_dispatch:
jobs:
backporter:
runs-on: ubuntu-latest
steps:
- uses: giteabot/gitea-backporter@v1
with:
github_token: ${{ secrets.BACKPORTER_GITHUB_TOKEN }}
gitea_fork: ${{ secrets.BACKPORTER_GITEA_FORK }}
checks: allpull_request_reviewruns get a read-only token and no secrets on pull requests from forks, so add a second workflow that only relays reviews to the first one throughworkflow_run. Its job never runs, the requested run alone triggers the relay. It must exist on every branch pull requests target, because review runs use the workflow from the pull request's merge ref.
name: Gitea Backporter Review
on:
pull_request_review:
types: [submitted, edited, dismissed]
permissions: {}
jobs:
relay:
if: false
runs-on: ubuntu-latest
steps:
- run: "true"For a more complete example with permissions, see examples/workflows.
The optional checks input controls which bot checks run in a workflow. It
accepts all, none, or a comma-separated list from:
backportlabelsmerge_queuelockfeedbacklast_callmilestoneslgtmtranslation_commentpr_actions
For example, to run only label cleanup and milestone maintenance:
- uses: giteabot/gitea-backporter@v1
with:
github_token: ${{ secrets.BACKPORTER_GITHUB_TOKEN }}
gitea_fork: ${{ secrets.BACKPORTER_GITEA_FORK }}
checks: labels,milestonesmake fmtruns the formattermake lintruns the linter and checks formatting and typesmake testruns the tests
Contributions are welcome!