diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-07-10 09:46:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 01:46:08 +0000 |
commit | af1f0dfcc6366c01ee05098c34ca8457a0248f70 (patch) | |
tree | 17da03206cd974b4321e9bfe449cc3efa6014d25 /docs/content | |
parent | d6f8a60b6579c9a152d930d45e26eb91be685f0a (diff) | |
download | gitea-af1f0dfcc6366c01ee05098c34ca8457a0248f70.tar.gz gitea-af1f0dfcc6366c01ee05098c34ca8457a0248f70.zip |
Remove docs sub folder since docs has been moved to https://gitea.com/gitea/docs (#31536)
Diffstat (limited to 'docs/content')
214 files changed, 0 insertions, 25746 deletions
diff --git a/docs/content/actions.en-us.md b/docs/content/actions.en-us.md deleted file mode 100644 index d8e33d3784..0000000000 --- a/docs/content/actions.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2023-04-27T14:00:00+08:00" -title: "Actions" -slug: "actions" -sidebar_position: 36 -toc: false -draft: false -menu: - sidebar: - name: "Usage - Actions" - sidebar_position: 31 - identifier: "actions" ---- diff --git a/docs/content/administration.en-us.md b/docs/content/administration.en-us.md deleted file mode 100644 index 416b9e631e..0000000000 --- a/docs/content/administration.en-us.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Administration" -slug: "administration" -sidebar_position: 30 -toc: false -draft: false -menu: - sidebar: - name: "Administration" - sidebar_position: 20 - collapse: true - identifier: "administration" ---- diff --git a/docs/content/administration.zh-cn.md b/docs/content/administration.zh-cn.md deleted file mode 100644 index 262e5f068f..0000000000 --- a/docs/content/administration.zh-cn.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "运维" -slug: "administration" -sidebar_position: 30 -toc: false -draft: false -menu: - sidebar: - name: "运维" - sidebar_position: 20 - identifier: "administration" ---- diff --git a/docs/content/administration/_index.en-us.md b/docs/content/administration/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/administration/_index.en-us.md +++ /dev/null diff --git a/docs/content/administration/_index.zh-cn.md b/docs/content/administration/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/administration/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/administration/adding-legal-pages.en-us.md b/docs/content/administration/adding-legal-pages.en-us.md deleted file mode 100644 index 1ff0c0132d..0000000000 --- a/docs/content/administration/adding-legal-pages.en-us.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -date: "2019-12-28" -title: "Adding Legal Pages" -slug: adding-legal-pages -sidebar_position: 110 -toc: false -draft: false -aliases: - - /en-us/adding-legal-pages -menu: - sidebar: - parent: "administration" - name: "Adding Legal Pages" - identifier: "adding-legal-pages" - sidebar_position: 110 ---- - -Some jurisdictions (such as EU), requires certain legal pages (e.g. Privacy Policy) to be added to website. Follow these steps to add them to your Gitea instance. - -## Getting Pages - -Gitea source code ships with sample pages, available in `contrib/legal` directory. Copy them to `custom/public/assets/`. For example, to add Privacy Policy: - -``` -wget -O /path/to/custom/public/assets/privacy.html https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/legal/privacy.html.sample -``` - -Now you need to edit the page to meet your requirements. In particular you must change the email addresses, web addresses and references to "Your Gitea Instance" to match your situation. - -You absolutely must not place a general ToS or privacy statement that implies that the Gitea project is responsible for your server. - -## Make it Visible - -Create or append to `/path/to/custom/templates/custom/extra_links_footer.tmpl`: - -```go -<a class="item" href="{{AppSubUrl}}/assets/privacy.html">Privacy Policy</a> -``` - -Restart Gitea to see the changes. diff --git a/docs/content/administration/adding-legal-pages.zh-cn.md b/docs/content/administration/adding-legal-pages.zh-cn.md deleted file mode 100644 index 3e18c6e6b0..0000000000 --- a/docs/content/administration/adding-legal-pages.zh-cn.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "添加法律页面" -slug: adding-legal-pages -sidebar_position: 110 -toc: false -draft: false -aliases: - - /zh-cn/adding-legal-pages -menu: - sidebar: - parent: "administration" - name: "添加法律页面" - identifier: "adding-legal-pages" - sidebar_position: 110 ---- - -一些法域(例如欧盟)要求在网站上添加特定的法律页面(例如隐私政策)。按照以下步骤将它们添加到你的 Gitea 实例中。 - -## 获取页面 - -Gitea 源代码附带了示例页面,位于 `contrib/legal` 目录中。将它们复制到 `custom/public/assets/` 目录下。例如,如果要添加隐私政策: - -``` -wget -O /path/to/custom/public/assets/privacy.html https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/legal/privacy.html.sample -``` - -现在,你需要编辑该页面以满足你的需求。特别是,你必须更改电子邮件地址、网址以及与 "Your Gitea Instance" 相关的引用,以匹配你的情况。 - -请务必不要放置会暗示 Gitea 项目对你的服务器负责的一般服务条款或隐私声明。 - -## 使其可见 - -创建或追加到 `/path/to/custom/templates/custom/extra_links_footer.tmpl` 文件中: - -```go -<a class="item" href="{{AppSubUrl}}/assets/privacy.html">隐私政策</a> -``` - -重启 Gitea 以查看更改。 diff --git a/docs/content/administration/backup-and-restore.en-us.md b/docs/content/administration/backup-and-restore.en-us.md deleted file mode 100644 index 451ef5c944..0000000000 --- a/docs/content/administration/backup-and-restore.en-us.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -date: "2017-01-01T16:00:00+02:00" -title: "Backup and Restore" -slug: "backup-and-restore" -sidebar_position: 11 -toc: false -draft: false -aliases: - - /en-us/backup-and-restore -menu: - sidebar: - parent: "administration" - name: "Backup and Restore" - sidebar_position: 11 - identifier: "backup-and-restore" ---- - -# Backup and Restore - -Gitea currently has a `dump` command that will save the installation to a ZIP file. This -file can be unpacked and used to restore an instance. - -## Backup Consistency - -To ensure the consistency of the Gitea instance, it must be shutdown during backup. - -Gitea consists of a database, files and git repositories, all of which change when it is used. For instance, when a migration is in progress, a transaction is created in the database while the git repository is being copied over. If the backup happens in the middle of the migration, the git repository may be incomplete although the database claims otherwise because it was dumped afterwards. The only way to avoid such race conditions is by stopping the Gitea instance during the backups. - -## Backup Command (`dump`) - -Switch to the user running Gitea: `su git`. Run `./gitea dump -c /path/to/app.ini` in the Gitea installation -directory. There should be some output similar to the following: - -```none -2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001 -2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories -2016/12/27 22:32:22 Dumping database... -2016/12/27 22:32:22 Packing dump files... -2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001 -2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip -``` - -Inside the `gitea-dump-1482906742.zip` file, will be the following: - -- `app.ini` - Optional copy of configuration file if originally stored outside the default `custom/` directory -- `custom/` - All config or customization files in `custom/`. -- `data/` - Data directory (APP_DATA_PATH), except sessions if you are using file session. This directory includes `attachments`, `avatars`, `lfs`, `indexers`, SQLite file if you are using SQLite. -- `repos/` - Complete copy of the repository directory. -- `gitea-db.sql` - SQL dump of database -- `log/` - Various logs. They are not needed for a recovery or migration. - -Intermediate backup files are created in a temporary directory specified either with the -`--tempdir` command-line parameter or the `TMPDIR` environment variable. - -## Backup the database - -The SQL dump created by `gitea dump` uses XORM and Gitea admins may prefer to use the native the MySQL and PostgreSQL dump tools instead. There are still open issues when using XORM for dumping the database that may cause problems when attempting to restore it. - -```sh -# mysql -mysqldump -u$USER -p$PASS --database $DATABASE > gitea-db.sql -# postgres -pg_dump -U $USER $DATABASE > gitea-db.sql -``` - -### Using Docker (`dump`) - -There are a few caveats for using the `dump` command with Docker. - -The command has to be executed with the `RUN_USER = <OS_USERNAME>` specified in `gitea/conf/app.ini`; and, for the zipping of the backup folder to occur without permission error the command `docker exec` must be executed inside of the `--tempdir`. - -Example: - -```none -docker exec -u <OS_USERNAME> -it -w <--tempdir> $(docker ps -qf 'name=^<NAME_OF_DOCKER_CONTAINER>$') bash -c '/usr/local/bin/gitea dump -c </path/to/app.ini>' -``` - -\*Note: `--tempdir` refers to the temporary directory of the docker environment used by Gitea; if you have not specified a custom `--tempdir`, then Gitea uses `/tmp` or the `TMPDIR` environment variable of the docker container. For `--tempdir` adjust your `docker exec` command options accordingly. - -The result should be a file, stored in the `--tempdir` specified, along the lines of: `gitea-dump-1482906742.zip` - -## Restore Command (`restore`) - -There is currently no support for a recovery command. It is a manual process that mostly -involves moving files to their correct locations and restoring a database dump. - -Example: - -```sh -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -mv app.ini /etc/gitea/conf/app.ini -mv data/* /var/lib/gitea/data/ -mv log/* /var/lib/gitea/log/ -mv repos/* /var/lib/gitea/data/gitea-repositories/ -chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea - -# mysql -mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql -# sqlite3 -sqlite3 $DATABASE_PATH <gitea-db.sql -# postgres -psql -U $USER -d $DATABASE < gitea-db.sql - -service gitea restart -``` - -Repository Git Hooks should be regenerated if installation method is changed (eg. binary -> Docker), or if Gitea is installed to a different directory than the previous installation. - -With Gitea running, and from the directory Gitea's binary is located, execute: `./gitea admin regenerate hooks` - -This ensures that application and configuration file paths in repository Git Hooks are consistent and applicable to the current installation. If these paths are not updated, repository `push` actions will fail. - -If you still have issues, consider running `./gitea doctor check` to inspect possible errors (or run with `--fix`). - -### Using Docker (`restore`) - -There is also no support for a recovery command in a Docker-based gitea instance. The restore process contains the same steps as described in the previous section but with different paths. - -Example: - -```sh -# open bash session in container -docker exec --user git -it 2a83b293548e bash -# unzip your backup file within the container -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -# restore the gitea data -mv data/* /data/gitea -# restore the repositories itself -mv repos/* /data/git/gitea-repositories/ -# adjust file permissions -chown -R git:git /data -# Regenerate Git Hooks -/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks -``` - -The default user in the gitea container is `git` (1000:1000). Please replace `2a83b293548e` with your gitea container id or name. - -### Using Docker-rootless (`restore`) - -The restore workflow in Docker-rootless containers differs only in the directories to be used: - -```sh -# open bash session in container -docker exec --user git -it 2a83b293548e bash -# unzip your backup file within the container -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -# restore the app.ini -mv data/conf/app.ini /etc/gitea/app.ini -# restore the gitea data -mv data/* /var/lib/gitea -# restore the repositories itself -mv repos/* /var/lib/gitea/git/gitea-repositories -# adjust file permissions -chown -R git:git /etc/gitea/app.ini /var/lib/gitea -# Regenerate Git Hooks -/usr/local/bin/gitea -c '/etc/gitea/app.ini' admin regenerate hooks -``` diff --git a/docs/content/administration/backup-and-restore.zh-cn.md b/docs/content/administration/backup-and-restore.zh-cn.md deleted file mode 100644 index db7eba84f7..0000000000 --- a/docs/content/administration/backup-and-restore.zh-cn.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -date: "2018-06-06T09:33:00+08:00" -title: "备份与恢复" -slug: "backup-and-restore" -sidebar_position: 11 -toc: false -draft: false -aliases: - - /zh-cn/backup-and-restore -menu: - sidebar: - parent: "administration" - name: "备份与恢复" - sidebar_position: 11 - identifier: "backup-and-restore" ---- - -# 备份与恢复 - -Gitea 已经实现了 `dump` 命令可以用来备份所有需要的文件到一个zip压缩文件。该压缩文件可以被用来进行数据恢复。 - -## 备份一致性 - -为了确保 Gitea 实例的一致性,在备份期间必须关闭它。 - -Gitea 包括数据库、文件和 Git 仓库,当它被使用时所有这些都会发生变化。例如,当迁移正在进行时,在数据库中创建一个事务,而 Git 仓库正在被复制。如果备份发生在迁移的中间,Git 仓库可能是不完整的,尽管数据库声称它是完整的,因为它是在之后被转储的。避免这种竞争条件的唯一方法是在备份期间停止 Gitea 实例。 - -## 备份命令 (`dump`) - -先转到git用户的权限: `su git`. 再Gitea目录运行 `./gitea dump`。一般会显示类似如下的输出: - -``` -2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001 -2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories -2016/12/27 22:32:22 Dumping database... -2016/12/27 22:32:22 Packing dump files... -2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001 -2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip -``` - -最后生成的 `gitea-dump-1482906742.zip` 文件将会包含如下内容: - -* `app.ini` - 如果原先存储在默认的 custom/ 目录之外,则是配置文件的可选副本 -* `custom/` - 所有保存在 `custom/` 目录下的配置和自定义的文件。 -* `data/` - 数据目录(APP_DATA_PATH),如果使用文件会话,则不包括会话。该目录包括 `attachments`、`avatars`、`lfs`、`indexers`、如果使用 SQLite 则包括 SQLite 文件。 -* `repos/` - 仓库目录的完整副本。 -* `gitea-db.sql` - 数据库dump出来的 SQL。 -* `log/` - Logs文件,如果用作迁移不是必须的。 - -中间备份文件将会在临时目录进行创建,如果您要重新指定临时目录,可以用 `--tempdir` 参数,或者用 `TMPDIR` 环境变量。 - -## 备份数据库 - -`gitea dump` 创建的 SQL 转储使用 XORM,Gitea 管理员可能更喜欢使用本地的 MySQL 和 PostgreSQL 转储工具。使用 XORM 转储数据库时仍然存在一些问题,可能会导致在尝试恢复时出现问题。 - -```sh -# mysql -mysqldump -u$USER -p$PASS --database $DATABASE > gitea-db.sql -# postgres -pg_dump -U $USER $DATABASE > gitea-db.sql -``` - -### 使用Docker (`dump`) - -在使用 Docker 时,使用 `dump` 命令有一些注意事项。 - -必须以 `gitea/conf/app.ini` 中指定的 `RUN_USER = <OS_USERNAME>` 执行该命令;并且,为了让备份文件夹的压缩过程能够顺利执行,`docker exec` 命令必须在 `--tempdir` 内部执行。 - -示例: - -```none -docker exec -u <OS_USERNAME> -it -w <--tempdir> $(docker ps -qf 'name=^<NAME_OF_DOCKER_CONTAINER>$') bash -c '/usr/local/bin/gitea dump -c </path/to/app.ini>' -``` - -\*注意:`--tempdir` 指的是 Gitea 使用的 Docker 环境的临时目录;如果您没有指定自定义的 `--tempdir`,那么 Gitea 将使用 `/tmp` 或 Docker 容器的 `TMPDIR` 环境变量。对于 `--tempdir`,请相应调整您的 `docker exec` 命令选项。 - -结果应该是一个文件,存储在指定的 `--tempdir` 中,类似于:`gitea-dump-1482906742.zip` - -## 恢复命令 (`restore`) - -当前还没有恢复命令,恢复需要人工进行。主要是把文件和数据库进行恢复。 - -例如: - -```sh -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -mv app.ini /etc/gitea/conf/app.ini -mv data/* /var/lib/gitea/data/ -mv log/* /var/lib/gitea/log/ -mv repos/* /var/lib/gitea/gitea-repositories/ -chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea - -# mysql -mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql -# sqlite3 -sqlite3 $DATABASE_PATH <gitea-db.sql -# postgres -psql -U $USER -d $DATABASE < gitea-db.sql - -service gitea restart -``` - -如果安装方式发生了变化(例如 二进制 -> Docker),或者 Gitea 安装到了与之前安装不同的目录,则需要重新生成仓库 Git 钩子。 - -在 Gitea 运行时,并从 Gitea 二进制文件所在的目录执行:`./gitea admin regenerate hooks` - -这样可以确保仓库 Git 钩子中的应用程序和配置文件路径与当前安装一致。如果这些路径没有更新,仓库的 `push` 操作将失败。 - -### 使用 Docker (`restore`) - -在基于 Docker 的 Gitea 实例中,也没有恢复命令的支持。恢复过程与前面描述的步骤相同,但路径不同。 - -示例: - -```sh -# 在容器中打开 bash 会话 -docker exec --user git -it 2a83b293548e bash -# 在容器内解压您的备份文件 -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -# 恢复 Gitea 数据 -mv data/* /data/gitea -# 恢复仓库本身 -mv repos/* /data/git/gitea-repositories/ -# 调整文件权限 -chown -R git:git /data -# 重新生成 Git 钩子 -/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks -``` - -Gitea 容器中的默认用户是 `git`(1000:1000)。请用您的 Gitea 容器 ID 或名称替换 `2a83b293548e`。 - -### 使用 Docker-rootless (`restore`) - -在 Docker-rootless 容器中的恢复工作流程只是要使用的目录不同: - -```sh -# 在容器中打开 bash 会话 -docker exec --user git -it 2a83b293548e bash -# 在容器内解压您的备份文件 -unzip gitea-dump-1610949662.zip -cd gitea-dump-1610949662 -# 恢复 app.ini -mv data/conf/app.ini /etc/gitea/app.ini -# 恢复 Gitea 数据 -mv data/* /var/lib/gitea -# 恢复仓库本身 -mv repos/* /var/lib/gitea/git/gitea-repositories -# 调整文件权限 -chown -R git:git /etc/gitea/app.ini /var/lib/gitea -# 重新生成 Git 钩子 -/usr/local/bin/gitea -c '/etc/gitea/app.ini' admin regenerate hooks -``` diff --git a/docs/content/administration/cmd-embedded.en-us.md b/docs/content/administration/cmd-embedded.en-us.md deleted file mode 100644 index b7f6836144..0000000000 --- a/docs/content/administration/cmd-embedded.en-us.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -date: "2020-01-25T21:00:00-03:00" -title: "Embedded data extraction tool" -slug: "cmd-embedded" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /en-us/cmd-embedded -menu: - sidebar: - parent: "administration" - name: "Embedded data extraction tool" - sidebar_position: 20 - identifier: "cmd-embedded" ---- - -# Embedded data extraction tool - -Gitea's executable contains all the resources required to run: templates, images, style-sheets -and translations. Any of them can be overridden by placing a replacement in a matching path -inside the `custom` directory (see [Customizing Gitea](administration/customizing-gitea.md)). - -To obtain a copy of the embedded resources ready for editing, the `embedded` command from the CLI -can be used from the OS shell interface. - -**NOTE:** The embedded data extraction tool is included in Gitea versions 1.12 and above. - -## Listing resources - -To list resources embedded in Gitea's executable, use the following syntax: - -```sh -gitea embedded list [--include-vendored] [patterns...] -``` - -The `--include-vendored` flag makes the command include vendored files, which are -normally excluded; that is, files from external libraries that are required for Gitea -(e.g. [octicons](https://octicons.github.com/), etc). - -A list of file search patterns can be provided. Gitea uses [gobwas/glob](https://github.com/gobwas/glob) -for its glob syntax. Here are some examples: - -- List all template files, in any virtual directory: `**.tmpl` -- List all mail template files: `templates/mail/**.tmpl` -- List all files inside `public/assets/img`: `public/assets/img/**` - -Don't forget to use quotes for the patterns, as spaces, `*` and other characters might have -a special meaning for your command shell. - -If no pattern is provided, all files are listed. - -### Example: Listing all embedded files - -Listing all embedded files with `openid` in their path: - -```sh -$ gitea embedded list '**openid**' -public/assets/img/auth/openid_connect.svg -public/assets/img/openid-16x16.png -templates/user/auth/finalize_openid.tmpl -templates/user/auth/signin_openid.tmpl -templates/user/auth/signup_openid_connect.tmpl -templates/user/auth/signup_openid_navbar.tmpl -templates/user/auth/signup_openid_register.tmpl -templates/user/settings/security_openid.tmpl -``` - -## Extracting resources - -To extract resources embedded in Gitea's executable, use the following syntax: - -```sh -gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...} -``` - -The `--config` option tells Gitea the location of the `app.ini` configuration file if -it's not in its default location. This option is only used with the `--custom` flag. - -The `--destination` option tells Gitea the directory where the files must be extracted to. -The default is the current directory. - -The `--custom` flag tells Gitea to extract the files directly into the `custom` directory. -For this to work, the command needs to know the location of the `app.ini` configuration -file (`--config`) and, depending of the configuration, be ran from the directory where -Gitea normally starts. See [Customizing Gitea](administration/customizing-gitea.md) for details. - -The `--overwrite` flag allows any existing files in the destination directory to be overwritten. - -The `--rename` flag tells Gitea to rename any existing files in the destination directory -as `filename.bak`. Previous `.bak` files are overwritten. - -At least one file search pattern must be provided; see `list` subcomand above for pattern -syntax and examples. - -### Important notice - -Make sure to **only extract those files that require customization**. Files that -are present in the `custom` directory are not upgraded by Gitea's upgrade process. -When Gitea is upgraded to a new version (by replacing the executable), many of the -embedded files will suffer changes. Gitea will honor and use any files found -in the `custom` directory, even if they are old and incompatible. - -### Example: Extracting mail templates - -Extracting mail templates to a temporary directory: - -```sh -$ mkdir tempdir -$ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl' -Extracting to tempdir: -tempdir/templates/mail/auth/activate.tmpl -tempdir/templates/mail/auth/activate_email.tmpl -tempdir/templates/mail/auth/register_notify.tmpl -tempdir/templates/mail/auth/reset_passwd.tmpl -tempdir/templates/mail/issue/assigned.tmpl -tempdir/templates/mail/issue/default.tmpl -tempdir/templates/mail/notify/collaborator.tmpl -``` diff --git a/docs/content/administration/cmd-embedded.zh-cn.md b/docs/content/administration/cmd-embedded.zh-cn.md deleted file mode 100644 index a2df1aa2f5..0000000000 --- a/docs/content/administration/cmd-embedded.zh-cn.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "嵌入资源提取工具" -slug: "cmd-embedded" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/cmd-embedded -menu: - sidebar: - parent: "administration" - name: "嵌入资源提取工具" - sidebar_position: 20 - identifier: "cmd-embedded" ---- - -# 嵌入资源提取工具 - -Gitea 的可执行文件包含了运行所需的所有资源:模板、图片、样式表和翻译文件。你可以通过在 `custom` 目录下的相应路径中放置替换文件来覆盖其中的任何资源(详见 [自定义 Gitea 配置](administration/customizing-gitea.md))。 - -要获取嵌入资源的副本以进行编辑,可以使用 CLI 中的 `embedded` 命令,通过操作系统的 shell 执行。 - -**注意:** 嵌入资源提取工具包含在 Gitea 1.12 及以上版本中。 - -## 资源列表 - -要列出嵌入在 Gitea 可执行文件中的资源,请使用以下语法: - -```sh -gitea embedded list [--include-vendored] [patterns...] -``` - -`--include-vendored` 标志使命令包括被供应的文件,这些文件通常被排除在外;即来自外部库的文件,这些文件是 Gitea 所需的(例如 [octicons](https://octicons.github.com/) 等)。 - -可以提供一系列文件搜索模式。Gitea 使用 [gobwas/glob](https://github.com/gobwas/glob) 作为其 glob 语法。以下是一些示例: - -- 列出所有模板文件,无论在哪个虚拟目录下:`**.tmpl` -- 列出所有邮件模板文件:`templates/mail/**.tmpl` -列出 `public/assets/img` 目录下的所有文件:`public/assets/img/**` - -不要忘记为模式使用引号,因为空格、`*` 和其他字符可能对命令行解释器有特殊含义。 - -如果未提供模式,则列出所有文件。 - -### 示例:列出所有嵌入文件 - -列出所有路径中包含 `openid` 的嵌入文件: - -```sh -$ gitea embedded list '**openid**' -public/assets/img/auth/openid_connect.svg -public/assets/img/openid-16x16.png -templates/user/auth/finalize_openid.tmpl -templates/user/auth/signin_openid.tmpl -templates/user/auth/signup_openid_connect.tmpl -templates/user/auth/signup_openid_navbar.tmpl -templates/user/auth/signup_openid_register.tmpl -templates/user/settings/security_openid.tmpl -``` - -## 提取资源 - -要提取嵌入在 Gitea 可执行文件中的资源,请使用以下语法: - -```sh -gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...} -``` - -`--config` 选项用于告知 Gitea `app.ini` 配置文件的位置(如果不在默认位置)。此选项仅在使用 `--custom` 标志时使用。 - -`--destination` 选项用于指定提取文件的目标目录。默认为当前目录。 - -`--custom` 标志告知 Gitea 直接将文件提取到 `custom` 目录中。为使其正常工作,该命令需要知道 `app.ini` 配置文件的位置(通过 `--config` 指定),并且根据配置的不同,需要从 Gitea 通常启动的目录运行。有关详细信息,请参阅 [自定义 Gitea 配置](administration/customizing-gitea.md)。 - -`--overwrite` 标志允许覆盖目标目录中的任何现有文件。 - -`--rename` 标志告知 Gitea 将目标目录中的任何现有文件重命名为 `filename.bak`。之前的 `.bak` 文件将被覆盖。 - -至少需要提供一个文件搜索模式;有关模式的语法和示例,请参阅上述 `list` 子命令。 - -### 重要提示 - -请确保**只提取需要自定义的文件**。位于 `custom` 目录中的文件不会受到 Gitea 的升级过程的影响。当 Gitea 升级到新版本(通过替换可执行文件)时,许多嵌入文件将发生变化。Gitea 将尊重并使用在 `custom` 目录中找到的任何文件,即使这些文件是旧的和不兼容的。 - -### 示例:提取邮件模板 - -将邮件模板提取到临时目录: - -```sh -$ mkdir tempdir -$ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl' -Extracting to tempdir: -tempdir/templates/mail/auth/activate.tmpl -tempdir/templates/mail/auth/activate_email.tmpl -tempdir/templates/mail/auth/register_notify.tmpl -tempdir/templates/mail/auth/reset_passwd.tmpl -tempdir/templates/mail/issue/assigned.tmpl -tempdir/templates/mail/issue/default.tmpl -tempdir/templates/mail/notify/collaborator.tmpl -``` diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md deleted file mode 100644 index 752a8d4c6f..0000000000 --- a/docs/content/administration/command-line.en-us.md +++ /dev/null @@ -1,571 +0,0 @@ ---- -date: "2017-01-01T16:00:00+02:00" -title: "Gitea Command Line" -slug: "command-line" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /en-us/command-line -menu: - sidebar: - parent: "administration" - name: "Command Line" - sidebar_position: 1 - identifier: "command-line" ---- - -# Command Line - -## Usage - -`gitea [global options] command [command or global options] [arguments...]` - -## Global options - -All global options can be placed at the command level. - -- `--help`, `-h`: Show help text and exit. Optional. -- `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`). -- `--work-path path`, `-w path`: Gitea's work path. Optional. (default: the binary's path or `$GITEA_WORK_DIR`) -- `--custom-path path`, `-C path`: Gitea's custom folder path. Optional. (default: `WorkPath`/custom or `$GITEA_CUSTOM`). -- `--config path`, `-c path`: Gitea configuration file path. Optional. (default: `CustomPath`/conf/app.ini). - -NB: The defaults custom-path, config and work-path can also be -changed at build time (if preferred). - -## Commands - -### web - -Starts the server: - -- Options: - - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file. - - `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file. - - `--pid path`, `-P path`: Pidfile path. Optional. - - `--quiet`, `-q`: Only emit Fatal logs on the console for logs emitted before logging set up. - - `--verbose`: Emit tracing logs on the console for logs emitted before logging is set-up. -- Examples: - - `gitea web` - - `gitea web --port 80` - - `gitea web --config /etc/gitea.ini --pid /some/custom/gitea.pid` -- Notes: - - Gitea should not be run as root. To bind to a port below 1024, you can use setcap on - Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be - redone every time you update Gitea. - -### admin - -Admin operations: - -- Commands: - - `user`: - - `list`: - - Options: - - `--admin`: List only admin users. Optional. - - Description: lists all users that exist - - Examples: - - `gitea admin user list` - - `delete`: - - Options: - - `--email`: Email of the user to be deleted. - - `--username`: Username of user to be deleted. - - `--id`: ID of user to be deleted. - - One of `--id`, `--username` or `--email` is required. If more than one is provided then all have to match. - - Examples: - - `gitea admin user delete --id 1` - - `create`: - - Options: - - `--name value`: Username. Required. As of Gitea 1.9.0, use the `--username` flag instead. - - `--username value`: Username. Required. New in Gitea 1.9.0. - - `--password value`: Password. Required. - - `--email value`: Email. Required. - - `--admin`: If provided, this makes the user an admin. Optional. - - `--access-token`: If provided, an access token will be created for the user. Optional. (default: false). - - `--must-change-password`: The created user will be required to set a new password after the initial login, default: true. It could be disabled by `--must-change-password=false`. - - `--random-password`: If provided, a randomly generated password will be used as the password of the created - user. The value of `--password` will be discarded. Optional. - - `--random-password-length`: If provided, it will be used to configure the length of the randomly generated - password. Optional. (default: 12) - - Examples: - - `gitea admin user create --username myname --password asecurepassword --email me@example.com` - - `change-password`: - - Options: - - `--username value`, `-u value`: Username. Required. - - `--password value`, `-p value`: New password. Required. - - `--must-change-password`: The user is required to set a new password after the login, default: true. It could be disabled by `--must-change-password=false`. - - Examples: - - `gitea admin user change-password --username myname --password asecurepassword` - - `must-change-password`: - - Args: - - `[username...]`: Users that must change their passwords - - Options: - - `--all`, `-A`: Force a password change for all users - - `--exclude username`, `-e username`: Exclude the given user. Can be set multiple times. - - `--unset`: Revoke forced password change for the given users - - `generate-access-token`: - - Options: - - `--username value`, `-u value`: Username. Required. - - `--token-name value`, `-t value`: Token name. Required. - - `--scopes value`: Comma-separated list of scopes. Scopes follow the format `[read|write]:<block>` or `all` where `<block>` is one of the available visual groups you can see when opening the API page showing the available routes (for example `repo`). - - Examples: - - `gitea admin user generate-access-token --username myname --token-name mytoken` - - `gitea admin user generate-access-token --help` - - `regenerate` - - Options: - - `hooks`: Regenerate Git Hooks for all repositories - - `keys`: Regenerate authorized_keys file - - Examples: - - `gitea admin regenerate hooks` - - `gitea admin regenerate keys` - - `auth`: - - `list`: - - Description: lists all external authentication sources that exist - - Examples: - - `gitea admin auth list` - - `delete`: - - Options: - - `--id`: ID of source to be deleted. Required. - - Examples: - - `gitea admin auth delete --id 1` - - `add-oauth`: - - Options: - - `--name`: Application Name. - - `--provider`: OAuth2 Provider. - - `--key`: Client ID (Key). - - `--secret`: Client Secret. - - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider). - - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints. - - `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints. - - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub). - - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub). - - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub). - - `--custom-email-url`: Use a custom Email URL (option for GitHub). - - `--icon-url`: Custom icon URL for OAuth2 login source. - - `--skip-local-2fa`: Allow source to override local 2FA. (Optional) - - `--scopes`: Additional scopes to request for this OAuth2 source. (Optional) - - `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional) - - `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional) - - `--group-claim-name`: Claim name providing group names for this source. (Optional) - - `--admin-group`: Group Claim value for administrator users. (Optional) - - `--restricted-group`: Group Claim value for restricted users. (Optional) - - `--group-team-map`: JSON mapping between groups and org teams. (Optional) - - `--group-team-map-removal`: Activate automatic team membership removal depending on groups. (Optional) - - Examples: - - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE` - - `update-oauth`: - - Options: - - `--id`: ID of source to be updated. Required. - - `--name`: Application Name. - - `--provider`: OAuth2 Provider. - - `--key`: Client ID (Key). - - `--secret`: Client Secret. - - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider). - - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints. - - `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints. - - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub). - - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub). - - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub). - - `--custom-email-url`: Use a custom Email URL (option for GitHub). - - `--icon-url`: Custom icon URL for OAuth2 login source. - - `--skip-local-2fa`: Allow source to override local 2FA. (Optional) - - `--scopes`: Additional scopes to request for this OAuth2 source. - - `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional) - - `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional) - - `--group-claim-name`: Claim name providing group names for this source. (Optional) - - `--admin-group`: Group Claim value for administrator users. (Optional) - - `--restricted-group`: Group Claim value for restricted users. (Optional) - - Examples: - - `gitea admin auth update-oauth --id 1 --name external-github-updated` - - `add-smtp`: - - Options: - - `--name`: Application Name. Required. - - `--auth-type`: SMTP Authentication Type (PLAIN/LOGIN/CRAM-MD5). Default to PLAIN. - - `--host`: SMTP host. Required. - - `--port`: SMTP port. Required. - - `--force-smtps`: SMTPS is always used on port 465. Set this to force SMTPS on other ports. - - `--skip-verify`: Skip TLS verify. - - `--helo-hostname`: Hostname sent with HELO. Leave blank to send current hostname. - - `--disable-helo`: Disable SMTP helo. - - `--allowed-domains`: Leave empty to allow all domains. Separate multiple domains with a comma (','). - - `--skip-local-2fa`: Skip 2FA to log on. - - `--active`: This Authentication Source is Activated. - Remarks: - `--force-smtps`, `--skip-verify`, `--disable-helo`, `--skip-loca-2fs` and `--active` options can be used in form: - - `--option`, `--option=true` to enable - - `--option=false` to disable - If those options are not specified value would not be changed in `update-smtp` or would use default `false` value in `add-smtp` - - Examples: - - `gitea admin auth add-smtp --name ldap --host smtp.mydomain.org --port 587 --skip-verify --active` - - `update-smtp`: - - Options: - - `--id`: ID of source to be updated. Required. - - other options are shared with `add-smtp` - - Examples: - - `gitea admin auth update-smtp --id 1 --host smtp.mydomain.org --port 587 --skip-verify=false` - - `gitea admin auth update-smtp --id 1 --active=false` - - `add-ldap`: Add new LDAP (via Bind DN) authentication source - - Options: - - `--name value`: Authentication name. Required. - - `--not-active`: Deactivate the authentication source. - - `--security-protocol value`: Security protocol name. Required. - - `--skip-tls-verify`: Disable TLS verification. - - `--host value`: The address where the LDAP server can be reached. Required. - - `--port value`: The port to use when connecting to the LDAP server. Required. - - `--user-search-base value`: The LDAP base at which user accounts will be searched for. Required. - - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required. - - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges. - - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status. - - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name. - - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name. - - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname. - - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required. - - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key. - - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar. - - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user. - - `--bind-password value`: The password for the Bind DN, if any. - - `--attributes-in-bind`: Fetch attributes in bind DN context. - - `--synchronize-users`: Enable user synchronization. - - `--page-size value`: Search page size. - - Examples: - - `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" --email-attribute mail` - - `update-ldap`: Update existing LDAP (via Bind DN) authentication source - - Options: - - `--id value`: ID of authentication source. Required. - - `--name value`: Authentication name. - - `--not-active`: Deactivate the authentication source. - - `--security-protocol value`: Security protocol name. - - `--skip-tls-verify`: Disable TLS verification. - - `--host value`: The address where the LDAP server can be reached. - - `--port value`: The port to use when connecting to the LDAP server. - - `--user-search-base value`: The LDAP base at which user accounts will be searched for. - - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. - - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges. - - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status. - - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name. - - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name. - - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname. - - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. - - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key. - - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar. - - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user. - - `--bind-password value`: The password for the Bind DN, if any. - - `--attributes-in-bind`: Fetch attributes in bind DN context. - - `--synchronize-users`: Enable user synchronization. - - `--page-size value`: Search page size. - - Examples: - - `gitea admin auth update-ldap --id 1 --name "my ldap auth source"` - - `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn` - - `add-ldap-simple`: Add new LDAP (simple auth) authentication source - - Options: - - `--name value`: Authentication name. Required. - - `--not-active`: Deactivate the authentication source. - - `--security-protocol value`: Security protocol name. Required. - - `--skip-tls-verify`: Disable TLS verification. - - `--host value`: The address where the LDAP server can be reached. Required. - - `--port value`: The port to use when connecting to the LDAP server. Required. - - `--user-search-base value`: The LDAP base at which user accounts will be searched for. - - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required. - - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges. - - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status. - - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name. - - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name. - - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname. - - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required. - - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key. - - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar. - - `--user-dn value`: The user’s DN. Required. - - Examples: - - `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail` - - `update-ldap-simple`: Update existing LDAP (simple auth) authentication source - - Options: - - `--id value`: ID of authentication source. Required. - - `--name value`: Authentication name. - - `--not-active`: Deactivate the authentication source. - - `--security-protocol value`: Security protocol name. - - `--skip-tls-verify`: Disable TLS verification. - - `--host value`: The address where the LDAP server can be reached. - - `--port value`: The port to use when connecting to the LDAP server. - - `--user-search-base value`: The LDAP base at which user accounts will be searched for. - - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. - - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges. - - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status. - - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name. - - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name. - - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname. - - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. - - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key. - - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar. - - `--user-dn value`: The user’s DN. - - Examples: - - `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"` - - `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn` - -### cert - -Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current -directory and will overwrite any existing files. - -- Options: - - `--host value`: Comma separated hostnames and ips which this certificate is valid for. - Wildcards are supported. Required. - - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options - are P224, P256, P384, P521. - - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is - set. (default: 3072). - - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`). - - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s) - - `--ca`: If provided, this cert generates it's own certificate authority. Optional. -- Examples: - - `gitea cert --host git.example.com,example.com,www.example.com --ca` - -### dump - -Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip` -in the current directory. - -- Options: - - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip). - - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp). - - `--skip-repository`, `-R`: Skip the repository dumping. Optional. - - `--skip-custom-dir`: Skip dumping of the custom dir. Optional. - - `--skip-lfs-data`: Skip dumping of LFS data. Optional. - - `--skip-attachment-data`: Skip dumping of attachment data. Optional. - - `--skip-package-data`: Skip dumping of package data. Optional. - - `--skip-log`: Skip dumping of log data. Optional. - - `--database`, `-d`: Specify the database SQL syntax. Optional (supported arguments: sqlite3, mysql, mssql, postgres). - - `--verbose`, `-V`: If provided, shows additional details. Optional. - - `--type`: Set the dump output format. Optional. (formats: zip, tar, tar.sz, tar.gz, tar.xz, tar.bz2, tar.br, tar.lz4, tar.zst default: zip). -- Examples: - - `gitea dump` - - `gitea dump --verbose` - -### generate - -Generates random values and tokens for usage in configuration file. Useful for generating values -for automatic deployments. - -- Commands: - - `secret`: - - Options: - - `INTERNAL_TOKEN`: Token used for an internal API call authentication. - - `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility). - - `SECRET_KEY`: Global secret key. - - Examples: - - `gitea generate secret INTERNAL_TOKEN` - - `gitea generate secret JWT_SECRET` - - `gitea generate secret SECRET_KEY` - -### keys - -Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file: - -```ini -... -# The value of -e and the AuthorizedKeysCommandUser should match the -# username running Gitea -AuthorizedKeysCommandUser git -AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k -``` - -The command will return the appropriate authorized_keys line for the -provided key. You should also set the value -`SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of -`app.ini`. - -NB: opensshd requires the Gitea program to be owned by root and not -writable by group or others. The program must be specified by an absolute -path. -NB: Gitea must be running for this command to succeed. - -### migrate - -Migrates the database. This command can be used to run other commands before starting the server for the first time. -This command is idempotent. - -### doctor check - -Diagnose and potentially fix problems with the current Gitea instance. -Several checks are run by default, but additional ones can be run: - -- `gitea doctor check --list` - will list all the available checks -- `gitea doctor check --all` - will run all available checks -- `gitea doctor check --default` - will run the default checks -- `gitea doctor check --run [check(s),]...` - will run the named checks - -Some problems can be automatically fixed by passing the `--fix` option. -Extra logging can be set with `--log-file=...`. - -#### doctor recreate-table - -Sometimes when there are migrations the old columns and default values may be left -unchanged in the database schema. This may lead to warning such as: - -``` -2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0 -``` - -You can cause Gitea to recreate these tables and copy the old data into the new table -with the defaults set appropriately by using: - -``` -gitea doctor recreate-table user -``` - -You can ask Gitea to recreate multiple tables using: - -``` -gitea doctor recreate-table table1 table2 ... -``` - -And if you would like Gitea to recreate all tables simply call: - -``` -gitea doctor recreate-table -``` - -It is highly recommended to back-up your database before running these commands. - -### doctor convert - -Converts a MySQL database from utf8 to utf8mb4 or a MSSQL database from varchar to nvarchar. - -### manager - -Manage running server operations: - -- Commands: - - `shutdown`: Gracefully shutdown the running process - - `restart`: Gracefully restart the running process - (not implemented for windows servers) - - `flush-queues`: Flush queues in the running process - - Options: - - `--timeout value`: Timeout for the flushing process (default: 1m0s) - - `--non-blocking`: Set to true to not wait for flush to complete before returning - - `logging`: Adjust logging commands - - Commands: - - `pause`: Pause logging - - Notes: - - The logging level will be raised to INFO temporarily if it is below this level. - - Gitea will buffer logs up to a certain point and will drop them after that point. - - `resume`: Resume logging - - `release-and-reopen`: Cause Gitea to release and re-open files and connections used for logging (Equivalent to sending SIGUSR1 to Gitea.) - - `remove name`: Remove the named logger - - Options: - - `--group group`, `-g group`: Set the group to remove the sublogger from. (defaults to `default`) - - `add`: Add a logger - - Commands: - - `console`: Add a console logger - - Options: - - `--group value`, `-g value`: Group to add logger to - will default to "default" - - `--name value`, `-n value`: Name of the new logger - will default to mode - - `--level value`, `-l value`: Logging level for the new logger - - `--stacktrace-level value`, `-L value`: Stacktrace logging level - - `--flags value`, `-F value`: Flags for the logger - - `--expression value`, `-e value`: Matching expression for the logger - - `--prefix value`, `-p value`: Prefix for the logger - - `--color`: Use color in the logs - - `--stderr`: Output console logs to stderr - only relevant for console - - `file`: Add a file logger - - Options: - - `--group value`, `-g value`: Group to add logger to - will default to "default" - - `--name value`, `-n value`: Name of the new logger - will default to mode - - `--level value`, `-l value`: Logging level for the new logger - - `--stacktrace-level value`, `-L value`: Stacktrace logging level - - `--flags value`, `-F value`: Flags for the logger - - `--expression value`, `-e value`: Matching expression for the logger - - `--prefix value`, `-p value`: Prefix for the logger - - `--color`: Use color in the logs - - `--filename value`, `-f value`: Filename for the logger - - - `--rotate`, `-r`: Rotate logs - - `--max-size value`, `-s value`: Maximum size in bytes before rotation - - `--daily`, `-d`: Rotate logs daily - - `--max-days value`, `-D value`: Maximum number of daily logs to keep - - `--compress`, `-z`: Compress rotated logs - - `--compression-level value`, `-Z value`: Compression level to use - - `conn`: Add a network connection logger - - Options: - - `--group value`, `-g value`: Group to add logger to - will default to "default" - - `--name value`, `-n value`: Name of the new logger - will default to mode - - `--level value`, `-l value`: Logging level for the new logger - - `--stacktrace-level value`, `-L value`: Stacktrace logging level - - `--flags value`, `-F value`: Flags for the logger - - `--expression value`, `-e value`: Matching expression for the logger - - `--prefix value`, `-p value`: Prefix for the logger - - `--color`: Use color in the logs - - `--reconnect-on-message`, `-R`: Reconnect to host for every message - - `--reconnect`, `-r`: Reconnect to host when connection is dropped - - `--protocol value`, `-P value`: Set protocol to use: tcp, unix, or udp (defaults to tcp) - - `--address value`, `-a value`: Host address and port to connect to (defaults to :7020) - - `smtp`: Add an SMTP logger - - Options: - - `--group value`, `-g value`: Group to add logger to - will default to "default" - - `--name value`, `-n value`: Name of the new logger - will default to mode - - `--level value`, `-l value`: Logging level for the new logger - - `--stacktrace-level value`, `-L value`: Stacktrace logging level - - `--flags value`, `-F value`: Flags for the logger - - `--expression value`, `-e value`: Matching expression for the logger - - `--prefix value`, `-p value`: Prefix for the logger - - `--color`: Use color in the logs - - `--username value`, `-u value`: Mail server username - - `--password value`, `-P value`: Mail server password - - `--host value`, `-H value`: Mail server host (defaults to: 127.0.0.1:25) - - `--send-to value`, `-s value`: Email address(es) to send to - - `--subject value`, `-S value`: Subject header of sent emails - - `processes`: Display Gitea processes and goroutine information - - Options: - - `--flat`: Show processes as flat table rather than as tree - - `--no-system`: Do not show system processes - - `--stacktraces`: Show stacktraces for goroutines associated with processes - - `--json`: Output as json - - `--cancel PID`: Send cancel to process with PID. (Only for non-system processes.) - -### dump-repo - -Dump-repo dumps repository data from Git/GitHub/Gitea/GitLab: - -- Options: - - `--git_service service` : Git service, it could be `git`, `github`, `gitea`, `gitlab`, If clone_addr could be recognized, this could be ignored. - - `--repo_dir dir`, `-r dir`: Repository dir path to store the data - - `--clone_addr addr`: The URL will be clone, currently could be a git/github/gitea/gitlab http/https URL. i.e. https://github.com/lunny/tango.git - - `--auth_username lunny`: The username to visit the clone_addr - - `--auth_password <password>`: The password to visit the clone_addr - - `--auth_token <token>`: The personal token to visit the clone_addr - - `--owner_name lunny`: The data will be stored on a directory with owner name if not empty - - `--repo_name tango`: The data will be stored on a directory with repository name if not empty - - `--units <units>`: Which items will be migrated, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units. - -### restore-repo - -Restore-repo restore repository data from disk dir: - -- Options: - - `--repo_dir dir`, `-r dir`: Repository dir path to restore from - - `--owner_name lunny`: Restore destination owner name - - `--repo_name tango`: Restore destination repository name - - `--units <units>`: Which items will be restored, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units. - -### actions generate-runner-token - -Generate a new token for a runner to use to register with the server - -- Options: - - `--scope {owner}[/{repo}]`, `-s {owner}[/{repo}]`: To limit the scope of the runner, no scope means the runner can be used for all repos, but you can also limit it to a specific repo or owner - -To register a global runner: - -``` -gitea actions generate-runner-token -``` - -To register a runner for a specific organization, in this case `org`: - -``` -gitea actions generate-runner-token -s org -``` - -To register a runner for a specific repo, in this case `username/test-repo`: - -``` -gitea actions generate-runner-token -s username/test-repo -``` diff --git a/docs/content/administration/command-line.zh-cn.md b/docs/content/administration/command-line.zh-cn.md deleted file mode 100644 index 6e6bcb6082..0000000000 --- a/docs/content/administration/command-line.zh-cn.md +++ /dev/null @@ -1,542 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "Gitea 命令行" -slug: "command-line" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /zh-cn/command-line -menu: - sidebar: - parent: "administration" - name: "Gitea 命令行" - sidebar_position: 1 - identifier: "command-line" ---- - -# 命令行 - -## 用法 - -`gitea [全局选项] 命令 [命令或全局选项] [参数...]` - -## 全局选项 - -所有全局选项均可被放置在命令级别。 - -- `--help`,`-h`:显示帮助文本并退出。可选。 -- `--version`,`-v`:显示版本信息并退出。可选。 (示例:`Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`)。 -- `--custom-path path`,`-C path`:Gitea 自定义文件夹的路径。可选。 (默认值:`AppWorkPath`/custom 或 `$GITEA_CUSTOM`)。 -- `--config path`,`-c path`:Gitea 配置文件的路径。可选。 (默认值:`custom`/conf/app.ini)。 -- `--work-path path`,`-w path`:Gitea 的 `AppWorkPath`。可选。 (默认值:LOCATION_OF_GITEA_BINARY 或 `$GITEA_WORK_DIR`) - -注意:默认的 custom-path、config 和 work-path 也可以在构建时更改(如果需要)。 - -## 命令 - -### web - -启动服务器: - -- 选项: - - `--port number`,`-p number`:端口号。可选。 (默认值:3000)。覆盖配置文件中的设置。 - - `--install-port number`:运行安装页面的端口号。可选。 (默认值:3000)。覆盖配置文件中的设置。 - - `--pid path`,`-P path`:Pid 文件的路径。可选。 - - `--quiet`,`-q`:只在控制台上输出 Fatal 日志,用于在设置日志之前发出的日志。 - - `--verbose`:在控制台上输出跟踪日志,用于在设置日志之前发出的日志。 -- 示例: - - `gitea web` - - `gitea web --port 80` - - `gitea web --config /etc/gitea.ini --pid /some/custom/gitea.pid` -- 注意: - - Gitea 不应以 root 用户身份运行。要绑定到低于 1024 的端口,您可以在 Linux 上使用 setcap 命令:`sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`。每次更新 Gitea 都需要重新执行此操作。 - -### admin - -管理员操作: - -- 命令: - - `user`: - - `list`: - - 选项: - - `--admin`:仅列出管理员用户。可选。 - - 描述:列出所有现有用户。 - - 示例: - - `gitea admin user list` - - `delete`: - - 选项: - - `--email`:要删除的用户的电子邮件。 - - `--username`:要删除的用户的用户名。 - - `--id`:要删除的用户的ID。 - - 必须提供 `--id`、`--username` 或 `--email` 中的一个。如果提供多个,则所有条件必须匹配。 - - 示例: - - `gitea admin user delete --id 1` - - `create`: - - 选项: - - `--name value`:用户名。必填。自 Gitea 1.9.0 版本起,请改用 `--username` 标志。 - - `--username value`:用户名。必填。Gitea 1.9.0 新增。 - - `--password value`:密码。必填。 - - `--email value`:邮箱。必填。 - - `--admin`:如果提供此选项,将创建一个管理员用户。可选。 - - `--access-token`:如果提供,将为用户创建访问令牌。可选。(默认值:false)。 - - `--must-change-password`:如果提供,创建的用户将在初始登录后需要选择一个新密码。可选。(默认值:true)。 - - `--random-password`:如果提供,将使用随机生成的密码作为创建用户的密码。`--password` 的值将被忽略。可选。 - - `--random-password-length`:如果提供,将用于配置随机生成密码的长度。可选。(默认值:12) - - 示例: - - `gitea admin user create --username myname --password asecurepassword --email me@example.com` - - `change-password`: - - 选项: - - `--username value`,`-u value`:用户名。必填。 - - `--password value`,`-p value`:新密码。必填。 - - 示例: - - `gitea admin user change-password --username myname --password asecurepassword` - - `must-change-password`: - - 参数: - - `[username...]`:需要更改密码的用户 - - 选项: - - `--all`,`-A`:强制所有用户更改密码 - - `--exclude username`,`-e username`:排除给定的用户。可以多次设置。 - - `--unset`:撤销对给定用户的强制密码更改 - - `regenerate`: - - 选项: - - `hooks`:重新生成所有仓库的 Git Hooks。 - - `keys`:重新生成 authorized_keys 文件。 - - 示例: - - `gitea admin regenerate hooks` - - `gitea admin regenerate keys` - - `auth`: - - `list`: - - 描述:列出所有存在的外部认证源。 - - 示例: - - `gitea admin auth list` - - `delete`: - - 选项: - - `--id`:要删除的源的 ID。必填。 - - 示例: - - `gitea admin auth delete --id 1` - - `add-oauth`: - - 选项: - - `--name`:应用程序名称。 - - `--provider`:OAuth2 提供者。 - - `--key`:客户端 ID(Key)。 - - `--secret`:客户端密钥。 - - `--auto-discover-url`:OpenID Connect 自动发现 URL(仅在使用 OpenID Connect 作为提供程序时需要)。 - - `--use-custom-urls`:在 GitLab/GitHub OAuth 端点上使用自定义 URL。 - - `--custom-tenant-id`:在 OAuth 端点上使用自定义租户 ID。 - - `--custom-auth-url`:使用自定义授权 URL(GitLab/GitHub 的选项)。 - - `--custom-token-url`:使用自定义令牌 URL(GitLab/GitHub 的选项)。 - - `--custom-profile-url`:使用自定义配置文件 URL(GitLab/GitHub 的选项)。 - - `--custom-email-url`:使用自定义电子邮件 URL(GitHub 的选项)。 - - `--icon-url`:OAuth2 登录源的自定义图标 URL。 - - `--skip-local-2fa`:允许源覆盖本地 2FA。(可选) - - `--scopes`:请求此 OAuth2 源的附加范围。(可选) - - `--required-claim-name`:必须设置的声明名称,以允许用户使用此源登录。(可选) - - `--required-claim-value`:必须设置的声明值,以允许用户使用此源登录。(可选) - - `--group-claim-name`:提供此源的组名的声明名称。(可选) - - `--admin-group`:管理员用户的组声明值。(可选) - - `--restricted-group`:受限用户的组声明值。(可选) - - `--group-team-map`:组与组织团队之间的 JSON 映射。(可选) - - `--group-team-map-removal`:根据组自动激活团队成员资格的删除。(可选) - - 示例: - - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE` - - `update-oauth`: - - 选项: - - `--id`:要更新的源的 ID。必填。 - - `--name`:应用程序名称。 - - `--provider`:OAuth2 提供者。 - - `--key`:客户端 ID(Key)。 - - `--secret`:客户端密钥。 - - `--auto-discover-url`:OpenID Connect 自动发现 URL(仅在使用 OpenID Connect 作为提供程序时需要)。 - - `--use-custom-urls`:在 GitLab/GitHub OAuth 端点上使用自定义 URL。 - - `--custom-tenant-id`:在 OAuth 端点上使用自定义租户 ID。 - - `--custom-auth-url`:使用自定义授权 URL(GitLab/GitHub 的选项)。 - - `--custom-token-url`:使用自定义令牌 URL(GitLab/GitHub 的选项)。 - - `--custom-profile-url`:使用自定义配置文件 URL(GitLab/GitHub 的选项)。 - - `--custom-email-url`:使用自定义电子邮件 URL(GitHub 的选项)。 - - `--icon-url`:OAuth2 登录源的自定义图标 URL。 - - `--skip-local-2fa`:允许源覆盖本地 2FA。(可选) - - `--scopes`:请求此 OAuth2 源的附加范围。 - - `--required-claim-name`:必须设置的声明名称,以允许用户使用此源登录。(可选) - - `--required-claim-value`:必须设置的声明值,以允许用户使用此源登录。(可选) - - `--group-claim-name`:提供此源的组名的声明名称。(可选) - - `--admin-group`:管理员用户的组声明值。(可选) - - `--restricted-group`:受限用户的组声明值。(可选) - - 示例: - - `gitea admin auth update-oauth --id 1 --name external-github-updated` - - `add-smtp`: - - 选项: - - `--name`:应用程序名称。必填。 - - `--auth-type`:SMTP 认证类型(PLAIN/LOGIN/CRAM-MD5)。默认为 PLAIN。 - - `--host`:SMTP 主机。必填。 - - `--port`:SMTP 端口。必填。 - - `--force-smtps`:SMTPS 始终在端口 465 上使用。设置此选项以强制在其他端口上使用 SMTPS。 - - `--skip-verify`:跳过 TLS 验证。 - - `--helo-hostname`:发送 HELO 时使用的主机名。留空以发送当前主机名。 - - `--disable-helo`:禁用 SMTP helo。 - - `--allowed-domains`:留空以允许所有域。使用逗号(',')分隔多个域。 - - `--skip-local-2fa`:跳过 2FA 登录。 - - `--active`:启用此认证源。 - 备注: - `--force-smtps`、`--skip-verify`、`--disable-helo`、`--skip-local-2fs` 和 `--active` 选项可以采用以下形式使用: - - `--option`、`--option=true` 以启用选项 - - `--option=false` 以禁用选项 - 如果未指定这些选项,则在 `update-smtp` 中不会更改值,或者在 `add-smtp` 中将使用默认的 `false` 值。 - - 示例: - - `gitea admin auth add-smtp --name ldap --host smtp.mydomain.org --port 587 --skip-verify --active` - - `update-smtp`: - - 选项: - - `--id`:要更新的源的 ID。必填。 - - 其他选项与 `add-smtp` 共享 - - 示例: - - `gitea admin auth update-smtp --id 1 --host smtp.mydomain.org --port 587 --skip-verify=false` - - `gitea admin auth update-smtp --id 1 --active=false` - - `add-ldap`:添加新的 LDAP(通过 Bind DN)认证源 - - 选项: - - `--name value`:认证名称。必填。 - - `--not-active`:停用认证源。 - - `--security-protocol value`:安全协议名称。必填。 - - `--skip-tls-verify`:禁用 TLS 验证。 - - `--host value`:LDAP 服务器的地址。必填。 - - `--port value`:连接到 LDAP 服务器时使用的端口。必填。 - - `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。必填。 - - `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。必填。 - - `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。 - - `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。 - - `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。 - - `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。 - - `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。 - - `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。必填。 - - `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。 - - `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。 - - `--bind-dn value`:在搜索用户时绑定到 LDAP 服务器的 DN。 - - `--bind-password value`:绑定 DN 的密码(如果有)。 - - `--attributes-in-bind`:在绑定 DN 上下文中获取属性。 - - `--synchronize-users`:启用用户同步。 - - `--page-size value`:搜索页面大小。 - - 示例: - - `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" --email-attribute mail` - - `update-ldap`:更新现有的 LDAP(通过 Bind DN)认证源 - - 选项: - - `--id value`:认证源的 ID。必填。 - - `--name value`:认证名称。 - - `--not-active`:停用认证源。 - - `--security-protocol value`:安全协议名称。 - - `--skip-tls-verify`:禁用 TLS 验证。 - - `--host value`:LDAP 服务器的地址。 - - `--port value`:连接到 LDAP 服务器时使用的端口。 - - `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。 - - `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。 - - `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。 - - `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。 - - `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。 - - `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。 - - `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。 - - `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。 - - `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。 - - `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。 - - `--bind-dn value`:在搜索用户时绑定到 LDAP 服务器的 DN。 - - `--bind-password value`:绑定 DN 的密码(如果有)。 - - `--attributes-in-bind`:在绑定 DN 上下文中获取属性。 - - `--synchronize-users`:启用用户同步。 - - `--page-size value`:搜索页面大小。 - - 示例: - - `gitea admin auth update-ldap --id 1 --name "my ldap auth source"` - - `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn` - - `add-ldap-simple`:添加新的 LDAP(简单身份验证)认证源 - - 选项: - - `--name value`:认证名称。必填。 - - `--not-active`:停用认证源。 - - `--security-protocol value`:安全协议名称。必填。 - - `--skip-tls-verify`:禁用 TLS 验证。 - - `--host value`:LDAP 服务器的地址。必填。 - - `--port value`:连接到 LDAP 服务器时使用的端口。必填。 - - `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。 - - `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。必填。 - - `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。 - - `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。 - - `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。 - - `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。 - - `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。 - - `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。必填。 - - `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。 - - `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。 - - `--user-dn value`:用户的 DN。必填。 - - 示例: - - `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail` - - `update-ldap-simple`:更新现有的 LDAP(简单身份验证)认证源 - - 选项: - - `--id value`:认证源的 ID。必填。 - - `--name value`:认证名称。 - - `--not-active`:停用认证源。 - - `--security-protocol value`:安全协议名称。 - - `--skip-tls-verify`:禁用 TLS 验证。 - - `--host value`:LDAP 服务器的地址。 - - `--port value`:连接到 LDAP 服务器时使用的端口。 - - `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。 - - `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。 - - `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。 - - `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。 - - `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。 - - `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。 - - `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。 - - `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。 - - `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。 - - `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。 - - `--user-dn value`:用户的 DN。 - - 示例: - - `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"` - - `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn` - -### cert - -生成自签名的SSL证书。将输出到当前目录下的`cert.pem`和`key.pem`文件中,并且会覆盖任何现有文件。 - -- 选项: - - `--host value`:逗号分隔的主机名和IP地址列表,此证书适用于这些主机。支持使用通配符。必填。 - - `--ecdsa-curve value`:用于生成密钥的ECDSA曲线。可选。有效选项为P224、P256、P384、P521。 - - `--rsa-bits value`:要生成的RSA密钥的大小。可选。如果设置了--ecdsa-curve,则忽略此选项。(默认值:3072)。 - - `--start-date value`:证书的创建日期。可选。(格式:`Jan 1 15:04:05 2011`)。 - - `--duration value`:证书有效期。可选。(默认值:8760h0m0s) - - `--ca`:如果提供此选项,则证书将生成自己的证书颁发机构。可选。 -- 示例: - - `gitea cert --host git.example.com,example.com,www.example.com --ca` - -### dump - -将所有文件和数据库导出到一个zip文件中。输出文件将保存在当前目录下,类似于`gitea-dump-1482906742.zip`。 - -- 选项: - - `--file name`,`-f name`:指定要创建的导出文件的名称。可选。(默认值:gitea-dump-[timestamp].zip)。 - - `--tempdir path`,`-t path`:指定临时目录的路径。可选。(默认值:/tmp)。 - - `--skip-repository`,`-R`:跳过仓库的导出。可选。 - - `--skip-custom-dir`:跳过自定义目录的导出。可选。 - - `--skip-lfs-data`:跳过LFS数据的导出。可选。 - - `--skip-attachment-data`:跳过附件数据的导出。可选。 - - `--skip-package-data`:跳过包数据的导出。可选。 - - `--skip-log`:跳过日志数据的导出。可选。 - - `--database`,`-d`:指定数据库的SQL语法。可选。 - - `--verbose`,`-V`:如果提供此选项,显示附加详细信息。可选。 - - `--type`:设置导出的格式。可选。(默认值:zip) -- 示例: - - `gitea dump` - - `gitea dump --verbose` - -### generate - -用于在配置文件中生成随机值和令牌。对于自动部署时生成值非常有用。 - -- 命令: - - `secret`: - - 选项: - - `INTERNAL_TOKEN`: 用于内部 API 调用身份验证的令牌。 - - `JWT_SECRET`: 用于 LFS 和 OAUTH2 JWT 身份验证的密钥(LFS_JWT_SECRET 是此选项的别名,用于向后兼容)。 - - `SECRET_KEY`: 全局密钥。 - - 示例: - - `gitea generate secret INTERNAL_TOKEN` - - `gitea generate secret JWT_SECRET` - - `gitea generate secret SECRET_KEY` - -### keys - -提供一个 SSHD AuthorizedKeysCommand。需要在 sshd 配置文件中进行配置: - -```ini -... -# -e 的值和 AuthorizedKeysCommandUser 应与运行 Gitea 的用户名匹配 -AuthorizedKeysCommandUser git -AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k -``` - -该命令将返回适用于提供的密钥的合适 authorized_keys 行。您还应在 `app.ini` 的 `[server]` 部分设置值 `SSH_CREATE_AUTHORIZED_KEYS_FILE=false`。 - -注意: opensshd 要求 Gitea 程序由 root 拥有,并且不可由组或其他人写入。程序必须使用绝对路径指定。 -注意: Gitea 必须在运行此命令时处于运行状态才能成功。 - -### migrate - -迁移数据库。该命令可用于在首次启动服务器之前运行其他命令。此命令是幂等的。 - -### doctor check - -对 Gitea 实例进行诊断,可以修复一些可修复的问题。 -默认只运行部分检查,额外的检查可以参考: - -- `gitea doctor check --list` - 列出所有可用的检查 -- `gitea doctor check --all` - 运行所有可用的检查 -- `gitea doctor check --default` - 运行默认的检查 -- `gitea doctor check --run [check(s),]...` - 运行指定的名字的检查 - -有些问题可以通过设置 `--fix` 选项进行自动修复。 -额外的日志可以通过 `--log-file=...` 进行设置。 - -#### doctor recreate-table - -有时,在迁移时,旧的列和默认值可能会在数据库模式中保持不变。这可能会导致警告,如下所示: - -``` -2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0 -``` - -您可以通过以下方式让 Gitea 重新创建这些表,并将旧数据复制到新表中,并适当设置默认值: - -``` -gitea doctor recreate-table user -``` - -您可以使用以下方式让 Gitea 重新创建多个表: - -``` -gitea doctor recreate-table table1 table2 ... -``` - -如果您希望 Gitea 重新创建所有表,请直接调用: - -``` -gitea doctor recreate-table -``` - -强烈建议在运行这些命令之前备份您的数据库。 - -### doctor convert - -将现有的 MySQL 数据库从 utf8 转换为 utf8mb4,或者把 MSSQL 数据库从 varchar 转换为 nvarchar。 - -### manager - -管理运行中的服务器操作: - -- 命令: - - `shutdown`: 优雅地关闭运行中的进程 - - `restart`: 优雅地重新启动运行中的进程(对于Windows服务器尚未实现) - - `flush-queues`: 刷新运行中的进程中的队列 - - 选项: - - `--timeout value`: 刷新过程的超时时间(默认值: 1m0s) - - `--non-blocking`: 设置为true,以在返回之前不等待刷新完成 - - `logging`: 调整日志命令 - - 命令: - - `pause`: 暂停日志记录 - - 注意: - - 如果日志级别低于此级别,日志级别将被临时提升为INFO。 - - Gitea将在一定程度上缓冲日志,并在超过该点后丢弃日志。 - - `resume`: 恢复日志记录 - - `release-and-reopen`: 使Gitea释放和重新打开用于日志记录的文件和连接(相当于向Gitea发送SIGUSR1信号)。 - - `remove name`: 删除指定的日志记录器 - - 选项: - - `--group group`, `-g group`: 从中删除子记录器的组(默认为`default`) - - `add`: 添加日志记录器 - - 命令: - - `console`: 添加控制台日志记录器 - - 选项: - - `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default" - - `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式 - - `--level value`, `-l value`: 新日志记录器的日志级别 - - `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别 - - `--flags value`, `-F value`: 日志记录器的标志 - - `--expression value`, `-e value`: 日志记录器的匹配表达式 - - `--prefix value`, `-p value`: 日志记录器的前缀 - - `--color`: 在日志中使用颜色 - - `--stderr`: 将控制台日志输出到stderr - 仅适用于控制台 - - `file`: 添加文件日志记录器 - - 选项: - - `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default" - - `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式 - - `--level value`, `-l value`: 新日志记录器的日志级别 - - `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别 - - `--flags value`, `-F value`: 日志记录器的标志 - - `--expression value`, `-e value`: 日志记录器的匹配表达式 - - `--prefix value`, `-p value`: 日志记录器的前缀 - - `--color`: 在日志中使用颜色 - - `--filename value`, `-f value`: 日志记录器的文件名 - - `--rotate`, `-r`: 轮转日志 - - `--max-size value`, `-s value`: 在轮转之前的最大大小(以字节为单位) - - `--daily`, `-d`: 每天轮转日志 - - `--max-days value`, `-D value`: 保留的每日日志的最大数量 - - `--compress`, `-z`: 压缩轮转的日志 - - `--compression-level value`, `-Z value`: 使用的压缩级别 - - `conn`: 添加网络连接日志记录器 - - 选项: - - `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default" - - `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式 - - `--level value`, `-l value`: 新日志记录器的日志级别 - - `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别 - - `--flags value`, `-F value`: 日志记录器的标志 - - `--expression value`, `-e value`: 日志记录器的匹配表达式 - - `--prefix value`, `-p value`: 日志记录器的前缀 - - `--color`: 在日志中使用颜色 - - `--reconnect-on-message`, `-R`: 对于每个消息重新连接主机 - - `--reconnect`, `-r`: 连接中断时重新连接主机 - - `--protocol value`, `-P value`: 设置要使用的协议:tcp、unix或udp(默认为tcp) - - `--address value`, `-a value`: 要连接到的主机地址和端口(默认为:7020) - - `smtp`: 添加SMTP日志记录器 - - 选项: - - `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default" - - `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式 - - `--level value`, `-l value`: 新日志记录器的日志级别 - - `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别 - - `--flags value`, `-F value`: 日志记录器的标志 - - `--expression value`, `-e value`: 日志记录器的匹配表达式 - - `--prefix value`, `-p value`: 日志记录器的前缀 - - `--color`: 在日志中使用颜色 - - `--username value`, `-u value`: 邮件服务器用户名 - - `--password value`, `-P value`: 邮件服务器密码 - - `--host value`, `-H value`: 邮件服务器主机(默认为: 127.0.0.1:25) - - `--send-to value`, `-s value`: 要发送到的电子邮件地址 - - `--subject value`, `-S value`: 发送电子邮件的主题标题 - - `processes`: 显示 Gitea 进程和 Goroutine 信息 - - 选项: - - `--flat`: 以平面表格形式显示进程,而不是树形结构 - - `--no-system`: 不显示系统进程 - - `--stacktraces`: 显示与进程关联的 Goroutine 的堆栈跟踪 - - `--json`: 输出为 JSON 格式 - - `--cancel PID`: 向具有 PID 的进程发送取消命令(仅适用于非系统进程) - -### dump-repo - -`dump-repo` 从 Git/GitHub/Gitea/GitLab 中转储存储库数据: - -- 选项: - - `--git_service service`:Git 服务,可以是 `git`、`github`、`gitea`、`gitlab`。如果 `clone_addr` 可以被识别,则可以忽略此选项。 - - `--repo_dir dir`,`-r dir`:存储数据的存储库目录路径。 - - `--clone_addr addr`:将被克隆的 URL,目前可以是 git/github/gitea/gitlab 的 http/https URL。例如:https://github.com/lunny/tango.git - - `--auth_username lunny`:访问 `clone_addr` 的用户名。 - - `--auth_password <password>`:访问 `clone_addr` 的密码。 - - `--auth_token <token>`:访问 `clone_addr` 的个人令牌。 - - `--owner_name lunny`:如果非空,数据将存储在具有所有者名称的目录中。 - - `--repo_name tango`:如果非空,数据将存储在具有存储库名称的目录中。 - - `--units <units>`:要迁移的项目,一个或多个项目应以逗号分隔。允许的项目有 wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments。如果为空,则表示所有项目。 - -### restore-repo - -`restore-repo` 从磁盘目录中还原存储库数据: - -- 选项: - - `--repo_dir dir`,`-r dir`:还原数据的存储库目录路径。 - - `--owner_name lunny`:还原目标所有者名称。 - - `--repo_name tango`:还原目标存储库名称。 - - `--units <units>`:要还原的项目,一个或多个项目应以逗号分隔。允许的项目有 wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments。如果为空,则表示所有项目。 - -### actions generate-runner-token - -生成一个供 Runner 使用的新令牌,用于向服务器注册。 - -- 选项: - - `--scope {owner}[/{repo}]`,`-s {owner}[/{repo}]`:限制 Runner 的范围,没有范围表示该 Runner 可用于所有仓库,但你也可以将其限制为特定的仓库或所有者。 - -要注册全局 Runner: - -``` -gitea actions generate-runner-token -``` - -要注册特定组织的 Runner,例如 `org`: - -``` -gitea actions generate-runner-token -s org -``` - -要注册特定仓库的 Runner,例如 `username/test-repo`: - -``` -gitea actions generate-runner-token -s username/test-repo -``` diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md deleted file mode 100644 index 7d51c758b6..0000000000 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ /dev/null @@ -1,1361 +0,0 @@ ---- -date: "2016-12-26T16:00:00+02:00" -title: "配置说明" -slug: "config-cheat-sheet" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /zh-cn/config-cheat-sheet -menu: - sidebar: - parent: "administration" - name: "配置说明" - sidebar_position: 30 - identifier: "config-cheat-sheet" ---- - -# 配置说明 - -这是针对Gitea配置文件的说明, -你可以了解Gitea的强大配置。 - -需要说明的是,你的所有改变请修改 `custom/conf/app.ini` 文件而不是源文件。 -如果是从发行版本完成的安装, -配置文件的路径为`/etc/gitea/conf/app.ini`。 - -所有默认值可以通过 [app.example.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) 查看到。 -如果你发现 `%(X)s` 这样的内容,请查看 -[ini](https://github.com/go-ini/ini/#recursive-values) 这里的说明。 -标注了 :exclamation: 的配置项表明除非你真的理解这个配置项的意义,否则最好使用默认值。 - -在下面的默认值中,`$XYZ`代表环境变量`XYZ`的值(详见:`environment-to-ini`)。 _`XxYyZz`_是指默认配置的一部分列出的值。这些在 app.ini 文件中不起作用,仅在此处列出作为文档说明。 - -包含`#`或者`;`的变量必须使用引号(`` ` ``或者`""""`)包裹,否则会被解析为注释。 - -**注意:** 修改完配置文件后,需要重启 Gitea 服务才能生效。 - -## 默认配置 (非`app.ini`配置文件) - -这些值取决于环境,但构成了许多值的基础。当运行 `gitea help`或启动时,它们将 -作为默认配置的一部分进行报告。它们在那里发出的顺序略有不同,但我们将按照设置的顺序在这里列出。 - -- _`AppPath`_: Gitea二进制可执行文件的绝对路径 -- _`AppWorkPath`_: Gitea可执行文件的工作目录。 该配置可以通过以下几种方式设置,优先级依次递减: - - `app.ini`中的`WORK_PATH`配置项 - - 启动Gitea时的`--work-path`命令行参数 - - `$GITEA_WORK_DIR`环境变量 - - 在编译时设置的内置值(参见从源代码编译) - - 默认为 _`AppPath`_ 的目录 - - 如果上述任何路径为相对路径,将自动解析为相对于 _`AppPath`_ 目录的绝对路径 -- _`CustomPath`_: 这是用于自定义模板和其他选项的基础目录。 -它是通过使用以下层次结构中的第一个设置的内容来确定的: - - 通过传递给二进制文件的`--custom-path`标志 - - 环境变量 `$GITEA_CUSTOM` - - 在构建时设置的内置值(参见从源代码构建) - - 否则,默认为 _`AppWorkPath`_`/custom` - - 如果上述任何路径是相对路径,则会相对于 _`AppWorkPath`_ 目录进行处理, - 使其变为绝对路径。 -- _`CustomConf`_: 这是指向`app.ini`文件的路径。 - - 这是指向`app.ini`文件的路径。 - - 在构建时设置的内置值(参见从源代码构建) - - 否则,默认为 _`CustomPath`_`/conf/app.ini` - - 如果上述任何路径是相对路径,则会相对于_`CustomPath`_目录进行处理。 - -此外,还有_`StaticRootPath`_,可以在构建时设置为内置值,否则将默认为 _`AppWorkPath`_。 - -## Overall (`DEFAULT`) - -- `APP_NAME`: **Gitea: Git with a cup of tea** 应用名称,在网页的标题中显示。 -- `RUN_USER`: **_current OS username_/`$USER`/`$USERNAME` e.g. git**: 运行Gitea的用户, - 应当是一个专用的系统账户(非用户使用,推荐创建一个专用的`git`用户). 如果在你自己的个人电脑使用改成你自己的用户名。 - 该配置如果设置不正确,Gitea可能崩溃。 -- `RUN_MODE`: **prod**: 应用的运行模式,对运行性能和问题排除有影响: `dev` 或者 `prod`,默认为 `prod`。 `dev`模式有助于开发和问题排查, 除设置为`dev` 外,均被视为 `prod`. -- `WORK_PATH`: **_the-work-path_**: 工作目录, 前文有提及. - -## 仓库 (`repository`) - -- `ROOT`: **%(APP_DATA_PATH)s/gitea-repositories**: 存放git工程的根目录,建议填绝对路径。 - 相对路径将被解析为**_`AppWorkPath`_/%(ROOT)s**. -- `SCRIPT_TYPE`: **bash**: 服务器支持的Shell类型,通常是`bash`, - 但有些服务器也有可能是`sh`。 -- `DETECTED_CHARSETS_ORDER`: **UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, ISO-8859, windows-1252, ISO-8859, windows-1250, ISO-8859, ISO-8859, ISO-8859, windows-1253, ISO-8859, windows-1255, ISO-8859, windows-1251, windows-1256, KOI8-R, ISO-8859, windows-1254, Shift_JIS, GB18030, EUC-JP, EUC-KR, Big5, ISO-2022, ISO-2022, ISO-2022, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr**: 检测到的字符集的决定性顺序 - 如果检测到的字符集具有相等的置信度,则优先选择列表中较早出现的字符集,而不是较晚出现的字符集。添加“defaults”将会将未命名的字符集放置在该点。 -- `ANSI_CHARSET`: **_empty_**: 默认的ANSI字符集,用于覆盖非UTF-8字符集。 -- `FORCE_PRIVATE`: **false**: 强制使每个新仓库变为私有。 -- `DEFAULT_PRIVATE`: **last**: 创建新仓库时默认为私有。 - \[last, private, public\] -- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: 使用推送创建新仓库时默认为私有。 -- `MAX_CREATION_LIMIT`: **-1**: 每个用户的全局仓库创建上限, - `-1` 代表无限制. -- `PREFERRED_LICENSES`: **Apache License 2.0,MIT License**: 要放置在列表顶部的指定许可证。 - 名称必须与 options/license 或 custom/options/license 中的文件名匹配。 -- `DISABLE_HTTP_GIT`: **false**: 禁用HTTP协议与仓库进行 - 交互的能力。 -- `USE_COMPAT_SSH_URI`: **false**: 当使用默认的SSH端口时,强制使用ssh://克隆URL, - 而不是scp-style uri。 -- `GO_GET_CLONE_URL_PROTOCOL`: **https**: 用于 "go get" 请求的值,返回仓库的URL作为https或ssh, - 默认为https。 -- `ACCESS_CONTROL_ALLOW_ORIGIN`: **_empty_**:用于 Access-Control-Allow-Origin 标头的值, -默认不提供。 -警告:如果您不提供正确的值,这可能对您的网站造成危害。 -- `DEFAULT_CLOSE_ISSUES_VIA_COMMITS_IN_ANY_BRANCH`: **false**: 如果非默认分支上的提交将问题标记为已关闭,则关闭该问题。 -- `ENABLE_PUSH_CREATE_USER`: **false**: 允许用户将本地存储库推送到Gitea,并为用户自动创建它们。 -- `ENABLE_PUSH_CREATE_ORG`: **false**: 允许用户将本地存储库推送到Gitea,并为组织自动创建它们。 -- `DISABLED_REPO_UNITS`: **_empty_**: 逗号分隔的全局禁用的仓库单元列表。允许的值是:: \[repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects, repo.packages, repo.actions\] -- `DEFAULT_REPO_UNITS`: **repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,repo.actions**: 逗号分隔的默认新仓库单元列表。允许的值是:: \[repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects, repo.packages, repo.actions\]. 注意:目前无法停用代码和发布。如果您指定了默认的仓库单元,您仍应将它们列出以保持未来的兼容性。外部wiki和问题跟踪器不能默认启用,因为它需要额外的设置。禁用的仓库单元将不会添加到新的仓库中,无论它是否在默认列表中。 -- `DEFAULT_FORK_REPO_UNITS`: **repo.code,repo.pulls**: 逗号分隔的默认分叉仓库单元列表。允许的值和规则与`DEFAULT_REPO_UNITS`相同。 -- `PREFIX_ARCHIVE_FILES`: **true**: 通过将存档文件放置在以仓库命名的目录中来添加前缀。 -- `DISABLE_MIGRATIONS`: **false**: 禁用迁移功能。 -- `DISABLE_STARS`: **false**: 禁用点赞功能。 -- `DEFAULT_BRANCH`: **main**: 所有仓库的默认分支名称。 -- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: 允许非管理员用户认领未被认领的仓库。 -- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: 允许非管理员用户删除未被认领的仓库。 -- `DISABLE_DOWNLOAD_SOURCE_ARCHIVES`: **false**: 不允许从用户界面下载源代码存档文件。 -- `ALLOW_FORK_WITHOUT_MAXIMUM_LIMIT`: **true**: 允许无限制得派生仓库。 - -### 仓库 - 编辑器 (`repository.editor`) - -- `LINE_WRAP_EXTENSIONS`: **.txt,.md,.markdown,.mdown,.mkd,.livemd,**: 在 Monaco 编辑器中应该换行的文件扩展名列表。用逗号分隔扩展名。要对没有扩展名的文件进行换行,只需放置一个逗号。 -- `PREVIEWABLE_FILE_MODES`: **markdown**: 具有预览API的有效文件模式,例如 `api/v1/markdown`。用逗号分隔各个值。如果文件扩展名不匹配,编辑模式下的预览选项卡将不会显示。 - -### 仓库 - 合并请求 (`repository.pull-request`) - -- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: 在拉取请求标题中用于标记工作正在进行中的前缀列表。 -这些前缀在不区分大小写的情况下进行匹配。 -- `CLOSE_KEYWORDS`: **close**, **closes**, **closed**, **fix**, **fixes**, **fixed**, **resolve**, **resolves**, **resolved**: 在拉取请求评论中用于自动关闭相关问题的关键词列表。 -- `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: 在拉取请求评论中用于自动重新打开相关问题的 -关键词列表。 -- `DEFAULT_MERGE_STYLE`: **merge**: 设置创建仓库的默认合并方式,可选: `merge`, `rebase`, `rebase-merge`, `squash`, `fast-forward-only` -- `DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT`: **50**: 在默认合并消息中,对于`squash`提交,最多包括此数量的提交。设置为 -1 以包括所有提交。 -- `DEFAULT_MERGE_MESSAGE_SIZE`: **5120**: 在默认的合并消息中,对于`squash`提交,限制提交消息的大小。设置为 `-1`以取消限制。仅在`POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`为`true`时使用。 -- `DEFAULT_MERGE_MESSAGE_ALL_AUTHORS`: **false**: 在默认合并消息中,对于`squash`提交,遍历所有提交以包括所有作者的`Co-authored-by`,否则仅使用限定列表中的作者。 -- `DEFAULT_MERGE_MESSAGE_MAX_APPROVERS`: **10**:在默认合并消息中,限制列出的审批者数量为`Reviewed-by`:。设置为 `-1` 以包括所有审批者。 -- `DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY`: **true**: 在默认合并消息中,仅包括官方允许审查的审批者。 -- `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: 在默认的 squash 合并消息中,包括构成拉取请求的所有提交的提交消息。 -- `ADD_CO_COMMITTER_TRAILERS`: **true**: 如果提交者与作者不匹配,在合并提交消息中添加`co-authored-by`和`co-committed-by`标记。 -- `TEST_CONFLICTING_PATCHES_WITH_GIT_APPLY`:使用三方合并方法测试`PR Patch`以发现是否存在冲突。如果此设置`true`,将使用`git apply`重新测试冲突的`PR Pathch` - 这是1.18(和之前版本)中的先前行为,但效率相对较低。如果发现需要此设置,请报告。 - -### 仓库 - 工单 (`repository.issue`) - -- `LOCK_REASONS`: **Too heated,Off-topic,Resolved,Spam**: 合并请求或工单被锁定的原因列表。 -- `MAX_PINNED`: **3**: 每个仓库的最大可固定工单数量。设置为0禁用固定工单。 - -### 仓库 - 文件上传 (`repository.upload`) - -- `ENABLED`: **true**: 是否启用仓库文件上传。 -- `TEMP_PATH`: **data/tmp/uploads**: 文件上传的临时保存路径(在Gitea重启的时候该目录会被清空)。 -- `ALLOWED_TYPES`: **_empty_**: 以逗号分割的列表,代表支持上传的文件类型。(`.zip`), mime类型 (`text/plain`) or 通配符类型 (`image/*`, `audio/*`, `video/*`). 为空或者 `*/*`代表允许所有类型文件。 -- `FILE_MAX_SIZE`: **50**: 每个文件的最大大小(MB)。 -- `MAX_FILES`: **5**: 每次上传的最大文件数。 - -### 仓库 - 版本发布 (`repository.release`) - -- `ALLOWED_TYPES`: **_empty_**: 允许发布的文件类型列表,用逗号分隔 。如压缩包类型(`.zip`), mime 类型 (`text/plain`) ,也支持通配符 (`image/*`, `audio/*`, `video/*`)。 空值或者 `*/*` 代表允许所有类型。 -- `DEFAULT_PAGING_NUM`: **10**: 默认的发布版本页面分页大小 -- 关于版本发布相关的附件设置,详见`附件`部分。 - -### 仓库 - Signing (`repository.signing`) - -- `SIGNING_KEY`: **default**: \[none, KEYID, default \]: 用于签名的密钥 -- `SIGNING_NAME` & `SIGNING_EMAIL`: 如果`SIGNING_KEY`提供了一个 KEYID,将使用这些作为签名者的姓名和电子邮件地址。这些应与密钥的公开姓名和电子邮件地址相匹配。 -- `INITIAL_COMMIT`: **always**: \[never, pubkey, twofa, always\]: 签名初始提交。 - - `never`: 永不签名 - - `pubkey`: 仅在用户具有公钥时签名 - - `twofa`: 仅在用户使用双因素身份验证登录时签名 - - `always`: 始终签名 - - 除了 never 和 always 之外的选项可以组合为逗号分隔的列表。 -- `DEFAULT_TRUST_MODEL`: **collaborator**: \[collaborator, committer, collaboratorcommitter\]: 用于验证提交的默认信任模型。 - - `collaborator`: 信任协作者密钥签名的签名。 - - `committer`: 信任与提交者匹配的签名(这与GitHub匹配,并会强制Gitea签名的提交具有Gitea作为提交者)。 - - `collaboratorcommitter`: 信任与提交者匹配的协作者密钥签名的签名。 -- `WIKI`: **never**: \[never, pubkey, twofa, always, parentsigned\]: 对wiki提交进行签名。 -- `CRUD_ACTIONS`: **pubkey, twofa, parentsigned**: \[never, pubkey, twofa, parentsigned, always\]: 对CRUD操作进行签名。 - - 与上面相同的选项,增加了: - - `parentsigned`: 仅在父提交进行了签名时才进行签名。 -- `MERGES`: **pubkey, twofa, basesigned, commitssigned**: \[never, pubkey, twofa, approved, basesigned, commitssigned, always\]: 对合并操作进行签名。 - - `approved`: 仅对已批准的合并操作进行签名,适用于受保护的分支。 - - `basesigned`: 仅在基础仓库的父提交进行了签名时才进行签名。 - - `headsigned`: 仅在头分支的头提交进行了签名时才进行签名。 - - `commitssigned`: 仅在头分支中的所有提交到合并点都进行了签名时才进行签名。 - -### 仓库 - Local (`repository.local`) - -- `LOCAL_COPY_PATH`: **tmp/local-repo**:临时本地仓库副本的路径。默认为 tmp/local-repo(内容在 Gitea 重新启动时被删除) - -### 仓库 - MIME type mapping (`repository.mimetype_mapping`) - -配置用于根据可下载文件的文件扩展名设置预期的 MIME 类型。配置以键值对的形式呈现,文件扩展名以`.`开头。 - -以下配置在下载具有`.apk`文件扩展名的文件时设置`Content-Type: application/vnd.android.package-archive`头部。 - -```ini -.apk=application/vnd.android.package-archive -``` - -## 跨域 (`cors`) - -- `ENABLED`: **false**: 启用 CORS 头部(默认禁用) -- `ALLOW_DOMAIN`: **\***: 允许请求的域名列表 -- `METHODS`: **GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS**: 允许发起的请求方式列表 -- `MAX_AGE`: **10m**: 缓存响应的最大时间 -- `ALLOW_CREDENTIALS`: **false**: 允许带有凭据的请求 -- `HEADERS`: **Content-Type,User-Agent**: 允许请求携带的头部 -- `X_FRAME_OPTIONS`: **SAMEORIGIN**: 详见 `X-Frame-Options`HTTP头部. - -## 界面 (`ui`) - -- `EXPLORE_PAGING_NUM`: **20**: 探索页面每页显示的仓库数量。 -- `ISSUE_PAGING_NUM`: **20**: 工单页面每页显示的工单数量。 -- `MEMBERS_PAGING_NUM`: **20**: 组织成员页面每页显示的成员数量。 -- `FEED_MAX_COMMIT_NUM`: **5**: 活动流页面显示的最大提交数量。 -- `FEED_PAGING_NUM`: **20**: 活动流页面显示的最大活动数量。 -- `SITEMAP_PAGING_NUM`: **20**: 在单个子SiteMap中显示的项数。 -- `GRAPH_MAX_COMMIT_NUM`: **100**: 提交图中显示的最大commit数量。 -- `CODE_COMMENT_LINES`: **4**: 在代码评论中能够显示的最大代码行数。 -- `DEFAULT_THEME`: **gitea-auto**: 在Gitea安装时候设置的默认主题,自定义的主题可以通过 `{CustomPath}/public/assets/css/theme-*.css` 提供。 -- `SHOW_USER_EMAIL`: **true**: 用户的电子邮件是否应该显示在`Explore Users`页面中。 -- `THEMES`: **_empty_**: 所有可用的主题(由 `{CustomPath}/public/assets/css/theme-*.css` 提供)。允许用户选择个性化的主题, -- `MAX_DISPLAY_FILE_SIZE`: **8388608**: 能够显示文件的最大大小(默认为8MiB)。 -- `REACTIONS`: 用户可以在问题(Issue)、Pull Request(PR)以及评论中选择的所有可选的反应。 - 这些值可以是表情符号别名(例如::smile:)或Unicode表情符号。 - 对于自定义的反应,在 public/assets/img/emoji/ 目录下添加一个紧密裁剪的正方形图像,文件名为 reaction_name.png。 -- `CUSTOM_EMOJIS`: **gitea, codeberg, gitlab, git, github, gogs**: 不在utf8标准中定义的额外表情符号。 - 默认情况下,我们支持 Gitea 表情符号(:gitea:)。要添加更多表情符号,请将它们复制到 public/assets/img/emoji/ 目录下, - 并将其添加到此配置中。 -- `DEFAULT_SHOW_FULL_NAME`: **false**: 是否在可能的情况下显示用户的全名。如果没有设置全名,则将使用用户名。 -- `SEARCH_REPO_DESCRIPTION`: **true**: 是否在探索页面上的仓库搜索中搜索描述。 -- `ONLY_SHOW_RELEVANT_REPOS`: **false** 在没有指定关键字并使用默认排序时,是否仅在探索页面上显示相关的仓库。 - 如果一个仓库是分叉或者没有元数据(没有描述、图标、主题),则被视为不相关的仓库。 - -### 界面 - 管理员 (`ui.admin`) - -- `USER_PAGING_NUM`: **50**: 单页显示的用户数量。 -- `REPO_PAGING_NUM`: **50**: 单页显示的仓库数量。 -- `NOTICE_PAGING_NUM`: **25**: 单页显示的通知数量。 -- `ORG_PAGING_NUM`: **50**: 单页显示的组织数量。 - -### 界面 - 用户 (`ui.user`) - -- `REPO_PAGING_NUM`: **15**: 单页显示的仓库数量。 - -### 界面 - 元信息 (`ui.meta`) - -- `AUTHOR`: **Gitea - Git with a cup of tea**: 主页的作者元标签。 -- `DESCRIPTION`: **Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go**: 主页的描述元标签。 -- `KEYWORDS`: **go,git,self-hosted,gitea**: 首页关键词元标签。 - -### 界面 - 通知 (`ui.notification`) - -- `MIN_TIMEOUT`: **10s**: 这些选项控制通知端点定期轮询以更新通知计数。在页面加载后,通知计数将在` MIN_TIMEOUT`之后进行检查。如果通知计数未更改,超时时间将按照`TIMEOUT_STEP`增加到`MAX_TIMEOUT`。将 `MIN_TIMEOUT`设置为 -1 以关闭该功能。 -- `MAX_TIMEOUT`: **60s**. -- `TIMEOUT_STEP`: **10s**. -- `EVENT_SOURCE_UPDATE_TIME`: **10s**: 该设置确定了查询数据库以更新通知计数的频率。如果浏览器客户端支持`EventSource`和`SharedWorker`,则优先使用`SharedWorker`而不是轮询通知端点。将其设置为 -1 可以禁用 `EventSource`。 - -### 界面 - SVG Images (`ui.svg`) - -- `ENABLE_RENDER`: **true**: 是否将SVG文件呈现为图像。如果禁用了SVG渲染,SVG文件将显示为文本,无法作为图像嵌入到Markdown文件中。 - -### 界面 - CSV Files (`ui.csv`) - -- `MAX_FILE_SIZE`: **524288** (512kb): 以字节为单位允许将CSV文件呈现为表格的最大文件大小(将其设置为0表示没有限制)。 - -## Markdown (`markdown`) - -- `ENABLE_HARD_LINE_BREAK_IN_COMMENTS`: **true**: 在评论中将软换行符呈现为硬换行符, - 这意味着段落之间的单个换行符将导致换行, - 并且不需要在段落后添加尾随空格来强制换行。 -- `ENABLE_HARD_LINE_BREAK_IN_DOCUMENTS`: **false**: 在文档中将软换行符呈现为硬换行符, - 这意味着段落之间的单个换行符将导致换行, - 并且不需要在段落后添加尾随空格来强制换行。 -- `CUSTOM_URL_SCHEMES`: 使用逗号分隔的列表(ftp、git、svn)来指示要在Markdown中呈现的附加URL超链接。 - 以http和https开头的URL始终显示。 - 如果此条目为空,则允许所有URL方案。 -- `FILE_EXTENSIONS`: **.md,.markdown,.mdown,.mkd,.livemd**: 应呈现/编辑为Markdown的文件扩展名列表。使用逗号分隔扩展名。要将没有任何扩展名的文件呈现为Markdown,请只需放置一个逗号。 -- `ENABLE_MATH`: **true**: 启用对`\(...\)`, `\[...\]`, `$...$`和`$$...$$` 作为数学块的检测。 - -## 服务器 (`server`) - -- `APP_DATA_PATH`: **_`AppWorkPath`_/data**: 这是存储数据的默认根路径。 -- `PROTOCOL`: **http**: \[http, https, fcgi, http+unix, fcgi+unix\] -- `USE_PROXY_PROTOCOL`: **false**: 在连接中预期`PROXY`协议头。 -- `PROXY_PROTOCOL_TLS_BRIDGING`: **false**: 协议为 https 时,在`TLS`协商后预期`PROXY`协议头。 -- `PROXY_PROTOCOL_HEADER_TIMEOUT`: **5s**: 等待`PROXY`协议头的超时时间(设置为`0`表示没有超时)。 -- `PROXY_PROTOCOL_ACCEPT_UNKNOWN`: **false**:接受带有未知类型的`PROXY`协议头。 -- `DOMAIN`: **localhost**: 此服务器的域名。 -- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**: - 覆盖自动生成的公共URL。 - 如果内部URL和外部URL不匹配(例如在Docker中),这很有用。 -- `STATIC_URL_PREFIX`: **_empty_**: - 覆盖此选项以从不同的URL请求静态资源。 - 这包括CSS文件、图片、JS文件和Web字体。 - 头像图片是动态资源,仍由Gitea提供。 - 选项可以是不同的路径,例如`/static`, 也可以是另一个域,例如`https://cdn.example.com`. - 请求会变成 `%(ROOT_URL)s/static/assets/css/index.css` 或 `https://cdn.example.com/assets/css/index.css` - 静态文件位于Gitea源代码仓库的`public/`目录中。 - 您可以将`STATIC_URL_PREFIX`请求代理到 Gitea 服务器以提供静态资源,或者将手动构建的 Gitea 资源从 `$GITEA_BUILD/public`复制到静态位置,例如`/var/www/assets`。确保`$STATIC_URL_PREFIX/assets/css/index.css`指向`/var/www/assets/css/index.css`。 - -- `HTTP_ADDR`: **0.0.0.0**:HTTP 监听地址。 - - 如果 `PROTOCOL` 设置为 `fcgi`,Gitea 将在由 - `HTTP_ADDR` 和 `HTTP_PORT` 配置设置定义的 TCP 套接字上监听 FastCGI 请求。 - - 如果 `PROTOCOL` 设置为 `http+unix` 或 `fcgi+unix`,则应该是要使用的 Unix 套接字文件的名称。相对路径将相对于 _`AppWorkPath`_ 被转换为绝对路径。 -- `HTTP_PORT`: **3000**:HTTP 监听端口。 - - 如果 `PROTOCOL` 设置为 `fcgi`,Gitea 将在由 `HTTP_ADDR` 和 `HTTP_PORT` - 配置设置定义的 TCP 套接字上监听 FastCGI 请求。 -- `UNIX_SOCKET_PERMISSION`: **666**:Unix 套接字的权限。 -- `LOCAL_ROOT_URL`: **%(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/**: - 用于访问网络服务的 Gitea 工作器(例如 SSH 更新)的本地(DMZ)URL。 - 在大多数情况下,您不需要更改默认值。 - 仅在您的 SSH 服务器节点与 HTTP 节点不同的情况下才修改它。对于不同的协议,默认值不同。如果 `PROTOCOL` - 是 `http+unix`,则默认值为 `http://unix/`。如果 `PROTOCOL` 是 `fcgi` 或 `fcgi+unix`,则默认值为 - `%(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/`。如果监听在 `0.0.0.0`,则默认值为 - `%(PROTOCOL)s://localhost:%(HTTP_PORT)s/`, - 否则默认值为 `%(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/`。 -- `LOCAL_USE_PROXY_PROTOCOL`: **%(USE_PROXY_PROTOCOL)s**:在进行本地连接时传递 PROXY 协议头。 - 如果本地连接将经过代理,请将其设置为 false。 -- `PER_WRITE_TIMEOUT`: **30s**:连接的任何写操作的超时时间。(将其设置为 -1 - 以禁用所有超时。) -- `PER_WRITE_PER_KB_TIMEOUT`: **10s**:连接每写入 1 KB 的超时时间。 -- `DISABLE_SSH`: **false**:当SSH不可用时禁用SSH功能。 -- `START_SSH_SERVER`: **false**:启用时,使用内置的SSH服务器。 -- `SSH_SERVER_USE_PROXY_PROTOCOL`: **false**:在与内置SSH服务器建立连接时,期望PROXY协议头。 -- `BUILTIN_SSH_SERVER_USER`: **%(RUN_USER)s**:用于内置SSH服务器的用户名。 -- `SSH_USER`: **%(BUILTIN_SSH_SERVER_USER)s**:在克隆URL中显示的SSH用户名。这仅适用于自行配置SSH服务器的人;在大多数情况下,您希望将其留空并修改`BUILTIN_SSH_SERVER_USER`。 -- `SSH_DOMAIN`: **%(DOMAIN)s**:此服务器的域名,用于显示的克隆 URL。 -- `SSH_PORT`: **22**:显示在克隆 URL 中的 SSH 端口。 -- `SSH_LISTEN_HOST`: **0.0.0.0**:内置 SSH 服务器的监听地址。 -- `SSH_LISTEN_PORT`: **%(SSH_PORT)s**:内置 SSH 服务器的端口。 -- `SSH_ROOT_PATH`: **~/.ssh**:SSH 目录的根路径。 -- `SSH_CREATE_AUTHORIZED_KEYS_FILE`: **true**:当 Gitea 不使用内置 SSH 服务器时,默认情况下 Gitea 会创建一个 authorized_keys 文件。如果您打算使用 AuthorizedKeysCommand 功能,您应该关闭此选项。 -- `SSH_AUTHORIZED_KEYS_BACKUP`: **false**:在重写所有密钥时启用 SSH 授权密钥备份,默认值为 false。 -- `SSH_TRUSTED_USER_CA_KEYS`: **_empty_**:指定信任的证书颁发机构的公钥,用于对用户证书进行身份验证。多个密钥应以逗号分隔。例如 `ssh-<algorithm> <key>` 或 `ssh-<algorithm> <key1>, ssh-<algorithm> <key2>`。有关详细信息,请参阅 `sshd` 配置手册中的 `TrustedUserCAKeys` 部分。当为空时,不会创建文件,并且 `SSH_AUTHORIZED_PRINCIPALS_ALLOW` 默认为 `off`。 -- `SSH_TRUSTED_USER_CA_KEYS_FILENAME`: **`RUN_USER`/.ssh/gitea-trusted-user-ca-keys.pem**:Gitea 将管理的 `TrustedUserCaKeys` 文件的绝对路径。如果您正在运行自己的 SSH 服务器,并且想要使用 Gitea 管理的文件,您还需要修改您的 `sshd_config` 来指向此文件。官方的 Docker 映像将自动工作,无需进一步配置。 -- `SSH_AUTHORIZED_PRINCIPALS_ALLOW`: **off** 或 **username, email**:\[off, username, email, anything\]:指定允许用户用作 principal 的值。当设置为 `anything` 时,对 principal 字符串不执行任何检查。当设置为 `off` 时,不允许设置授权的 principal。 -- `SSH_CREATE_AUTHORIZED_PRINCIPALS_FILE`: **false/true**:当 Gitea 不使用内置 SSH 服务器且 `SSH_AUTHORIZED_PRINCIPALS_ALLOW` 不为 `off` 时,默认情况下 Gitea 会创建一个 authorized_principals 文件。 -- `SSH_AUTHORIZED_PRINCIPALS_BACKUP`: **false/true**:在重写所有密钥时启用 SSH 授权 principal 备份,默认值为 true(如果 `SSH_AUTHORIZED_PRINCIPALS_ALLOW` 不为 `off`)。 -- `SSH_AUTHORIZED_KEYS_COMMAND_TEMPLATE`: **`{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}`**:设置用于传递授权密钥的命令模板。可能的密钥是:AppPath、AppWorkPath、CustomConf、CustomPath、Key,其中 Key 是 `models/asymkey.PublicKey`,其他是 shellquoted 字符串。 -- `SSH_SERVER_CIPHERS`: **chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com**:对于内置的 SSH 服务器,选择支持的 SSH 连接的加密方法,对于系统 SSH,此设置无效。 -- `SSH_SERVER_KEY_EXCHANGES`: **curve25519-sha256, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group14-sha256, diffie-hellman-group14-sha1**:对于内置 SSH 服务器,选择支持的 SSH 连接的密钥交换算法,对于系统 SSH,此设置无效。 -- `SSH_SERVER_MACS`: **hmac-sha2-256-etm@openssh.com, hmac-sha2-256, hmac-sha1**:对于内置 SSH 服务器,选择支持的 SSH 连接的 MAC 算法,对于系统 SSH,此设置无效。 -- `SSH_SERVER_HOST_KEYS`: **ssh/gitea.rsa, ssh/gogs.rsa**:对于内置 SSH 服务器,选择要提供为主机密钥的密钥对。私钥应在 `SSH_SERVER_HOST_KEY` 中,公钥在 `SSH_SERVER_HOST_KEY.pub` 中。相对路径会相对于 `APP_DATA_PATH` 转为绝对路径。如果不存在密钥,将为您创建一个 4096 位的 RSA 密钥。 -- `SSH_KEY_TEST_PATH`: **/tmp**:在使用 `ssh-keygen` 测试公共 SSH 密钥时要在其中创建临时文件的目录,默认为系统临时目录。 -- `SSH_KEYGEN_PATH`: **_empty_**:使用 `ssh-keygen` 解析公共 SSH 密钥。该值将传递给 shell。默认情况下,Gitea 会自行进行解析。 -- `SSH_EXPOSE_ANONYMOUS`: **false**:启用将 SSH 克隆 URL 暴露给匿名访问者,默认为 false。 -- `SSH_PER_WRITE_TIMEOUT`: **30s**:对 SSH 连接的任何写入设置超时。(将其设置为 -1 可以禁用所有超时。) -- `SSH_PER_WRITE_PER_KB_TIMEOUT`: **10s**:对写入 SSH 连接的每 KB 设置超时。 -- `MINIMUM_KEY_SIZE_CHECK`: **true**:指示是否检查最小密钥大小与相应类型。 -- `OFFLINE_MODE`: **true**:禁用 CDN 用于静态文件和 Gravatar 用于个人资料图片。 -- `CERT_FILE`: **https/cert.pem**:用于 HTTPS 的证书文件路径。在链接时,服务器证书必须首先出现,然后是中间 CA 证书(如果有)。如果 `ENABLE_ACME=true`,则此设置会被忽略。路径相对于 `CUSTOM_PATH`。 -- `KEY_FILE`: **https/key.pem**:用于 HTTPS 的密钥文件路径。如果 `ENABLE_ACME=true`,则此设置会被忽略。路径相对于 `CUSTOM_PATH`。 -- `STATIC_ROOT_PATH`: **_`StaticRootPath`_**:模板和静态文件路径的上一级。 -- `APP_DATA_PATH`: **data**(在 Docker 上为 **/data/gitea**):应用程序数据的默认路径。相对路径会相对于 _`AppWorkPath`_ 转为绝对路径。 -- `STATIC_CACHE_TIME`: **6h**:对 `custom/`、`public/` 和所有上传的头像的静态资源的 Web 浏览器缓存时间。请注意,在 `RUN_MODE` 为 "dev" 时,此缓存会被禁用。 -- `ENABLE_GZIP`: **false**:为运行时生成的内容启用 gzip 压缩,静态资源除外。 -- `ENABLE_PPROF`: **false**:应用程序分析(内存和 CPU)。对于 "web" 命令,它会在 `localhost:6060` 上监听。对于 "serv" 命令,它会将数据转储到磁盘上的 `PPROF_DATA_PATH` 中,文件名为 `(cpuprofile|memprofile)_<username>_<temporary id>`。 -- `PPROF_DATA_PATH`: **_`AppWorkPath`_/data/tmp/pprof**:`PPROF_DATA_PATH`,当您将 Gitea 作为服务启动时,请使用绝对路径。 -- `LANDING_PAGE`: **home**:未经身份验证用户的登录页面 \[home, explore, organizations, login, **custom**]。其中 custom 可以是任何 URL,例如 "/org/repo" 或甚至是 `https://anotherwebsite.com`。 -- `LFS_START_SERVER`: **false**:启用 Git LFS 支持。 -- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)s/lfs**:默认的 LFS 内容路径(如果它在本地存储中)。**已弃用**,请使用 `[lfs]` 中的设置。 -- `LFS_JWT_SECRET`: **_empty_**:LFS 身份验证密钥,将其更改为唯一的字符串。 -- `LFS_JWT_SECRET_URI`: **_empty_**:代替在配置中定义 LFS_JWT_SECRET,可以使用此配置选项为 Gitea 提供包含密钥的文件的路径(示例值:`file:/etc/gitea/lfs_jwt_secret`)。 -- `LFS_HTTP_AUTH_EXPIRY`: **24h**:LFS 身份验证的有效期,以 time.Duration 表示,超过此期限的推送可能会失败。 -- `LFS_MAX_FILE_SIZE`: **0**:允许的最大 LFS 文件大小(以字节为单位,设置为 0 为无限制)。 -- `LFS_LOCKS_PAGING_NUM`: **50**:每页返回的最大 LFS 锁定数。 -- `REDIRECT_OTHER_PORT`: **false**:如果为 true 并且 `PROTOCOL` 为 https,则允许将 http 请求重定向到 Gitea 监听的 https 端口的 `PORT_TO_REDIRECT`。 -- `REDIRECTOR_USE_PROXY_PROTOCOL`: **%(USE_PROXY_PROTOCOL)s**:在连接到 https 重定向器时,需要 PROXY 协议头。 -- `PORT_TO_REDIRECT`: **80**:http 重定向服务监听的端口。当 `REDIRECT_OTHER_PORT` 为 true 时使用。 -- `SSL_MIN_VERSION`: **TLSv1.2**:设置最低支持的 SSL 版本。 -- `SSL_MAX_VERSION`: **_empty_**:设置最大支持的 SSL 版本。 -- `SSL_CURVE_PREFERENCES`: **X25519,P256**:设置首选的曲线。 -- `SSL_CIPHER_SUITES`: **ecdhe_ecdsa_with_aes_256_gcm_sha384,ecdhe_rsa_with_aes_256_gcm_sha384,ecdhe_ecdsa_with_aes_128_gcm_sha256,ecdhe_rsa_with_aes_128_gcm_sha256,ecdhe_ecdsa_with_chacha20_poly1305,ecdhe_rsa_with_chacha20_poly1305**:设置首选的密码套件。 - - 如果没有对 AES 套件的硬件支持,默认情况下,ChaCha 套件将优先于 AES 套件。 - - 根据 Go 1.18 的支持的套件有: - - TLS 1.0 - 1.2 套件 - - "rsa_with_rc4_128_sha" - - "rsa_with_3des_ede_cbc_sha" - - "rsa_with_aes_128_cbc_sha" - - "rsa_with_aes_256_cbc_sha" - - "rsa_with_aes_128_cbc_sha256" - - "rsa_with_aes_128_gcm_sha256" - - "rsa_with_aes_256_gcm_sha384" - - "ecdhe_ecdsa_with_rc4_128_sha" - - "ecdhe_ecdsa_with_aes_128_cbc_sha" - - "ecdhe_ecdsa_with_aes_256_cbc_sha" - - "ecdhe_rsa_with_rc4_128_sha" - - "ecdhe_rsa_with_3des_ede_cbc_sha" - - "ecdhe_rsa_with_aes_128_cbc_sha" - - "ecdhe_rsa_with_aes_256_cbc_sha" - - "ecdhe_ecdsa_with_aes_128_cbc_sha256" - - "ecdhe_rsa_with_aes_128_cbc_sha256" - - "ecdhe_rsa_with_aes_128_gcm_sha256" - - "ecdhe_ecdsa_with_aes_128_gcm_sha256" - - "ecdhe_rsa_with_aes_256_gcm_sha384" - - "ecdhe_ecdsa_with_aes_256_gcm_sha384" - - "ecdhe_rsa_with_chacha20_poly1305_sha256" - - "ecdhe_ecdsa_with_chacha20_poly1305_sha256" - - TLS 1.3 套件 - - "aes_128_gcm_sha256" - - "aes_256_gcm_sha384" - - "chacha20_poly1305_sha256" - - 别名 - - "ecdhe_rsa_with_chacha20_poly1305" 是 "ecdhe_rsa_with_chacha20_poly1305_sha256" 的别名 - - "ecdhe_ecdsa_with_chacha20_poly1305" 是 "ecdhe_ecdsa_with_chacha20_poly1305_sha256" 的别名 -- `ENABLE_ACME`: **false**:通过 ACME 能力的证书颁发机构(CA)服务器(默认为 Let's Encrypt)启用自动证书管理的标志。如果启用,将忽略 `CERT_FILE` 和 `KEY_FILE`,并且 CA 必须将 `DOMAIN` 解析为此 Gitea 服务器。确保设置了 DNS 记录,并且端口 `80` 或端口 `443` 可以被 CA 服务器访问(默认情况下是公共互联网),并重定向到相应的端口 `PORT_TO_REDIRECT` 或 `HTTP_PORT`。 -- `ACME_URL`: **_empty_**:CA 的 ACME 目录 URL,例如自托管的 [smallstep CA 服务器](https://github.com/smallstep/certificates),它可以是 `https://ca.example.com/acme/acme/directory`。如果留空,默认使用 Let's Encrypt 的生产 CA(还要检查 `LETSENCRYPT_ACCEPTTOS`)。 -- `ACME_ACCEPTTOS`: **false**:这是一个明确的检查,您是否接受 ACME 提供者的服务条款。默认为 Let's Encrypt 的 [服务条款](https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf)。 -- `ACME_DIRECTORY`: **https**:证书管理器用于缓存证书和私钥等信息的目录。 -- `ACME_EMAIL`: **_empty_**:用于 ACME 注册的电子邮件。通常用于通知有关已颁发的证书的问题。 -- `ACME_CA_ROOT`: **_empty_**:CA 的根证书。如果留空,默认使用系统的信任链。 -- `ALLOW_GRACEFUL_RESTARTS`: **true**:在 SIGHUP 时执行优雅重启。 -- `GRACEFUL_HAMMER_TIME`: **60s**:在重新启动后,父进程将停止接受新连接,并允许请求在停止之前完成。如果耗时超过此时间,则会强制关闭关闭。 -- `STARTUP_TIMEOUT`: **0**:如果启动超过提供的时间,将关闭服务器。在 Windows 上设置这将向 SVC 主机发送一个等待提示,告诉 SVC 主机启动可能需要一些时间。请注意,启动由监听器(HTTP/HTTPS/SSH)的打开来确定。索引程序可能需要更长时间启动,可能具有自己的超时时间。 - -## 数据库 (`database`) - -- `DB_TYPE`: **mysql**:数据库类型 \[mysql, postgres, mssql, sqlite3\]。 -- `HOST`: **127.0.0.1:3306**:数据库主机地址和端口或unix套接字的绝对路径 \[mysql, postgres\](例如:/var/run/mysqld/mysqld.sock)。 -- `NAME`: **gitea**:数据库名称。 -- `USER`: **root**:数据库用户名。 -- `PASSWD`: **_empty_**:数据库密码。如果密码包含特殊字符,请使用 \`your password\` 或 """your password"""。 -- `SCHEMA`: **_empty_**:对于 PostgreSQL,如果与 "public" 不同的模式。模式必须事先存在,用户必须对其具有创建特权,并且用户搜索路径必须设置为首先查找模式(例如 `ALTER USER user SET SEARCH_PATH = schema_name,"$user",public;`)。 -- `SSL_MODE`: **disable**:MySQL 或 PostgreSQL 数据库是否启用 SSL 模式,仅适用于 MySQL 和 PostgreSQL。 - - MySQL 的有效值: - - `true`:启用 TLS,并针对数据库服务器证书根证书进行验证。选择此选项时,请确保用于验证数据库服务器证书的根证书(例如 CA 证书)位于数据库服务器和 Gitea 服务器的系统证书存储中。有关如何将 CA 证书添加到证书存储的说明,请参阅系统文档。 - - `false`:禁用 TLS。 - - `disable`:`false` 的别名,与 PostgreSQL 兼容。 - - `skip-verify`:启用 TLS,但不进行数据库服务器证书验证。如果数据库服务器上有自签名或无效证书,请使用此选项。 - - `prefer`:启用 TLS,并回退到非 TLS 连接。 - - PostgreSQL 的有效值: - - `disable`:禁用 TLS。 - - `require`:启用 TLS,但不进行任何验证。 - - `verify-ca`:启用 TLS,并对数据库服务器证书进行根证书验证。 - - `verify-full`:启用 TLS,并验证数据库服务器名称是否与给定的证书的 "Common Name" 或 "Subject Alternative Name" 字段匹配。 -- `SQLITE_TIMEOUT`:**500**:仅适用于 SQLite3 的查询超时。 -- `SQLITE_JOURNAL_MODE`:**""**:更改 SQlite3 的日志模式。可以用于在高负载导致写入拥塞时启用 [WAL 模式](https://www.sqlite.org/wal.html)。有关可能的值,请参阅 [SQlite3 文档](https://www.sqlite.org/pragma.html#pragma_journal_mode)。默认为数据库文件的默认值,通常为 DELETE。 -- `ITERATE_BUFFER_SIZE`:**50**:用于迭代的内部缓冲区大小。 -- `PATH`:**data/gitea.db**:仅适用于 SQLite3 的数据库文件路径。 -- `LOG_SQL`:**false**:记录已执行的 SQL。 -- `DB_RETRIES`:**10**:允许多少次 ORM 初始化 / DB 连接尝试。 -- `DB_RETRY_BACKOFF`:**3s**:如果发生故障,等待另一个 ORM 初始化 / DB 连接尝试的 time.Duration。 -- `MAX_OPEN_CONNS`:**0**:数据库最大打开连接数 - 默认为 0,表示没有限制。 -- `MAX_IDLE_CONNS`:**2**:连接池上的最大空闲数据库连接数,默认为 2 - 这将限制为 `MAX_OPEN_CONNS`。 -- `CONN_MAX_LIFETIME`:**0 或 3s**:设置 DB 连接可以重用的最长时间 - 默认为 0,表示没有限制(除了 MySQL,其中为 3s - 请参见 #6804 和 #7071)。 -- `AUTO_MIGRATION`:**true**:是否自动执行数据库模型迁移。 - -请参见 #8540 和 #8273 以获取有关 `MAX_OPEN_CONNS`、`MAX_IDLE_CONNS` 和 `CONN_MAX_LIFETIME` 的适当值及其与端口耗尽的关系的进一步讨论。 - -## 索引 (`indexer`) - -- `ISSUE_INDEXER_TYPE`: **bleve**:工单索引类型,当前支持:`bleve`、`db`、`elasticsearch` 或 `meilisearch`。 -- `ISSUE_INDEXER_CONN_STR`:****:工单索引连接字符串,仅适用于 elasticsearch 和 meilisearch(例如:http://elastic:password@localhost:9200)或者(例如:http://:apikey@localhost:7700)。 -- `ISSUE_INDEXER_NAME`:**gitea_issues**:工单索引器名称,在 ISSUE_INDEXER_TYPE 为 elasticsearch 或 meilisearch 时可用。 -- `ISSUE_INDEXER_PATH`:**indexers/issues.bleve**:用于工单搜索的索引文件;在 ISSUE_INDEXER_TYPE 为 bleve 和 elasticsearch 时可用。相对路径将相对于 _`AppWorkPath`_ 进行绝对路径化。 - -- `REPO_INDEXER_ENABLED`:**false**:启用代码搜索(占用大量磁盘空间,约为存储库大小的 6 倍)。 -- `REPO_INDEXER_REPO_TYPES`:**sources,forks,mirrors,templates**:存储库索引器单元。要索引的项目可以是 `sources`、`forks`、`mirrors`、`templates` 或它们的任何组合,用逗号分隔。如果为空,则默认为仅 `sources`,如果要完全禁用,请参见 `REPO_INDEXER_ENABLED`。 -- `REPO_INDEXER_TYPE`:**bleve**:代码搜索引擎类型,可以为 `bleve` 或者 `elasticsearch`。 -- `REPO_INDEXER_PATH`:**indexers/repos.bleve**:用于代码搜索的索引文件。 -- `REPO_INDEXER_CONN_STR`:****:代码索引器连接字符串,在 `REPO_INDEXER_TYPE` 为 elasticsearch 时可用。例如:http://elastic:password@localhost:9200 -- `REPO_INDEXER_NAME`:**gitea_codes**:代码索引器名称,在 `REPO_INDEXER_TYPE` 为 elasticsearch 时可用。 - -- `REPO_INDEXER_INCLUDE`:**empty**:逗号分隔的 glob 模式列表(参见 https://github.com/gobwas/glob)以用于**包括**在索引中。使用 `**.txt` 匹配任何具有 .txt 扩展名的文件。空列表表示包括所有文件。 -- `REPO_INDEXER_EXCLUDE`:**empty**:逗号分隔的 glob 模式列表(参见 https://github.com/gobwas/glob)以用于**排除**在索引中。即使在 `REPO_INDEXER_INCLUDE` 中匹配,也不会索引与此列表匹配的文件。 -- `REPO_INDEXER_EXCLUDE_VENDORED`:**true**:从索引中排除 vendored 文件。 -- `MAX_FILE_SIZE`:**1048576**:要索引的文件的最大字节数。 -- `STARTUP_TIMEOUT`:**30s**:如果索引器启动时间超过此超时时间 - 则失败。(此超时时间将添加到上面的锤子时间中,用于子进程 - 因为 bleve 不会在上一个父进程关闭之前启动)。设置为 -1 表示永不超时。 - -## 队列 (`queue` and `queue.*`) - -[queue] 配置在 `[queue.*]` 下为各个队列设置默认值,并允许为各个队列设置单独的配置覆盖。(不过请参见下文。) - -- `TYPE`:**level**:通用队列类型,当前支持:`level`(在内部使用 LevelDB)、`channel`、`redis`、`dummy`。无效的类型将视为 `level`。 -- `DATADIR`:**queues/common**:用于存储 level 队列的基本 DataDir。单独的队列的 `DATADIR` 可以在 `queue.name` 部分进行设置。相对路径将根据 `%(APP_DATA_PATH)s` 变为绝对路径。 -- `LENGTH`:**100000**:通道队列阻塞之前的最大队列大小 -- `BATCH_LENGTH`:**20**:在传递给处理程序之前批处理数据 -- `CONN_STR`:**redis://127.0.0.1:6379/0**:redis 队列类型的连接字符串。对于 `redis-cluster`,使用 `redis+cluster://127.0.0.1:6379/0`。可以使用查询参数来设置选项。类似地,LevelDB 选项也可以使用:**leveldb://relative/path?option=value** 或 **leveldb:///absolute/path?option=value** 进行设置,并将覆盖 `DATADIR`。 -- `QUEUE_NAME`:**_queue**:默认的 redis 和磁盘队列名称的后缀。单独的队列将默认为 **`name`**`QUEUE_NAME`,但可以在特定的 `queue.name` 部分中进行覆盖。 -- `SET_NAME`:**_unique**:将添加到默认的 redis 和磁盘队列 `set` 名称中以用于唯一队列的后缀。单独的队列将默认为 **`name`**`QUEUE_NAME`_`SET_NAME`_,但可以在特定的 `queue.name` 部分中进行覆盖。 -- `MAX_WORKERS`:**(dynamic)**:队列的最大工作协程数。默认值为 "CpuNum/2",限制在 1 到 10 之间。 - -Gitea 创建以下非唯一队列: - -- `code_indexer` -- `issue_indexer` -- `notification-service` -- `task` -- `mail` -- `push_update` - -以及以下唯一队列: - -- `repo_stats_update` -- `repo-archive` -- `mirror` -- `pr_patch_checker` - -## Admin (`admin`) - -- `DEFAULT_EMAIL_NOTIFICATIONS`: **enabled**:用户电子邮件通知的默认配置(用户可配置)。选项:enabled、onmention、disabled -- `DISABLE_REGULAR_ORG_CREATION`: **false**:禁止普通(非管理员)用户创建组织。 -- `USER_DISABLED_FEATURES`:**_empty_** 禁用的用户特性,当前允许为空或者 `deletion`,`manage_ssh_keys`, `manage_gpg_keys` 未来可以增加更多设置。 - - `deletion`: 用户不能通过界面或者API删除他自己。 - - `manage_ssh_keys`: 用户不能通过界面或者API配置SSH Keys。 - - `manage_gpg_keys`: 用户不能配置 GPG 密钥。 - -## 安全性 (`security`) - -- `INSTALL_LOCK`: **false**:控制是否能够访问安装向导页面,设置为 `true` 则禁止访问安装向导页面。 -- `SECRET_KEY`: **\<每次安装时随机生成\>**:全局服务器安全密钥。这个密钥非常重要,如果丢失将无法解密加密的数据(例如 2FA)。 -- `SECRET_KEY_URI`: **_empty_**:与定义 `SECRET_KEY` 不同,此选项可用于使用存储在文件中的密钥(示例值:`file:/etc/gitea/secret_key`)。它不应该像 `SECRET_KEY` 一样容易丢失。 -- `LOGIN_REMEMBER_DAYS`: **31**:在要求重新登录之前,记住用户的登录状态多长时间(以天为单位)。 -- `COOKIE_REMEMBER_NAME`: **gitea\_incredible**:保存自动登录信息的 Cookie 名称。 -- `REVERSE_PROXY_AUTHENTICATION_USER`: **X-WEBAUTH-USER**:反向代理认证的 HTTP 头部名称,用于提供用户信息。 -- `REVERSE_PROXY_AUTHENTICATION_EMAIL`: **X-WEBAUTH-EMAIL**:反向代理认证的 HTTP 头部名称,用于提供邮箱信息。 -- `REVERSE_PROXY_AUTHENTICATION_FULL_NAME`: **X-WEBAUTH-FULLNAME**:反向代理认证的 HTTP 头部名称,用于提供全名信息。 -- `REVERSE_PROXY_LIMIT`: **1**:解释 X-Forwarded-For 标头或 X-Real-IP 标头,并将其设置为请求的远程 IP。 - 可信代理计数。设置为零以不使用这些标头。 -- `REVERSE_PROXY_TRUSTED_PROXIES`: **127.0.0.0/8,::1/128**:逗号分隔的受信任代理服务器的 IP 地址和网络列表。使用 `*` 来信任全部。 -- `DISABLE_GIT_HOOKS`: **true**:设置为 `false` 以允许具有 Git 钩子权限的用户创建自定义 Git 钩子。 - 警告:自定义 Git 钩子可用于在主机操作系统上执行任意代码。这允许用户访问和修改此配置文件和 Gitea 数据库,并中断 Gitea 服务。 - 通过修改 Gitea 数据库,用户可以获得 Gitea 管理员权限。 - 它还使他们可以访问正在运行 Gitea 实例的操作系统上用户可用的其他资源,并以 Gitea 操作系统用户的名义执行任意操作。 - 这可能对您的网站或操作系统造成危害。 - 在必要之前,请在更改现有 git 存储库中的钩子之前进行调整。 -- `DISABLE_WEBHOOKS`: **false**:设置为 `true` 以禁用 Webhooks 功能。 -- `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET`: **true**:设置为 `false` 以允许本地用户在未设置 Gitea 环境的情况下推送到 Gitea 存储库。不建议这样做,如果您希望本地用户推送到 Gitea 存储库,应该适当地设置环境。 -- `IMPORT_LOCAL_PATHS`: **false**:设置为 `false` 以防止所有用户(包括管理员)从服务器上导入本地路径。 -- `INTERNAL_TOKEN`: **\<每次安装时随机生成,如果未设置 URI\>**:用于验证 Gitea 二进制文件内部通信的密钥。 -- `INTERNAL_TOKEN_URI`: **_empty_**:与在配置中定义 `INTERNAL_TOKEN` 不同,此配置选项可用于将包含内部令牌的文件的路径提供给 Gitea(示例值:`file:/etc/gitea/internal_token`)。 -- `PASSWORD_HASH_ALGO`: **pbkdf2**:要使用的哈希算法 \[argon2、pbkdf2、pbkdf2_v1、pbkdf2_hi、scrypt、bcrypt\],argon2 和 scrypt 将消耗大量内存。 - - 注意:`pbkdf2` 哈希的默认参数已更改 - 先前的设置可作为 `pbkdf2_v1` 使用,但不建议使用。 - - 可以通过在算法后使用 `$` 进行调整: - - `argon2$<time>$<memory>$<threads>$<key-length>` - - `bcrypt$<cost>` - - `pbkdf2$<iterations>$<key-length>` - - `scrypt$<n>$<r>$<p>$<key-length>` - - 默认值为: - - `argon2`:`argon2$2$65536$8$50` - - `bcrypt`:`bcrypt$10` - - `pbkdf2`:`pbkdf2$50000$50` - - `pbkdf2_v1`:`pbkdf2$10000$50` - - `pbkdf2_v2`:`pbkdf2$50000$50` - - `pbkdf2_hi`:`pbkdf2$320000$50` - - `scrypt`:`scrypt$65536$16$2$50` - - 使用此功能调整算法参数存在一定风险。 -- `CSRF_COOKIE_HTTP_ONLY`: **true**:设置为 false 以允许 JavaScript 读取 CSRF cookie。 -- `MIN_PASSWORD_LENGTH`: **6**:新用户的最小密码长度。 -- `PASSWORD_COMPLEXITY`: **off**:要求通过最小复杂性的字符类别的逗号分隔列表。如果留空或没有指定有效值,则禁用检查(off): - - lower - 使用一个或多个小写拉丁字符 - - upper - 使用一个或多个大写拉丁字符 - - digit - 使用一个或多个数字 - - spec - 使用一个或多个特殊字符,如 ``!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~`` - - off - 不检查密码复杂性 -- `PASSWORD_CHECK_PWN`: **false**:检查密码是否在 [HaveIBeenPwned](https://haveibeenpwned.com/Passwords) 中曝光。 -- `SUCCESSFUL_TOKENS_CACHE_SIZE`: **20**:缓存成功的令牌哈希。API 令牌在数据库中存储为 pbkdf2 哈希,但这意味着在存在多个 API 操作时可能会有显着的哈希负载。此缓存将在 LRU 缓存中存储成功的哈希令牌,以在性能和安全性之间保持平衡。 - -## Camo (`camo`) - -- `ENABLED`: **false**:启用媒体代理,目前仅支持图像。 -- `SERVER_URL`: **_empty_**:Camo服务器的URL,如果启用camo,则**必填**。 -- `HMAC_KEY`: **_empty_**:为URL编码提供HMAC密钥,如果启用camo,则**必填**。 -- `ALLWAYS`: **false**:设置为true以在HTTP和HTTPS内容上使用camo,否则仅代理非HTTPS URL。 - -## OpenID (`openid`) - -- `ENABLE_OPENID_SIGNIN`: **true**:允许通过OpenID进行身份验证。 -- `ENABLE_OPENID_SIGNUP`: **! DISABLE\_REGISTRATION**:允许通过OpenID进行注册。 -- `WHITELISTED_URIS`: **_empty_**:如果非空,是一组匹配OpenID URI的POSIX正则表达式模式,用于允许访问。 -- `BLACKLISTED_URIS`: **_empty_**:如果非空,是一组匹配OpenID URI的POSIX正则表达式模式,用于阻止访问。 - -## OAuth2 Client (`oauth2_client`) - -- `REGISTER_EMAIL_CONFIRM`: _[service]_ **REGISTER\_EMAIL\_CONFIRM**:设置此项以启用或禁用OAuth2自动注册的电子邮件确认。(覆盖`[service]`部分的`REGISTER\_EMAIL\_CONFIRM`设置) -- `OPENID_CONNECT_SCOPES`: **_empty_**:附加的OpenID连接范围的列表。(`openid`已隐式添加) -- `ENABLE_AUTO_REGISTRATION`: **false**:为新的OAuth2用户自动创建用户帐户。 -- `USERNAME`: **nickname**:新OAuth2帐户的用户名来源: - - userid - 使用userid / sub属性 - - nickname - 使用nickname属性 - - email - 使用email属性的用户名部分 -- `UPDATE_AVATAR`: **false**:如果OAuth2提供程序中有可用的头像,则进行头像更新。更新将在每次登录时执行。 -- `ACCOUNT_LINKING`: **login**:如果帐户/电子邮件已存在,如何处理: - - disabled - 显示错误 - - login - 显示帐户链接登录 - - auto - 自动与帐户链接(请注意,这将因为提供相同的用户名或电子邮件而自动授予现有帐户的访问权限。您必须确保这不会导致身份验证提供程序出现问题。) - -## Service (`service`) - -- `ACTIVE_CODE_LIVE_MINUTES`: **180**:确认帐户/电子邮件注册的时间限制(分钟)。 -- `RESET_PASSWD_CODE_LIVE_MINUTES`: **180**:确认忘记密码重置流程的时间限制(分钟)。 -- `REGISTER_EMAIL_CONFIRM`: **false**:启用此项以要求通过邮件确认注册。需要启用`Mailer`。 -- `REGISTER_MANUAL_CONFIRM`: **false**:启用此项以手动确认新的注册。需要禁用`REGISTER_EMAIL_CONFIRM`。 -- `DISABLE_REGISTRATION`: **false**:禁用注册,之后只有管理员可以为用户创建帐户。 -- `REQUIRE_EXTERNAL_REGISTRATION_PASSWORD`: **false**:启用此项以强制通过外部方式创建的帐户(通过GitHub、OpenID Connect等)创建密码。警告:启用此项将降低安全性,因此只有在您知道自己在做什么时才应启用它。 -- `REQUIRE_SIGNIN_VIEW`: **false**:启用此项以强制用户登录以查看任何页面或使用API。 -- `ENABLE_NOTIFY_MAIL`: **false**:启用此项以在发生某些情况(如创建问题)时向存储库的观察者发送电子邮件。需要启用`Mailer`。 -- `ENABLE_BASIC_AUTHENTICATION`: **true**:禁用此项以禁止使用HTTP BASIC和用户的密码进行身份验证。请注意,如果禁用此项,您将无法使用密码访问令牌API端点。此外,这仅会禁用使用密码的BASIC身份验证,而不会禁用令牌或OAuth Basic。 -- `ENABLE_REVERSE_PROXY_AUTHENTICATION`: **false**:启用此项以允许反向代理身份验证。 -- `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION`: **false**:启用此项以允许反向身份验证的自动注册。 -- `ENABLE_REVERSE_PROXY_EMAIL`: **false**:启用此项以允许使用提供的电子邮件而不是生成的电子邮件进行自动注册。 -- `ENABLE_REVERSE_PROXY_FULL_NAME`: **false**:启用此项以允许使用提供的全名进行自动注册。 -- `ENABLE_CAPTCHA`: **false**:启用此项以对注册使用验证码验证。 -- `REQUIRE_CAPTCHA_FOR_LOGIN`: **false**:启用此项以要求登录使用验证码验证。您还必须启用`ENABLE_CAPTCHA`。 -- `REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA`: **false**:启用此项以强制对外部帐户(即GitHub、OpenID Connect等)使用验证码验证。您还必须启用`ENABLE_CAPTCHA`。 -- `CAPTCHA_TYPE`: **image**:\[image、recaptcha、hcaptcha、mcaptcha、cfturnstile\] -- `RECAPTCHA_SECRET`: **""**:访问https://www.google.com/recaptcha/admin以获取recaptcha的密钥。 -- `RECAPTCHA_SITEKEY`: **""**:访问https://www.google.com/recaptcha/admin以获取recaptcha的站点密钥。 -- `RECAPTCHA_URL`: **https://www.google.com/recaptcha/**:设置recaptcha网址,允许使用recaptcha net。 -- `HCAPTCHA_SECRET`: **""**:注册https://www.hcaptcha.com/以获取hcaptcha的密钥。 -- `HCAPTCHA_SITEKEY`: **""**:注册https://www.hcaptcha.com/以获取hcaptcha的站点密钥。 -- `MCAPTCHA_SECRET`: **""**:访问您的mCaptcha实例以获取mCaptcha的密钥。 -- `MCAPTCHA_SITEKEY`: **""**:访问您的mCaptcha实例以获取mCaptcha的站点密钥。 -- `MCAPTCHA_URL` **https://demo.mcaptcha.org/**:设置mCaptcha的URL。 -- `CF_TURNSTILE_SECRET` **""**:访问https://dash.cloudflare.com/?to=/:account/turnstile以获取cloudflare turnstile的密钥。 -- `CF_TURNSTILE_SITEKEY` **""**:访问https://dash.cloudflare.com/?to=/:account/turnstile以获取cloudflare turnstile的站点密钥。 -- `DEFAULT_KEEP_EMAIL_PRIVATE`: **false**:默认情况下,将用户设置为保持其电子邮件地址私有。 -- `DEFAULT_ALLOW_CREATE_ORGANIZATION`: **true**:默认情况下,允许新用户创建组织。 -- `DEFAULT_USER_IS_RESTRICTED`: **false**:默认情况下,为新用户分配受限权限。 -- `DEFAULT_ENABLE_DEPENDENCIES`: **true**:启用此项以默认启用依赖项。 -- `ALLOW_CROSS_REPOSITORY_DEPENDENCIES` : **true** 启用此项以允许从用户被授予访问权限的任何存储库上进行依赖项操作。 -- `USER_LOCATION_MAP_URL`: **""**:一个显示用户在地图上位置的地图服务URL。位置将作为转义的查询参数附加到URL中。 -- `ENABLE_USER_HEATMAP`: **true**:启用此项以在用户个人资料上显示热图。 -- `ENABLE_TIMETRACKING`: **true**:启用时间跟踪功能。 -- `DEFAULT_ENABLE_TIMETRACKING`: **true**:默认情况下,允许存储库默认使用时间跟踪。 -- `DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME`: **true**:仅允许具有写权限的用户跟踪时间。 -- `EMAIL_DOMAIN_ALLOWLIST`: **_empty_**:如果非空,逗号分隔的域名列表,只能用于在此实例上注册,支持通配符。 -- `EMAIL_DOMAIN_BLOCKLIST`: **_empty_**:如果非空,逗号分隔的域名列表,不能用于在此实例上注册,支持通配符。 -- `SHOW_REGISTRATION_BUTTON`: **! DISABLE\_REGISTRATION**:显示注册按钮 -- `SHOW_MILESTONES_DASHBOARD_PAGE`: **true** 启用此项以显示里程碑仪表板页面 - 查看所有用户的里程碑 -- `AUTO_WATCH_NEW_REPOS`: **true** 启用此项以在创建新存储库时让所有组织用户观看新存储库 -- `AUTO_WATCH_ON_CHANGES`: **false** 启用此项以在首次提交后使用户观看存储库 -- `DEFAULT_USER_VISIBILITY`: **public**:为用户设置默认的可见性模式,可以是"public"、"limited"或"private"。 -- `ALLOWED_USER_VISIBILITY_MODES`: **public,limited,private**:设置用户可以具有的可见性模式 -- `DEFAULT_ORG_VISIBILITY`: **public**:为组织设置默认的可见性模式,可以是"public"、"limited"或"private"。 -- `DEFAULT_ORG_MEMBER_VISIBLE`: **false**:如果添加到组织时将用户的成员身份可见,设置为True。 -- `ALLOW_ONLY_INTERNAL_REGISTRATION`: **false**:设置为True以强制仅通过Gitea进行注册。 -- `ALLOW_ONLY_EXTERNAL_REGISTRATION`: **false**:设置为True以强制仅使用第三方服务进行注册。 -- `NO_REPLY_ADDRESS`: **noreply.DOMAIN**:如果用户将KeepEmailPrivate设置为True,则在Git日志中的用户电子邮件地址的域部分的值。DOMAIN解析为server.DOMAIN中的值。 - 用户的电子邮件将被替换为小写的用户名、"@"和NO_REPLY_ADDRESS的连接。 -- `USER_DELETE_WITH_COMMENTS_MAX_TIME`: **0**:用户删除后,评论将保留的最短时间。 -- `VALID_SITE_URL_SCHEMES`: **http, https**:用户个人资料的有效站点URL方案 - -### Service - Explore (`service.explore`) - -- `REQUIRE_SIGNIN_VIEW`: **false**:仅允许已登录的用户查看探索页面。 -- `DISABLE_USERS_PAGE`: **false**:禁用用户探索页面。 - -## SSH Minimum Key Sizes (`ssh.minimum_key_sizes`) - -定义允许的算法及其最小密钥长度(使用-1来禁用某个类型): - -- `ED25519`:**256** -- `ECDSA`:**256** -- `RSA`:**3071**:我们在这里设置为2047,因为一个其他方面有效的3072 RSA密钥可能被报告为3071长度。 -- `DSA`:**-1**:默认情况下禁用DSA。设置为**1024**以重新启用,但请注意可能需要重新配置您的SSHD提供者 - -## Webhook (`webhook`) - -- `QUEUE_LENGTH`: **1000**:钩子任务队列长度。编辑此值时要小心。 -- `DELIVER_TIMEOUT`: **5**:发送 Webhook 的交付超时时间(秒)。 -- `ALLOWED_HOST_LIST`: **external**:出于安全原因,Webhook 仅能调用允许的主机。以逗号分隔的列表。 - - 内置网络: - - `loopback`:IPv4 的 127.0.0.0/8 和 IPv6 的 ::1/128,包括 localhost。 - - `private`:RFC 1918(10.0.0.0/8,172.16.0.0/12,192.168.0.0/16)和 RFC 4193(FC00::/7)。也称为 LAN/Intranet。 - - `external`:一个有效的非私有单播 IP,您可以访问公共互联网上的所有主机。 - - `*`:允许所有主机。 - - CIDR 列表:IPv4 的 `1.2.3.0/8` 和 IPv6 的 `2001:db8::/32` - - 通配符主机:`*.mydomain.com`,`192.168.100.*` -- `SKIP_TLS_VERIFY`: **false**:允许不安全的证书。 -- `PAGING_NUM`: **10**:一页中显示的 Webhook 历史事件数量。 -- `PROXY_URL`: **_empty_**:代理服务器 URL,支持 http://、https://、socks://,留空将遵循环境的 http_proxy/https_proxy 设置。如果未提供,将使用全局代理设置。 -- `PROXY_HOSTS`: **_empty_**:需要代理的主机名的逗号分隔列表。支持通配符模式 (*);使用 ** 来匹配所有主机。如果未提供,将使用全局代理设置。 - -## 邮件 (`mailer`) - -⚠️ 此部分适用于 Gitea 1.18 及更高版本。如果您使用的是 Gitea 1.17 或更早版本,请阅读以下链接获取更多信息: -[Gitea 1.17 app.ini 示例](https://github.com/go-gitea/gitea/blob/release/v1.17/custom/conf/app.example.ini) -和 -[Gitea 1.17 配置文档](https://github.com/go-gitea/gitea/blob/release/v1.17/docs/content/doc/advanced/config-cheat-sheet.en-us.md) - -- `ENABLED`: **false**:是否启用邮件服务。 -- `PROTOCOL`: **_empty_**:邮件服务协议,可选择 "smtp"、"smtps"、"smtp+starttls"、"smtp+unix"、"sendmail"、"dummy"。在 Gitea 1.18 之前,邮件服务协议由 `MAILER_TYPE` 和 `IS_TLS_ENABLED` 两个配置共同决定。 - - SMTP 类族,如果您的提供者没有明确说明使用的是哪个协议,但提供了一个端口,您可以设置 SMTP_PORT,它将被推断出来。 - - **sendmail** 使用操作系统的 `sendmail` 命令,而不是 SMTP。这在 Linux 系统上很常见。 - - **dummy** 将邮件消息发送到日志,作为测试阶段。 - - 请注意,启用 sendmail 将忽略所有其他 `mailer` 设置,除了 `ENABLED`、`FROM`、`SUBJECT_PREFIX` 和 `SENDMAIL_PATH`。 - - 启用 dummy 将忽略所有设置,除了 `ENABLED`、`SUBJECT_PREFIX` 和 `FROM`。 -- `SMTP_ADDR`: **_empty_**:邮件服务器地址,例如 smtp.gmail.com。对于 smtp+unix,这应该是一个到 unix socket 的路径。在 1.18 之前,此设置与 `SMTP_PORT` 合并,名称为 `HOST`。 -- `SMTP_PORT`: **_empty_**:邮件服务器端口。如果未指定协议,将通过此设置进行推断。常用端口如下。在 1.18 之前,此设置与 `SMTP_ADDR` 合并,名称为 `HOST`。 - - 25:不安全的简单邮件传输协议(insecure SMTP) - - 465:安全的简单邮件传输协议(SMTP Secure) - - 587:StartTLS -- `USE_CLIENT_CERT`: **false**:使用客户端证书进行 TLS/SSL 加密。 -- `CLIENT_CERT_FILE`: **custom/mailer/cert.pem**:客户端证书文件。 -- `CLIENT_KEY_FILE`: **custom/mailer/key.pem**:客户端密钥文件。 -- `FORCE_TRUST_SERVER_CERT`: **false**:如果设置为 `true`,将完全忽略服务器证书验证错误。此选项不安全。考虑将证书添加到系统信任存储中。 -- `USER`: **_empty_**:邮件用户的用户名(通常是发件人的电子邮件地址)。 -- `PASSWD`: **_empty_**:邮件用户的密码。如果密码中使用了特殊字符,请使用 \`your password\` 进行引用。 - - 请注意:只有在 SMTP 服务器通信通过 TLS 加密(可以通过 `STARTTLS` 实现)或 SMTP 主机是 localhost 时,才支持身份验证。有关更多信息,请参阅 [邮件设置](administration/email-setup.md)。 -- `ENABLE_HELO`: **true**:启用 HELO 操作。 -- `HELO_HOSTNAME`: **(从系统检索)**:HELO 主机名。 -- `FROM`: **_empty_**:邮件的发件人地址,符合 RFC 5322。这可以是一个电子邮件地址,也可以是 "Name" \<email@example.com\> 格式。 -- `ENVELOPE_FROM`: **_empty_**:在 SMTP 邮件信封上设置的地址作为发件地址。设置为 `<>` 以发送一个空地址。 -- `SUBJECT_PREFIX`: **_empty_**:放置在电子邮件主题行之前的前缀。 -- `SENDMAIL_PATH`: **sendmail**:操作系统上 `sendmail` 的位置(可以是命令或完整路径)。 -- `SENDMAIL_ARGS`: **_empty_**:指定任何额外的 sendmail 参数。(注意:您应该知道电子邮件地址可能看起来像选项 - 如果您的 `sendmail` 命令带有选项,您必须设置选项终止符 `--`) -- `SENDMAIL_TIMEOUT`: **5m**:通过 sendmail 发送电子邮件的默认超时时间。 -- `SENDMAIL_CONVERT_CRLF`: **true**:大多数版本的 sendmail 偏好使用 LF 换行符,而不是 CRLF 换行符。如果您的 sendmail 版本需要 CRLF 换行符,请将此设置为 false。 -- `SEND_BUFFER_LEN`: **100**:邮件队列的缓冲区长度。**已弃用**,请在 `[queue.mailer]` 中使用 `LENGTH`。 -- `SEND_AS_PLAIN_TEXT`: **false**:仅以纯文本形式发送邮件,不包括 HTML 备选方案。 - -## 入站邮件 (`email.incoming`) - -- `ENABLED`: **false**:启用处理入站邮件。 -- `REPLY_TO_ADDRESS`: **_empty_**:包括 `%{token}` 占位符的电子邮件地址,该占位符将根据用户/操作进行替换。示例:`incoming+%{token}@example.com`。占位符必须出现在地址的用户部分(在 `@` 之前)。 -- `HOST`: **_empty_**:IMAP 服务器主机。 -- `PORT`: **_empty_**:IMAP 服务器端口。 -- `USERNAME`: **_empty_**:接收帐户的用户名。 -- `PASSWORD`: **_empty_**:接收帐户的密码。 -- `USE_TLS`: **false**:IMAP 服务器是否使用 TLS。 -- `SKIP_TLS_VERIFY`: **false**:如果设置为 `true`,将完全忽略服务器证书验证错误。此选项不安全。 -- `MAILBOX`: **INBOX**:入站邮件将到达的邮箱名称。 -- `DELETE_HANDLED_MESSAGE`: **true**:是否应从邮箱中删除已处理的消息。 -- `MAXIMUM_MESSAGE_SIZE`: **10485760**:要处理的消息的最大大小。忽略更大的消息。将其设置为 0 以允许每种大小。 - -## 缓存 (`cache`) - -- `ADAPTER`: **memory**: 缓存引擎,可以为 `memory`, `redis`, `redis-cluster`, `twoqueue` 和 `memcache`. (`twoqueue` 代表缓冲区固定的LRU缓存) -- `INTERVAL`: **60**: 垃圾回收间隔(秒),只对`memory`和`towqueue`有效。 -- `HOST`: **_empty_**: 缓存配置。`redis`, `redis-cluster`,`memcache`配置连接字符串;`twoqueue` 设置队列参数 - - Redis: `redis://:macaron@127.0.0.1:6379/0?pool_size=100&idle_timeout=180s` - - Redis-cluster `redis+cluster://:macaron@127.0.0.1:6379/0?pool_size=100&idle_timeout=180s` - - Memcache: `127.0.0.1:9090;127.0.0.1:9091` - - TwoQueue LRU cache: `{"size":50000,"recent_ratio":0.25,"ghost_ratio":0.5}` 或者 `50000`,代表缓冲区的缓存对象容量 -- `ITEM_TTL`: **16h**: 缓存项目失效时间,设置为 -1 则禁用缓存 - -### 缓存 - 最后提交缓存设置 (`cache.last_commit`) - -- `ITEM_TTL`: **8760h**:如果未使用,保持缓存中的项目的时间,将其设置为 -1 会禁用缓存。 -- `COMMITS_COUNT`: **1000**:仅在存储库的提交计数大于时启用缓存。 - -## 会话 (`session`) - -- `PROVIDER`: **memory**:会话存储引擎 \[memory, file, redis, redis-cluster, db, mysql, couchbase, memcache, postgres\]。设置为 `db` 将会重用 `[database]` 的配置信息。 -- `PROVIDER_CONFIG`: **data/sessions**:对于文件,为根路径;对于 db,为空(将使用数据库配置);对于其他引擎,为连接字符串。相对路径将根据 _`AppWorkPath`_ 绝对化。 -- `COOKIE_SECURE`: **_empty_**:`true` 或 `false`。启用此选项以强制在所有会话访问中使用 HTTPS。如果没有设置,当 ROOT_URL 是 https 链接的时候默认设置为 true。 -- `COOKIE_NAME`: **i\_like\_gitea**:用于会话 ID 的 cookie 名称。 -- `GC_INTERVAL_TIME`: **86400**:GC 间隔时间,以秒为单位。 -- `SESSION_LIFE_TIME`: **86400**:会话生命周期,以秒为单位,默认为 86400(1 天)。 -- `DOMAIN`: **_empty_**:设置 cookie 的域。 -- `SAME_SITE`: **lax** \[strict, lax, none\]:为 cookie 设置 SameSite 属性。 - -## 图像 (`picture`) - -- `GRAVATAR_SOURCE`: **gravatar**:头像来源,可以是 gravatar、duoshuo 或类似 http://cn.gravatar.com/avatar/ 的来源。 - `http://cn.gravatar.com/avatar/`。 -- `DISABLE_GRAVATAR`: **false**:启用后,只使用内部头像。**已弃用 [v1.18+]** 该配置已迁移到数据库中保存,通过管理员面板进行配置。 -- `ENABLE_FEDERATED_AVATAR`: **false**:启用头像联盟支持(参见 - [http://www.libravatar.org](http://www.libravatar.org))。**已弃用 [v1.18+]** 该配置已迁移到数据库中保存,通过管理员面板进行配置。 - -- `AVATAR_STORAGE_TYPE`: **default**:在 `[storage.xxx]` 中定义的存储类型。默认为 `default`,如果没有 `[storage]` 部分,则将读取 `[storage]`,如果没有则将是 `local` 类型。 -- `AVATAR_UPLOAD_PATH`: **data/avatars**:存储用户头像图像文件的路径。 -- `AVATAR_MAX_WIDTH`: **4096**:头像的最大宽度,以像素为单位。 -- `AVATAR_MAX_HEIGHT`: **4096**:头像的最大高度,以像素为单位。 -- `AVATAR_MAX_FILE_SIZE`: **1048576**(1MiB):头像的最大大小。 -- `AVATAR_MAX_ORIGIN_SIZE`: **262144**(256KiB):如果上传的文件不大于此字节大小,则图像将原样使用,无需调整大小/转换。 -- `AVATAR_RENDERED_SIZE_FACTOR`: **2**:渲染的头像图像的乘法因子。较大的值在 HiDPI 设备上会产生更细腻的渲染。 - -- `REPOSITORY_AVATAR_STORAGE_TYPE`: **default**:在 `[storage.xxx]` 中定义的存储类型。默认为 `default`,如果没有 `[storage]` 部分,则将读取 `[storage]`,如果没有则将是 `local` 类型。 -- `REPOSITORY_AVATAR_UPLOAD_PATH`: **data/repo-avatars**:存储仓库头像图像文件的路径。 -- `REPOSITORY_AVATAR_FALLBACK`: **none**:Gitea 处理缺少仓库头像的方式 - - none = 不显示任何头像 - - random = 生成随机头像 - - image = 使用默认图像(在 `REPOSITORY_AVATAR_FALLBACK_IMAGE` 中设置),如果设置为 image 并且未上传任何图像。 -- `REPOSITORY_AVATAR_FALLBACK_IMAGE`: **/img/repo_default.png**:作为默认仓库头像的图像(如果将 `REPOSITORY_AVATAR_FALLBACK` 设置为 image 并且没有上传图像)。 - -## 项目 (`project`) - -默认项目看板的模板: - -- `PROJECT_BOARD_BASIC_KANBAN_TYPE`: **待办,进行中,已完成** -- `PROJECT_BOARD_BUG_TRIAGE_TYPE`: **待分析,高优先级,低优先级,已关闭** - -## 工单和合并请求的附件 (`attachment`) - -- `ENABLED`: **true**: 是否允许用户上传附件。 -- `ALLOWED_TYPES`: **.cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: 允许的文件扩展名(`.zip`)、mime 类型(`text/plain`)或通配符类型(`image/*`、`audio/*`、`video/*`)的逗号分隔列表。空值或 `*/*` 允许所有类型。 -- `MAX_SIZE`: **2048**: 附件的最大限制(MB)。 -- `MAX_FILES`: **5**: 一次最多上传的附件数量。 -- `STORAGE_TYPE`: **local**: 附件的存储类型,`local` 表示本地磁盘,`minio` 表示兼容 S3 的对象存储服务,如果未设置将使用默认值 `local` 或其他在 `[storage.xxx]` 中定义的名称。 -- `SERVE_DIRECT`: **false**: 允许存储驱动器重定向到经过身份验证的 URL 以直接提供文件。目前,只支持 Minio/S3 通过签名 URL 提供支持,local 不会执行任何操作。 -- `PATH`: **attachments**: 存储附件的路径,仅当 STORAGE_TYPE 为 `local` 时可用。如果是相对路径,将会被解析为 `${AppDataPath}/${attachment.PATH}`. -- `MINIO_ENDPOINT`: **localhost:9000**: Minio 端点以连接,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_ACCESS_KEY_ID`: Minio accessKeyID 以连接,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_SECRET_ACCESS_KEY`: Minio secretAccessKey 以连接,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_BUCKET`: **gitea**: Minio 存储附件的存储桶,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_LOCATION`: **us-east-1**: Minio 存储桶的位置以创建,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_BASE_PATH`: **attachments/**: Minio 存储桶上的基本路径,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_USE_SSL`: **false**: Minio 启用 SSL,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio 跳过 SSL 验证,仅当 STORAGE_TYPE 为 `minio` 时可用。 -- `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio 校验算法:`default`(适用于 MinIO 或 AWS S3)或 `md5`(适用于 Cloudflare 或 Backblaze) -- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 - -## 日志 (`log`) - -- `ROOT_PATH`: **_empty_**: 日志文件的根目录。 -- `MODE`: **console**: 日志模式。对于多个模式,请使用逗号分隔。您可以在每个模式的日志子部分中配置每个模式。 `\[log.writer-mode-name\]`. -- `LEVEL`: **Info**: 日志级别。可选值:\[Trace, Debug, Info, Warn, Error, Critical, Fatal, None\] -- `STACKTRACE_LEVEL`: **None**: 记录创建堆栈跟踪的默认日志级别(很少有用,不要设置它)。可选值:\[Trace, Debug, Info, Warn, Error, Critical, Fatal, None\] -- `ENABLE_SSH_LOG`: **false**: 将 SSH 日志保存到日志文件中。 -- `logger.access.MODE`: **_empty_**: "access" 记录器 -- `logger.router.MODE`: **,**: "router" 记录器,单个逗号表示它将使用上述默认 MODE -- `logger.xorm.MODE`: **,**: "xorm" 记录器 - -### 访问日志 (`log`) - -- `ACCESS_LOG_TEMPLATE`: **`{{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"`**: 设置用于创建访问日志的模板。 - - 可用以下变量: - - `Ctx`: 请求的 `context.Context`。 - - `Identity`: 登录的 SignedUserName 或 `"-"`(如果未登录)。 - - `Start`: 请求的开始时间。 - - `ResponseWriter`: 请求的 responseWriter。 - - `RequestID`: 与 REQUEST_ID_HEADERS 相匹配的值(默认:如果不匹配则为 `-`)。 - - 您必须非常小心,确保此模板不会引发错误或 panic,因为此模板在 panic/recovery 脚本之外运行。 -- `REQUEST_ID_HEADERS`: **_empty_**: 您可以在这里配置由逗号分隔的多个值。它将按照配置的顺序进行匹配,最终将在访问日志中打印第一个匹配的值。 - - 例如: - - 在请求头中:X-Request-ID: **test-id-123** - - 在 app.ini 中的配置:REQUEST_ID_HEADERS = X-Request-ID - - 在日志中打印:127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "**test-id-123**" ... - -### 日志子部分 (`log.<writer-mode-name>`) - -- `MODE`: **name**: 设置此日志记录器的模式 - 默认为提供的子部分名称。这允许您在不同级别上具有两个不同的文件日志记录器。 -- `LEVEL`: **log.LEVEL**: 设置此日志记录器的日志级别。默认为全局 `[log]` 部分中设置的 `LEVEL`。 -- `STACKTRACE_LEVEL`: **log.STACKTRACE_LEVEL**: 设置记录堆栈跟踪的日志级别。 -- `EXPRESSION`: **""**: 用于匹配函数名称、文件或消息的正则表达式。默认为空。只有匹配表达式的日志消息才会保存在记录器中。 -- `FLAGS`: **stdflags**: 逗号分隔的字符串,表示日志标志。默认为 `stdflags`,表示前缀:`2009/01/23 01:23:23 ...a/b/c/d.go:23:runtime.Caller() [I]: message`。`none` 表示不要在日志行前缀中添加任何内容。有关更多信息,请参见 `modules/log/flags.go`。 -- `PREFIX`: **""**: 该记录器中每个日志行的附加前缀。默认为空。 -- `COLORIZE`: **false**: 是否为日志行添加颜色 - -### 控制台日志模式 (`log.console` 或 `MODE=console`) - -- 对于控制台记录器,如果不在 Windows 上或终端被确定为能够着色,则 `COLORIZE` 默认为 `true`。 -- `STDERR`: **false**: 使用 Stderr 而不是 Stdout。 - -### 文件日志模式 (`log.file` 或 `MODE=file`) - -- `FILE_NAME`: 设置此记录器的文件名。默认为 `gitea.log`(例外:访问日志默认为 `access.log`)。如果是相对路径,将相对于 `ROOT_PATH`。 -- `LOG_ROTATE`: **true**: 旋转日志文件。 -- `MAX_SIZE_SHIFT`: **28**: 单个文件的最大大小移位,28 表示 256Mb。 -- `DAILY_ROTATE`: **true**: 每天旋转日志。 -- `MAX_DAYS`: **7**: 在 n 天后删除日志文件 -- `COMPRESS`: **true**: 默认使用 gzip 压缩旧的日志文件 -- `COMPRESSION_LEVEL`: **-1**: 压缩级别 - -### 连接日志模式 (`log.conn` 或 `MODE=conn`) - -- `RECONNECT_ON_MSG`: **false**: 对每个单独的消息重新连接主机。 -- `RECONNECT`: **false**: 当连接丢失时尝试重新连接。 -- `PROTOCOL`: **tcp**: 设置协议,可以是 "tcp"、"unix" 或 "udp"。 -- `ADDR`: **:7020**: 设置要连接到的地址。 - -## 定时任务 (`cron`) - -- `ENABLED`: **false**: 是否在后台运行定期任务。 -- `RUN_AT_START`: **false**: 在应用程序启动时运行定时任务。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true时,任务成功完成时将进行通知。 - -- `SCHEDULE` 接受的格式: - - 完整的crontab语法规范, e.g. `* * * * * ?` - - 描述符e.g. `@midnight`, `@every 1h30m` ... - - 更多详见: [cron documentation](https://pkg.go.dev/github.com/gogs/cron@v0.0.0-20171120032916-9f6c956d3e14) - -### 基本定时任务 - 默认开启 - -#### 定时任务 - 删除旧的仓库存档 (`cron.archive_cleanup`) - -- `ENABLED`: **true**: 是否启用该定时任务。 -- `RUN_AT_START`: **true**: 设置在服务启动时运行。 -- `SCHEDULE`: **@midnight**: 使用Cron语法的定时任务触发配置,例如 `@every 1h`。 -- `OLDER_THAN`: **24h**: 超过`OLDER_THAN`时间的存档将被删除,例如 `12h`。 - -#### 定时任务 - 更新镜像仓库 (`cron.update_mirrors`) - -- `SCHEDULE`: **@every 10m**: 使用Cron语法的定时任务触发配置,例如 `@every 3h`。 -- `PULL_LIMIT`: **50**: 将要添加到队列的镜像数量限制为此数字(负值表示无限制,0将导致不会将镜像加入队列,从而有效地禁用镜像更新)。 -- `PUSH_LIMIT`: **50**: 将要添加到队列的镜像数量限制为此数字(负值表示无限制,0将导致不会将镜像加入队列,从而有效地禁用镜像更新)。 - -#### 定时任务 - 健康检查所有仓库 (`cron.repo_health_check`) - -- `SCHEDULE`: **@midnight**: Cron语法,用于安排仓库健康检查。 -- `TIMEOUT`: **60s**: 用于健康检查执行超时的时间持续语法。 -- `ARGS`: **_empty_**: `git fsck` 命令的参数,例如 `--unreachable --tags`。在 http://git-scm.com/docs/git-fsck 上了解更多。 - -#### 定时任务 - 检查所有仓库统计 (`cron.check_repo_stats`) - -- `RUN_AT_START`: **true**: 在启动时运行仓库统计检查。 -- `SCHEDULE`: **@midnight**: Cron语法,用于安排仓库统计检查。 - -#### 定时任务 - 清理 hook_task 表 (`cron.cleanup_hook_task_table`) - -- `ENABLED`: **true**: 启用清理 hook_task 任务。 -- `RUN_AT_START`: **false**: 在启动时运行清理 hook_task(如果启用)。 -- `SCHEDULE`: **@midnight**: Cron语法,用于清理 hook_task 表。 -- `CLEANUP_TYPE` **OlderThan** OlderThan 或 PerWebhook 方法来清理 hook_task,可以按年龄(即 hook_task 记录传递多久)或按每个 Webhook 保留的数量(即每个 Webhook 保留最新的 x 个传递)来清理。 -- `OLDER_THAN`: **168h**: 如果 CLEANUP_TYPE 设置为 OlderThan,则早于此表达式的任何传递的 hook_task 记录将被删除。 -- `NUMBER_TO_KEEP`: **10**: 如果 CLEANUP_TYPE 设置为 PerWebhook,则 Webhook 的此数量 hook_task 记录将被保留(即保留最新的 x 个传递)。 - -#### Cron - 清理过期的包 (`cron.cleanup_packages`) - -- `ENABLED`: **true**: 启用清理过期包任务。 -- `RUN_AT_START`: **true**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 每次运行此任务时都会通知。 -- `SCHEDULE`: **@midnight**: Cron语法,用于任务。 -- `OLDER_THAN`: **24h**: 未引用的包数据创建超过 OLDER_THAN 时间的包将被删除。 - -#### Cron - 更新迁移海报 ID (`cron.update_migration_poster_id`) - -- `SCHEDULE`: **@midnight** : 同步之间的间隔作为持续时间,每次实例启动时都会尝试同步。 - -#### Cron - 同步外部用户 (`cron.sync_external_users`) - -- `SCHEDULE`: **@midnight** : 同步之间的间隔作为持续时间,每次实例启动时都会尝试同步。 -- `UPDATE_EXISTING`: **true**: 创建新用户,更新现有用户数据,并禁用不再在外部源中的用户(默认设置)或仅在 UPDATE_EXISTING 设置为 false 时创建新用户。 - -### 扩展的定时任务(默认未启用) - -#### Cron - 垃圾收集所有仓库 (`cron.git_gc_repos`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 -- `TIMEOUT`: **60s**: 用于垃圾收集执行超时的时间持续语法。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `ARGS`: **_empty_**: `git gc` 命令的参数,例如 `--aggressive --auto`。默认值与 [git] -> GC_ARGS 相同。 - -#### Cron - 使用 Gitea SSH 密钥更新 '.ssh/authorized_keys' 文件 (`cron.resync_all_sshkeys`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 - -#### Cron - 重新同步所有仓库的 pre-receive、update 和 post-receive 钩子 (`cron.resync_all_hooks`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 - -#### Cron - 重新初始化所有缺失的 Git 仓库,但记录已存在 (`cron.reinit_missing_repos`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 - -#### Cron - 删除所有缺少 Git 文件的仓库 (`cron.delete_missing_repos`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 - -#### Cron - 删除生成的仓库头像 (`cron.delete_generated_repository_avatars`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 72h**: Cron语法,用于安排仓库存档清理,例如 `@every 1h`。 - -#### Cron - 从数据库中删除所有旧的操作 (`cron.delete_old_actions`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NOTICE_ON_SUCCESS`: **false**: 设置为 true 以打开成功通知。 -- `SCHEDULE`: **@every 168h**: Cron语法,用于设置多长时间进行检查。 -- `OLDER_THAN`: **8760h**: 早于此表达式的任何操作都将从数据库中删除,建议使用 `8760h`(1年),因为这是热力图的最大长度。 - -#### Cron - 从数据库中删除所有旧的系统通知 (`cron.delete_old_system_notices`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `NO_SUCCESS_NOTICE`: **false**: 设置为 true 以关闭成功通知。 -- `SCHEDULE`: **@every 168h**: Cron语法,用于设置多长时间进行检查。 -- `OLDER_THAN`: **8760h**: 早于此表达式的任何系统通知都将从数据库中删除。 - -#### Cron - 在仓库中回收 LFS 指针 (`cron.gc_lfs`) - -- `ENABLED`: **false**: 启用服务。 -- `RUN_AT_START`: **false**: 在启动时运行任务(如果启用)。 -- `SCHEDULE`: **@every 24h**: Cron语法,用于设置多长时间进行检查。 -- `OLDER_THAN`: **168h**: 只会尝试回收早于此时间(默认7天)的 LFSMetaObject。 -- `LAST_UPDATED_MORE_THAN_AGO`: **72h**: 只会尝试回收超过此时间(默认3天)没有尝试过回收的 LFSMetaObject。 -- `NUMBER_TO_CHECK_PER_REPO`: **100**: 每个仓库要检查的过期 LFSMetaObject 的最小数量。设置为 `0` 以始终检查所有。 - -## Git (`git`) - -- `PATH`: **""**: Git可执行文件的路径。如果为空,Gitea将在PATH环境中搜索。 -- `HOME_PATH`: **%(APP_DATA_PATH)s/home**: Git的HOME目录。 - 此目录将用于包含Gitea的git调用将使用的`.gitconfig`和可能的`.gnupg`目录。如果您可以确认Gitea是在此环境中唯一运行的应用程序,您可以将其设置为Gitea用户的正常主目录。 -- `DISABLE_DIFF_HIGHLIGHT`: **false**: 禁用已添加和已删除更改的高亮显示。 -- `MAX_GIT_DIFF_LINES`: **1000**: 在diff视图中允许单个文件的最大行数。 -- `MAX_GIT_DIFF_LINE_CHARACTERS`: **5000**: 在diff视图中每行的最大字符数。 -- `MAX_GIT_DIFF_FILES`: **100**: 在diff视图中显示的最大文件数。 -- `COMMITS_RANGE_SIZE`: **50**: 设置默认的提交范围大小 -- `BRANCHES_RANGE_SIZE`: **20**: 设置默认的分支范围大小 -- `GC_ARGS`: **_empty_**: 命令`git gc`的参数,例如`--aggressive --auto`。更多信息请参见http://git-scm.com/docs/git-gc/ -- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: 如果使用Git版本 >= 2.18时使用Git wire协议版本2,默认为true,当您始终希望使用Git wire协议版本1时设置为false。 - 要在使用OpenSSH服务器的情况下为通过SSH的Git启用此功能,请将`AcceptEnv GIT_PROTOCOL`添加到您的sshd_config文件中。 -- `PULL_REQUEST_PUSH_MESSAGE`: **true**: 对于推送到非默认分支的响应,使用URL创建拉取请求(如果启用了该存储库的拉取请求) -- `VERBOSE_PUSH`: **true**: 在处理推送时打印有关推送状态的信息。 -- `VERBOSE_PUSH_DELAY`: **5s**: 仅在推送时间超过此延迟时才打印详细信息。 -- `LARGE_OBJECT_THRESHOLD`: **1048576**: (仅限于Go-Git),不要在内存中缓存大于此大小的对象。(设置为0以禁用。) -- `DISABLE_CORE_PROTECT_NTFS`: **false** 将`core.protectNTFS`强制设置为false。 -- `DISABLE_PARTIAL_CLONE`: **false** 禁用使用部分克隆进行git。 - -### Git - 超时设置 (`git.timeout`) - -- `DEFAULT`: **360**: Git操作的默认超时时间,单位秒 -- `MIGRATE`: **600**: 在迁移外部存储库时的超时时间,单位秒 -- `MIRROR`: **300**: 在镜像外部存储库时的超时时间,单位秒 -- `CLONE`: **300**: 在存储库之间进行内部克隆的超时时间,单位秒 -- `PULL`: **300**: 在存储库之间进行内部拉取的超时时间,单位秒 -- `GC`: **60**: git存储库GC的超时时间,单位秒 - -### Git - 配置选项 (`git.config`) - -此部分中的键/值对将用作git配置。 -此部分仅执行“设置”配置,从此部分中删除的配置键不会自动从git配置中删除。格式为`some.configKey = value`。 - -- `diff.algorithm`: **histogram** -- `core.logAllRefUpdates`: **true** -- `gc.reflogExpire`: **90** - -## 指标 (`metrics`) - -- `ENABLED`: **false**: 启用/prometheus的metrics端点。 -- `ENABLED_ISSUE_BY_LABEL`: **false**: 启用按标签统计问题,格式为`gitea_issues_by_label{label="bug"} 2`。 -- `ENABLED_ISSUE_BY_REPOSITORY`: **false**: 启用按存储库统计问题,格式为`gitea_issues_by_repository{repository="org/repo"} 5`。 -- `TOKEN`: **_empty_**: 如果要在授权中包含指标,则需要指定令牌。相同的令牌需要在prometheus参数`bearer_token`或`bearer_token_file`中使用。 - -## API (`api`) - -- `ENABLE_SWAGGER`: **true**: 启用API文档接口 (`/api/swagger`, `/api/v1/swagger`, …). True or false。 -- `MAX_RESPONSE_ITEMS`: **50**: API分页的最大单页项目数。 -- `DEFAULT_PAGING_NUM`: **30**: API分页的默认分页数。 -- `DEFAULT_GIT_TREES_PER_PAGE`: **1000**: Git trees API的默认单页项目数。 -- `DEFAULT_MAX_BLOB_SIZE`: **10485760** (10MiB): blobs API的默认最大文件大小。 - -## OAuth2 (`oauth2`) - -- `ENABLED`: **true**:启用OAuth2提供者。 -- `ACCESS_TOKEN_EXPIRATION_TIME`:**3600**:OAuth2访问令牌的生命周期,以秒为单位。 -- `REFRESH_TOKEN_EXPIRATION_TIME`:**730**:OAuth2刷新令牌的生命周期,以小时为单位。 -- `INVALIDATE_REFRESH_TOKENS`:**false**:检查刷新令牌是否已被使用。 -- `JWT_SIGNING_ALGORITHM`:**RS256**:用于签署OAuth2令牌的算法。有效值:[`HS256`,`HS384`,`HS512`,`RS256`,`RS384`,`RS512`,`ES256`,`ES384`,`ES512`]。 -- `JWT_SECRET`:**_empty_**:OAuth2访问和刷新令牌的身份验证密钥,请将其更改为唯一的字符串。仅当`JWT_SIGNING_ALGORITHM`设置为`HS256`,`HS384`或`HS512`时才需要此设置。 -- `JWT_SECRET_URI`:**_empty_**:可以使用此配置选项,而不是在配置中定义`JWT_SECRET`,以向Gitea提供包含密钥的文件的路径(示例值:`file:/etc/gitea/oauth2_jwt_secret`)。 -- `JWT_SIGNING_PRIVATE_KEY_FILE`:**jwt/private.pem**:用于签署OAuth2令牌的私钥文件路径。路径相对于`APP_DATA_PATH`。仅当`JWT_SIGNING_ALGORITHM`设置为`RS256`,`RS384`,`RS512`,`ES256`,`ES384`或`ES512`时才需要此设置。文件必须包含PKCS8格式的RSA或ECDSA私钥。如果不存在密钥,则将为您创建一个4096位密钥。 -- `MAX_TOKEN_LENGTH`:**32767**:从OAuth2提供者接受的令牌/cookie的最大长度。 -- `DEFAULT_APPLICATIONS`:**git-credential-oauth,git-credential-manager, tea**:在启动时预注册用于某些服务的OAuth应用程序。有关可用选项列表,请参阅[OAuth2文档](/development/oauth2-provider.md)。 - -## i18n (`i18n`) - -- `LANGS`: **en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,uk-UA,ja-JP,es-ES,pt-BR,pt-PT,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sv-SE,ko-KR,el-GR,fa-IR,hu-HU,id-ID,ml-IN**: - 在语言选择器中显示的区域设置列表。如果用户浏览器的语言与列表中的任何区域设置不匹配,则将使用第一个区域设置作为默认值。 - -- `NAMES`:**English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,Français,Nederlands,Latviešu,Русский,Українська,日本語,Español,Português do Brasil,Português de Portugal,Polski,Български,Italiano,Suomi,Türkçe,Čeština,Српски,Svenska,한국어,Ελληνικά,فارسی,Magyar nyelv,Bahasa Indonesia,മലയാളം**: - 对应于各区域设置的可见名称。 - -## Markup (`markup`) - -- `MERMAID_MAX_SOURCE_CHARACTERS`: **5000**: 设置Mermaid源的最大大小。(设为-1代表禁止) - -gitea支持外部渲染工具,你可以配置你熟悉的文档渲染工具. 比如一下将新增一个名字为 asciidoc 的渲染工具。 - -```ini -[markup.asciidoc] -ENABLED = true -NEED_POSTPROCESS = true -FILE_EXTENSIONS = .adoc,.asciidoc -RENDER_COMMAND = "asciidoctor --embedded --safe-mode=secure --out-file=- -" -IS_INPUT_FILE = false -``` - -- ENABLED:**false** 设置是否启动渲染器 -- NEED_POSTPROCESS:**true** 设置为**true**以替换链接/SHA1等。 -- FILE_EXTENSIONS:**_empty_** 要由外部命令渲染的文件扩展名列表。多个扩展名需要用逗号分隔。 -- RENDER_COMMAND:用于渲染所有匹配的扩展名的外部命令。 -- IS_INPUT_FILE:**false** 输入不是标准输入,而是一个在`RENDER_COMMAND`之后带有文件参数的文件。 -- RENDER_CONTENT_MODE:**sanitized** 内容将如何呈现。 - - sanitized:对内容进行清理,并在当前页面内呈现,默认仅允许一些HTML标签和属性。可以在`[markup.sanitizer.*]`中定义自定义的清理规则。 - - no-sanitizer:禁用清理程序,在当前页面内呈现内容。这是**不安全**的,如果内容包含恶意代码,可能会导致XSS攻击。 - - iframe:在单独的独立页面中呈现内容,并通过iframe嵌入到当前页面中。iframe处于禁用同源策略的沙箱模式,并且JS代码与父页面安全隔离。 - -两个特殊的环境变量会传递给渲染命令: - -- `GITEA_PREFIX_SRC`,其中包含`src`路径树中的当前URL前缀。用作链接的前缀。 -- `GITEA_PREFIX_RAW`,其中包含`raw`路径树中的当前URL前缀。用作图像路径的前缀。 - -如果`RENDER_CONTENT_MODE`为`sanitized`,Gitea支持自定义用于呈现的HTML的清理策略。下面的示例将支持来自pandoc的KaTeX输出。 - -```ini -[markup.sanitizer.TeX] -; Pandoc renders TeX segments as <span>s with the "math" class, optionally -; with "inline" or "display" classes depending on context. -ELEMENT = span -ALLOW_ATTR = class -REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+ -ALLOW_DATA_URI_IMAGES = true -``` - -- `ELEMENT`:此策略适用于的元素。必须非空。 -- `ALLOW_ATTR`:此策略允许的属性。必须非空。 -- `REGEXP`:用于匹配属性内容的正则表达式。必须存在,但可以为空,以无条件允许此属性的白名单。 -- `ALLOW_DATA_URI_IMAGES`:**false** 允许数据URI图像(`<img src="data:image/png;base64,..."/>`)。 - -可以通过添加唯一的子节来定义多个清理规则,例如`[markup.sanitizer.TeX-2]`。 -要仅为指定的外部渲染器应用清理规则,它们必须使用渲染器名称,例如`[markup.sanitizer.asciidoc.rule-1]`。 -如果规则在渲染器ini节之上定义,或者名称与渲染器不匹配,则应用于每个渲染器。 - -## 代码高亮映射 (`highlight.mapping`) - -- `file_extension 比如 .toml`: **language 比如 ini**。文件扩展名到语言的映射覆盖。 - -- Gitea 将使用 `.gitattributes` 文件中的 `linguist-language` 或 `gitlab-language` 属性来对文件进行高亮显示,如果可用。 -如果未设置此属性或语言不可用,则将查找文件扩展名在此映射中或使用启发式方法来确定文件类型。 - -## 时间 (`time`) - -- `DEFAULT_UI_LOCATION`:在 UI 上的默认时间位置,以便我们可以在 UI 上显示正确的用户时间。例如:Asia/Shanghai - -## 迁移 (`migrations`) - -- `MAX_ATTEMPTS`:**3**:每次 http/https 请求的最大尝试次数(用于迁移)。 -- `RETRY_BACKOFF`:**3**:每次 http/https 请求重试的退避时间(秒)。 -- `ALLOWED_DOMAINS`:**_empty_**:允许迁移仓库的域名允许列表,默认为空。这意味着允许一切。多个域名可以用逗号分隔。支持通配符:`github.com, *.github.com`。 -- `BLOCKED_DOMAINS`:**_empty_**:阻止迁移仓库的域名阻止列表,默认为空。多个域名可以用逗号分隔。当 `ALLOWED_DOMAINS` 不为空时,此选项优先级较高,用于拒绝域名。支持通配符。 -- `ALLOW_LOCALNETWORKS`:**false**:允许 RFC 1918、RFC 1122、RFC 4632 和 RFC 4291 中定义的私有地址。如果域名被 `ALLOWED_DOMAINS` 允许,此选项将被忽略。 -- `SKIP_TLS_VERIFY`:**false**:允许跳过 TLS 验证。 - -## 联邦(`federation`) - -- `ENABLED`:**false**:启用/禁用联邦功能。 -- `SHARE_USER_STATISTICS`:**true**:如果启用联邦,则启用/禁用节点信息的用户统计信息。 -- `MAX_SIZE`:**4**:联邦请求和响应的最大大小(MB)。 - -警告:更改以下设置可能会破坏联邦功能。 - -- `ALGORITHMS`:**rsa-sha256, rsa-sha512, ed25519**:HTTP 签名算法。 -- `DIGEST_ALGORITHM`:**SHA-256**:HTTP 签名摘要算法。 -- `GET_HEADERS`:**(request-target), Date**:用于联邦请求的 GET 头部。 -- `POST_HEADERS`:**(request-target), Date, Digest**:用于联邦请求的 POST 头部。 - -## 包(`packages`) - -- `ENABLED`:**true**:启用/禁用包注册表功能。 -- `CHUNKED_UPLOAD_PATH`:**tmp/package-upload**:分块上传的路径。默认为 `APP_DATA_PATH` + `tmp/package-upload`。 -- `LIMIT_TOTAL_OWNER_COUNT`:**-1**:单个所有者可以拥有的包版本的最大数量(`-1` 表示无限制)。 -- `LIMIT_TOTAL_OWNER_SIZE`:**-1**:单个所有者可以使用的包的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_ALPINE`:**-1**:Alpine 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CARGO`:**-1**:Cargo 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CHEF`:**-1**:Chef 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_COMPOSER`:**-1**:Composer 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CONAN`:**-1**:Conan 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CONDA`:**-1**:Conda 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CONTAINER`:**-1**:Container 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_CRAN`:**-1**:CRAN 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_DEBIAN`:**-1**:Debian 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_GENERIC`:**-1**:通用上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_GO`:**-1**:Go 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_HELM`:**-1**:Helm 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_MAVEN`:**-1**:Maven 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_NPM`:**-1**:npm 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_NUGET`:**-1**:NuGet 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_PUB`:**-1**:Pub 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_PYPI`:**-1**:PyPI 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_RPM`:**-1**:RPM 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_RUBYGEMS`:**-1**:RubyGems 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_SWIFT`:**-1**:Swift 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 -- `LIMIT_SIZE_VAGRANT`:**-1**:Vagrant 上传的最大大小(`-1` 表示无限制,格式为 `1000`、`1 MB`、`1 GiB`)。 - -## 镜像(`mirror`) - -- `ENABLED`:**true**:启用镜像功能。设置为 **false** 以禁用所有镜像。预先存在的镜像保持有效,但不会更新;可以转换为常规仓库。 -- `DISABLE_NEW_PULL`:**false**:禁用创建**新的**拉取镜像。预先存在的镜像保持有效。如果 `mirror.ENABLED` 为 `false`,将被忽略。 -- `DISABLE_NEW_PUSH`:**false**:禁用创建**新的**推送镜像。预先存在的镜像保持有效。如果 `mirror.ENABLED` 为 `false`,将被忽略。 -- `DEFAULT_INTERVAL`:**8h**:每次检查之间的默认间隔。 -- `MIN_INTERVAL`:**10m**:检查的最小间隔。(必须大于 1 分钟)。 - -## LFS (`lfs`) - -用于 lfs 数据的存储配置。当将 `STORAGE_TYPE` 设置为 `xxx` 时,它将从默认的 `[storage]` 或 `[storage.xxx]` 派生。 -当派生时,`PATH` 的默认值是 `data/lfs`,`MINIO_BASE_PATH` 的默认值是 `lfs/`。 - -- `STORAGE_TYPE`:**local**:lfs 的存储类型,`local` 表示本地磁盘,`minio` 表示 S3 兼容对象存储服务,或者使用 `[storage.xxx]` 中定义的其他名称。 -- `SERVE_DIRECT`:**false**:允许存储驱动程序重定向到经过身份验证的 URL 以直接提供文件。目前,仅支持通过签名的 URL 提供 Minio/S3,本地不执行任何操作。 -- `PATH`:**./data/lfs**:存储 LFS 文件的位置,仅在 `STORAGE_TYPE` 为 `local` 时可用。如果未设置,则回退到 `[server]` 部分中已弃用的 `LFS_CONTENT_PATH` 值。 -- `MINIO_ENDPOINT`:**localhost:9000**:连接的 Minio 终端点,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_ACCESS_KEY_ID`:Minio 的 accessKeyID,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_SECRET_ACCESS_KEY`:Minio 的 secretAccessKey,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_BUCKET`:**gitea**:用于存储 lfs 的 Minio 桶,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_LOCATION`:**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_BASE_PATH`:**lfs/**:桶上的 Minio 基本路径,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 - -## 存储 (`storage`) - -默认的附件、lfs、头像、仓库头像、仓库归档、软件包、操作日志、操作艺术品的存储配置。 - -- `STORAGE_TYPE`:**local**:存储类型,`local` 表示本地磁盘,`minio` 表示 S3,`azureblob` 表示 azure 对象存储。 -- `SERVE_DIRECT`:**false**:允许存储驱动程序重定向到经过身份验证的 URL 以直接提供文件。目前,仅支持通过签名的 URL 提供 Minio/S3,本地不执行任何操作。 -- `MINIO_ENDPOINT`:**localhost:9000**:连接的 Minio 终端点,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_ACCESS_KEY_ID`:Minio 的 accessKeyID,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_SECRET_ACCESS_KEY`:Minio 的 secretAccessKey,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_BUCKET`:**gitea**:用于存储数据的 Minio 桶,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_LOCATION`:**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 - -- `AZURE_BLOB_ENDPOINT`: **_empty_**: Azure Blob 终端点,仅在 `STORAGE_TYPE` 为 `azureblob` 时可用。例如:https://accountname.blob.core.windows.net 或 http://127.0.0.1:10000/devstoreaccount1 -- `AZURE_BLOB_ACCOUNT_NAME`: **_empty_**: Azure Blob 账号名,仅在 `STORAGE_TYPE` 为 `azureblob` 时可用。 -- `AZURE_BLOB_ACCOUNT_KEY`: **_empty_**: Azure Blob 访问密钥,仅在 `STORAGE_TYPE` 为 `azureblob` 时可用。 -- `AZURE_BLOB_CONTAINER`: **gitea**: 用于存储数据的 Azure Blob 容器名,仅在 `STORAGE_TYPE` 为 `azureblob` 时可用。 - -建议的 minio 存储配置如下: - -```ini -[storage] -STORAGE_TYPE = minio -; Minio endpoint to connect only available when STORAGE_TYPE is `minio` -MINIO_ENDPOINT = localhost:9000 -; Minio accessKeyID to connect only available when STORAGE_TYPE is `minio` -MINIO_ACCESS_KEY_ID = -; Minio secretAccessKey to connect only available when STORAGE_TYPE is `minio` -MINIO_SECRET_ACCESS_KEY = -; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio` -MINIO_BUCKET = gitea -; Minio location to create bucket only available when STORAGE_TYPE is `minio` -MINIO_LOCATION = us-east-1 -; Minio enabled ssl only available when STORAGE_TYPE is `minio` -MINIO_USE_SSL = false -; Minio skip SSL verification available when STORAGE_TYPE is `minio` -MINIO_INSECURE_SKIP_VERIFY = false -SERVE_DIRECT = true -; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_BUCKET_LOOKUP_TYPE = auto -``` - -默认情况下,每个存储都有其默认的基本路径,如下所示: - -| storage | default base path | -| ----------------- | ------------------ | -| attachments | attachments/ | -| lfs | lfs/ | -| avatars | avatars/ | -| repo-avatars | repo-avatars/ | -| repo-archive | repo-archive/ | -| packages | packages/ | -| actions_log | actions_log/ | -| actions_artifacts | actions_artifacts/ | - -并且桶(bucket)、基本路径或`SERVE_DIRECT`可以是特殊的或被覆盖的,如果您想要使用不同的设置,您可以: - -```ini -[storage.actions_log] -MINIO_BUCKET = gitea_actions_log -SERVE_DIRECT = true -MINIO_BASE_PATH = my_actions_log/ ; default is actions_log/ if blank -``` - -如果您想为' lfs '自定义一个不同的存储,如果上面定义了默认存储 - -```ini -[lfs] -STORAGE_TYPE = my_minio - -[storage.my_minio] -STORAGE_TYPE = minio -; Minio endpoint to connect only available when STORAGE_TYPE is `minio` -MINIO_ENDPOINT = localhost:9000 -; Minio accessKeyID to connect only available when STORAGE_TYPE is `minio` -MINIO_ACCESS_KEY_ID = -; Minio secretAccessKey to connect only available when STORAGE_TYPE is `minio` -MINIO_SECRET_ACCESS_KEY = -; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio` -MINIO_BUCKET = gitea -; Minio location to create bucket only available when STORAGE_TYPE is `minio` -MINIO_LOCATION = us-east-1 -; Minio enabled ssl only available when STORAGE_TYPE is `minio` -MINIO_USE_SSL = false -; Minio skip SSL verification available when STORAGE_TYPE is `minio` -MINIO_INSECURE_SKIP_VERIFY = false -; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_BUCKET_LOOKUP_TYPE = auto -``` - -### 存储库归档存储 (`storage.repo-archive`) - -存储库归档存储的配置。当将`STORAGE_TYPE`设置为`xxx`时,它将继承默认的 `[storage]` 或 `[storage.xxx]` 配置。`PATH`的默认值是`data/repo-archive`,`MINIO_BASE_PATH`的默认值是`repo-archive/`。 - -- `STORAGE_TYPE`: **local**:存储类型,`local`表示本地磁盘,`minio`表示与S3兼容的对象存储服务,或者使用定义为`[storage.xxx]`的其他名称。 -- `SERVE_DIRECT`: **false**:允许存储驱动程序重定向到经过身份验证的URL以直接提供文件。目前,只有Minio/S3支持通过签名URL,本地不执行任何操作。 -- `PATH`: **./data/repo-archive**:用于存储归档文件的位置,仅在`STORAGE_TYPE`为`local`时可用。 -- `MINIO_ENDPOINT`: **localhost:9000**:Minio端点,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_ACCESS_KEY_ID`: Minio的accessKeyID,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_SECRET_ACCESS_KEY`: Minio的secretAccessKey,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_BUCKET`: **gitea**:用于存储归档的Minio存储桶,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_LOCATION`: **us-east-1**:用于创建存储桶的Minio位置,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_BASE_PATH`: **repo-archive/**:存储桶上的Minio基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_USE_SSL`: **false**:启用Minio的SSL,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_INSECURE_SKIP_VERIFY`: **false**:跳过Minio的SSL验证,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 - -### 存储库归档 (`repo-archive`) - -- `STORAGE_TYPE`: **local**:存储类型,用于操作日志,`local`表示本地磁盘,`minio`表示与S3兼容的对象存储服务,默认为`local`,或者使用定义为`[storage.xxx]`的其他名称。 -- `MINIO_BASE_PATH`: **repo-archive/**:Minio存储桶上的基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 - -## 代理 (`proxy`) - -- `PROXY_ENABLED`: **false**: 启用代理,如果为true,所有通过HTTP向外部的请求都将受到影响,如果为false,即使环境设置了http_proxy/https_proxy也不会使用 -- `PROXY_URL`: **_empty_**: 代理服务器地址,支持 http://, https//, socks://,为空则不启用代理而使用环境变量中的 http_proxy/https_proxy -- `PROXY_HOSTS`: **_empty_**: 逗号分隔的多个需要代理的网址,支持 * 号匹配符号, ** 表示匹配所有网站 - -i.e. - -```ini -PROXY_ENABLED = true -PROXY_URL = socks://127.0.0.1:1080 -PROXY_HOSTS = *.github.com -``` - -## Actions (`actions`) - -- `ENABLED`: **true**:启用/禁用操作功能 -- `DEFAULT_ACTIONS_URL`: **github**:获取操作插件的默认平台,`github`表示`https://github.com`,`self`表示当前的 Gitea 实例。 -- `STORAGE_TYPE`: **local**:用于操作日志的存储类型,`local`表示本地磁盘,`minio`表示与S3兼容的对象存储服务,默认为`local`,或者使用定义为`[storage.xxx]`的其他名称。 -- `MINIO_BASE_PATH`: **actions_log/**:Minio存储桶上的基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 - -`DEFAULT_ACTIONS_URL` 指示 Gitea 操作运行程序应该在哪里找到带有相对路径的操作。 -例如,`uses: actions/checkout@v4` 表示 `https://github.com/actions/checkout@v4`,因为 `DEFAULT_ACTIONS_URL` 的值为 `github`。 -它可以更改为 `self`,以使其成为 `root_url_of_your_gitea/actions/checkout@v4`。 - -请注意,对于大多数情况,不建议使用 `self`,因为它可能使名称在全局范围内产生歧义。 -此外,它要求您将所有所需的操作镜像到您的 Gitea 实例,这可能不值得。 -因此,请仅在您了解自己在做什么的情况下使用 `self`。 - -在早期版本(`<= 1.19`)中,`DEFAULT_ACTIONS_URL` 可以设置为任何自定义 URL,例如 `https://gitea.com` 或 `http://your-git-server,https://gitea.com`,默认值为 `https://gitea.com`。 -然而,后来的更新删除了这些选项,现在唯一的选项是 `github` 和 `self`,默认值为 `github`。 -但是,如果您想要使用其他 Git 服务器中的操作,您可以在 `uses` 字段中使用完整的 URL,Gitea 支持此功能(GitHub 不支持)。 -例如 `uses: https://gitea.com/actions/checkout@v4` 或 `uses: http://your-git-server/actions/checkout@v4`。 - -## 其他 (`other`) - -- `SHOW_FOOTER_VERSION`: **true**: 在页面底部显示Gitea的版本。 -- `SHOW_FOOTER_TEMPLATE_LOAD_TIME`: **true**: 在页脚显示模板执行的时间。 -- `SHOW_FOOTER_POWERED_BY`: **true**: 在页脚显示“由...提供动力”的文本。 -- `ENABLE_SITEMAP`: **true**: 生成sitemap. -- `ENABLE_FEED`: **true**: 是否启用RSS/Atom diff --git a/docs/content/administration/customizing-gitea.en-us.md b/docs/content/administration/customizing-gitea.en-us.md deleted file mode 100644 index 8475f6d131..0000000000 --- a/docs/content/administration/customizing-gitea.en-us.md +++ /dev/null @@ -1,403 +0,0 @@ ---- -date: "2017-04-15T14:56:00+02:00" -title: "Customizing Gitea" -slug: "customizing-gitea" -sidebar_position: 100 -toc: false -draft: false -aliases: - - /en-us/customizing-gitea -menu: - sidebar: - parent: "administration" - name: "Customizing Gitea" - identifier: "customizing-gitea" - sidebar_position: 100 ---- - -# Customizing Gitea - -Customizing Gitea is typically done using the `CustomPath` folder - by default this is -the `custom` folder from the working directory (WorkPath), but may be different if your build has -set this differently. This is the central place to override configuration settings, -templates, etc. You can check the `CustomPath` using `gitea help`. You can also find -the path on the _Configuration_ tab in the _Site Administration_ page. You can override -the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by -using the `--custom-path` option on the `gitea` binary. (The option will override the -environment variable.) - -If Gitea is deployed from binary, all default paths will be relative to the Gitea -binary. If installed from a distribution, these paths will likely be modified to -the Linux Filesystem Standard. Gitea will attempt to create required folders, including -`custom/`. Distributions may provide a symlink for `custom` using `/etc/gitea/`. - -Application settings can be found in file `CustomConf` which is by default, -`$GITEA_CUSTOM/conf/app.ini` but may be different if your build has set this differently. -Again `gitea help` will allow you review this variable and you can override it using the -`--config` option on the `gitea` binary. - -- [Quick Cheat Sheet](administration/config-cheat-sheet.md) -- [Complete List](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) - -If the `CustomPath` folder can't be found despite checking `gitea help`, check the `GITEA_CUSTOM` -environment variable; this can be used to override the default path to something else. -`GITEA_CUSTOM` might, for example, be set by an init script. You can check whether the value -is set under the "Configuration" tab on the site administration page. - -- [List of Environment Variables](administration/environment-variables.md) - -**Note:** Gitea must perform a full restart to see configuration changes. - -## Serving custom public files - -To make Gitea serve custom public files (like pages and images), use the folder -`$GITEA_CUSTOM/public/` as the webroot. Symbolic links will be followed. -At the moment, only the following files are served: - -- `public/robots.txt` -- files in the `public/.well-known/` folder -- files in the `public/assets/` folder - -For example, a file `image.png` stored in `$GITEA_CUSTOM/public/assets/`, can be accessed with -the url `http://gitea.domain.tld/assets/image.png`. - -## Changing the logo - -To build a custom logo and/or favicon clone the Gitea source repository, replace `assets/logo.svg` and/or `assets/favicon.svg` and run -`make generate-images`. `assets/favicon.svg` is used for the favicon only. This will update below output files which you can then place in `$GITEA_CUSTOM/public/assets/img` on your server: - -- `public/assets/img/logo.svg` - Used for site icon, app icon -- `public/assets/img/logo.png` - Used for Open Graph -- `public/assets/img/avatar_default.png` - Used as the default avatar image -- `public/assets/img/apple-touch-icon.png` - Used on iOS devices for bookmarks -- `public/assets/img/favicon.svg` - Used for favicon -- `public/assets/img/favicon.png` - Used as fallback for browsers that don't support SVG favicons - -In case the source image is not in vector format, you can attempt to convert a raster image using tools like [this](https://www.aconvert.com/image/png-to-svg/). - -## Customizing Gitea pages and resources - -Gitea's executable contains all the resources required to run: templates, images, style-sheets -and translations. Any of them can be overridden by placing a replacement in a matching path -inside the `custom` directory. For example, to replace the default `.gitignore` provided -for C++ repositories, we want to replace `options/gitignore/C++`. To do this, a replacement -must be placed in `$GITEA_CUSTOM/options/gitignore/C++` (see about the location of the `CustomPath` -directory at the top of this document). - -Every single page of Gitea can be changed. Dynamic content is generated using [go templates](https://pkg.go.dev/html/template), -which can be modified by placing replacements below the `$GITEA_CUSTOM/templates` directory. - -To obtain any embedded file (including templates), the [`gitea embedded` tool](administration/cmd-embedded.md) can be used. Alternatively, they can be found in the [`templates`](https://github.com/go-gitea/gitea/tree/main/templates) directory of Gitea source (Note: the example link is from the `main` branch. Make sure to use templates compatible with the release you are using). - -Be aware that any statement contained inside `{{` and `}}` are Gitea's template syntax and -shouldn't be touched without fully understanding these components. - -### Customizing startpage / homepage - -Copy [`home.tmpl`](https://github.com/go-gitea/gitea/blob/main/templates/home.tmpl) for your version of Gitea from `templates` to `$GITEA_CUSTOM/templates`. -Edit as you wish. -Dont forget to restart your Gitea to apply the changes. - -### Adding links and tabs - -If all you want is to add extra links to the top navigation bar or footer, or extra tabs to the repository view, you can put them in `extra_links.tmpl` (links added to the navbar), `extra_links_footer.tmpl` (links added to the left side of footer), and `extra_tabs.tmpl` inside your `$GITEA_CUSTOM/templates/custom/` directory. - -For instance, let's say you are in Germany and must add the famously legally-required "Impressum"/about page, listing who is responsible for the site's content: -just place it under your "$GITEA_CUSTOM/public/assets/" directory (for instance `$GITEA_CUSTOM/public/assets/impressum.html`) and put a link to it in either `$GITEA_CUSTOM/templates/custom/extra_links.tmpl` or `$GITEA_CUSTOM/templates/custom/extra_links_footer.tmpl`. - -To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL: -`<a class="item" href="{{AppSubUrl}}/assets/impressum.html">Impressum</a>` - -For more information, see [Adding Legal Pages](administration/adding-legal-pages.md). - -You can add new tabs in the same way, putting them in `extra_tabs.tmpl`. -The exact HTML needed to match the style of other tabs is in the file -`templates/repo/header.tmpl` -([source in GitHub](https://github.com/go-gitea/gitea/blob/main/templates/repo/header.tmpl)) - -### Other additions to the page - -Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `$GITEA_CUSTOM/templates/custom/` directory: - -- `header.tmpl`, just before the end of the `<head>` tag where you can add custom CSS files for instance. -- `body_outer_pre.tmpl`, right after the start of `<body>`. -- `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `<div class="full height">`. -- `body_inner_post.tmpl`, before the end of the main container. -- `body_outer_post.tmpl`, before the bottom `<footer>` element. -- `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional JavaScript. - -### Using Gitea variables - -It's possible to use various Gitea variables in your custom templates. - -First, _temporarily_ enable development mode: in your `app.ini` change from `RUN_MODE = prod` to `RUN_MODE = dev`. Then add `{{ $ | DumpVar }}` to any of your templates, restart Gitea and refresh that page; that will dump all available variables. - -Find the data that you need, and use the corresponding variable; for example, if you need the name of the repository then you'd use `{{.Repository.Name}}`. - -If you need to transform that data somehow, and aren't familiar with Go, an easy workaround is to add the data to the DOM and add a small JavaScript script block to manipulate the data. - -### Example: PlantUML - -You can add [PlantUML](https://plantuml.com/) support to Gitea's markdown by using a PlantUML server. -The data is encoded and sent to the PlantUML server which generates the picture. There is an online -demo server at http://www.plantuml.com/plantuml, but if you (or your users) have sensitive data you -can set up your own [PlantUML server](https://plantuml.com/server) instead. To set up PlantUML rendering, -copy JavaScript files from https://gitea.com/davidsvantesson/plantuml-code-highlight and put them in your -`$GITEA_CUSTOM/public/assets/` folder. Then add the following to `custom/footer.tmpl`: - -```html -<script> - $(async () => { - if (!$('.language-plantuml').length) return; - await Promise.all([ - $.getScript('https://your-gitea-server.com/assets/deflate.js'), - $.getScript('https://your-gitea-server.com/assets/encode.js'), - $.getScript('https://your-gitea-server.com/assets/plantuml_codeblock_parse.js'), - ]); - // Replace call with address to your plantuml server - parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml"); - }); -</script> -``` - -You can then add blocks like the following to your markdown: - -```plantuml -Alice -> Bob: Authentication Request -Bob --> Alice: Authentication Response - -Alice -> Bob: Another authentication Request -Alice <-- Bob: Another authentication Response -``` - -The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`. - -### Example: STL Preview - -You can display STL file directly in Gitea by adding: - -```html -<script> - function lS(src) { - return new Promise(function (resolve, reject) { - let s = document.createElement("script"); - s.src = src; - s.addEventListener("load", () => { - resolve(); - }); - document.body.appendChild(s); - }); - } - - if ($('.view-raw>a[href$=".stl" i]').length) { - $("body").append( - '<link href="/assets/Madeleine.js/src/css/Madeleine.css" rel="stylesheet">' - ); - Promise.all([ - lS("/assets/Madeleine.js/src/lib/stats.js"), - lS("/assets/Madeleine.js/src/lib/detector.js"), - lS("/assets/Madeleine.js/src/lib/three.min.js"), - lS("/assets/Madeleine.js/src/Madeleine.js"), - ]).then(function () { - $(".view-raw") - .attr("id", "view-raw") - .attr("style", "padding: 0;margin-bottom: -10px;"); - new Madeleine({ - target: "view-raw", - data: $('.view-raw>a[href$=".stl" i]').attr("href"), - path: "/assets/Madeleine.js/src", - }); - $('.view-raw>a[href$=".stl"]').remove(); - }); - } -</script> -``` - -to the file `templates/custom/footer.tmpl` - -You also need to download the content of the library [Madeleine.js](https://github.com/beige90/Madeleine.js) and place it under `$GITEA_CUSTOM/public/assets/` folder. - -You should end-up with a folder structure similar to: - -``` -$GITEA_CUSTOM/templates --- custom - `-- footer.tmpl - -$GITEA_CUSTOM/public/assets/ --- Madeleine.js - |-- LICENSE - |-- README.md - |-- css - | |-- pygment_trac.css - | `-- stylesheet.css - |-- examples - | |-- ajax.html - | |-- index.html - | `-- upload.html - |-- images - | |-- bg_hr.png - | |-- blacktocat.png - | |-- icon_download.png - | `-- sprite_download.png - |-- models - | |-- dino2.stl - | |-- ducati.stl - | |-- gallardo.stl - | |-- lamp.stl - | |-- octocat.stl - | |-- skull.stl - | `-- treefrog.stl - `-- src - |-- Madeleine.js - |-- css - | `-- Madeleine.css - |-- icons - | |-- logo.png - | |-- madeleine.eot - | |-- madeleine.svg - | |-- madeleine.ttf - | `-- madeleine.woff - `-- lib - |-- MadeleineConverter.js - |-- MadeleineLoader.js - |-- detector.js - |-- stats.js - `-- three.min.js -``` - -Then restart Gitea and open a STL file on your Gitea instance. - -## Customizing Gitea mails - -The `$GITEA_CUSTOM/templates/mail` folder allows changing the body of every mail of Gitea. -Templates to override can be found in the -[`templates/mail`](https://github.com/go-gitea/gitea/tree/main/templates/mail) -directory of Gitea source. -Override by making a copy of the file under `$GITEA_CUSTOM/templates/mail` using a -full path structure matching source. - -Any statement contained inside `{{` and `}}` are Gitea's template -syntax and shouldn't be touched without fully understanding these components. - -## Adding Analytics to Gitea - -Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `$GITEA_CUSTOM/templates/custom/header.tmpl` file. - -## Customizing gitignores, labels, licenses, locales, and readmes - -Place custom files in corresponding sub-folder under `custom/options`. - -**NOTE:** The files should not have a file extension, e.g. `Labels` rather than `Labels.txt` - -### gitignores - -To add custom .gitignore, add a file with existing [.gitignore rules](https://git-scm.com/docs/gitignore) in it to `$GITEA_CUSTOM/options/gitignore` - -## Customizing the git configuration - -Starting with Gitea 1.20, you can customize the git configuration via the `git.config` section. - -### Enabling signed git pushes - -To enable signed git pushes, set these two options: - -```ini -[git.config] -receive.advertisePushOptions = true -receive.certNonceSeed = <randomstring> -``` - -`certNonceSeed` should be set to a random string and be kept secret. - -### Labels - -Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`: - -```yaml -labels: - - name: "foo/bar" # name of the label that will appear in the dropdown - exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is / - color: aabbcc # hex colour coding - description: Some label # long description of label intent - ``` - -The [legacy file format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) can still be used following the format below, however we strongly recommend using the newer YAML format instead. - -`#hex-color label name ; label description` - -For more information, see the [labels documentation](usage/labels.md). - -### Licenses - -To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license` - -### Locales - -Locales are managed via our [Crowdin](https://crowdin.com/project/gitea). -You can override a locale by placing an altered locale file in `$GITEA_CUSTOM/options/locale`. -Gitea's default locale files can be found in the [`options/locale`](https://github.com/go-gitea/gitea/tree/main/options/locale) source folder and these should be used as examples for your changes. - -To add a completely new locale, as well as placing the file in the above location, you will need to add the new lang and name to the `[i18n]` section in your `app.ini`. Keep in mind that Gitea will use those settings as **overrides**, so if you want to keep the other languages as well you will need to copy/paste the default values and add your own to them. - -``` -[i18n] -LANGS = en-US,foo-BAR -NAMES = English,FooBar -``` - -The first locale will be used as the default if user browser's language doesn't match any locale in the list. - -Locales may change between versions, so keeping track of your customized locales is highly encouraged. - -### Readmes - -To add a custom Readme, add a markdown formatted file (without an `.md` extension) to `$GITEA_CUSTOM/options/readme` - -**NOTE:** readme templates support **variable expansion**. -currently there are `{Name}` (name of repository), `{Description}`, `{CloneURL.SSH}`, `{CloneURL.HTTPS}` and `{OwnerName}` - -### Reactions - -To change reaction emoji's you can set allowed reactions at app.ini - -``` -[ui] -REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes -``` - -A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gitea.com/issues/8) - -## Customizing the look of Gitea - -The built-in themes are `gitea-light`, `gitea-dark`, and `gitea-auto` (which automatically adapts to OS settings). - -The default theme can be changed via `DEFAULT_THEME` in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`. - -Gitea also has support for user themes, which means every user can select which theme should be used. -The list of themes a user can choose from can be configured with the `THEMES` value in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`. - -To make a custom theme available to all users: - -1. Add a CSS file to `$GITEA_CUSTOM/public/assets/css/theme-<theme-name>.css`. - The value of `$GITEA_CUSTOM` of your instance can be queried by calling `gitea help` and looking up the value of "CustomPath". -2. Add `<theme-name>` to the comma-separated list of setting `THEMES` in `app.ini`, or leave `THEMES` empty to allow all themes. - -Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes). - -The default theme sources can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes). - -If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. -This allows Gitea to adjust the Monaco code editor's theme accordingly. - -## Customizing fonts - -Fonts can be customized using CSS variables: - -```css -:root { - --fonts-proportional: /* custom proportional fonts */ !important; - --fonts-monospace: /* custom monospace fonts */ !important; - --fonts-emoji: /* custom emoji fonts */ !important; -} -``` diff --git a/docs/content/administration/customizing-gitea.zh-cn.md b/docs/content/administration/customizing-gitea.zh-cn.md deleted file mode 100644 index f41533c69c..0000000000 --- a/docs/content/administration/customizing-gitea.zh-cn.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -date: "2017-04-15T14:56:00+02:00" -title: "自定义 Gitea 配置" -slug: "customizing-gitea" -sidebar_position: 100 -toc: false -draft: false -aliases: - - /zh-cn/customizing-gitea -menu: - sidebar: - parent: "administration" - name: "自定义 Gitea 配置" - sidebar_position: 100 - identifier: "customizing-gitea" ---- - -# 自定义 Gitea 配置 - -Gitea 引用 `custom` 目录中的自定义配置文件来覆盖配置、模板等默认配置。 - -如果从二进制部署 Gitea ,则所有默认路径都将相对于该 gitea 二进制文件;如果从发行版安装,则可能会将这些路径修改为Linux文件系统标准。Gitea -将会自动创建包括 `custom/` 在内的必要应用目录,应用本身的配置存放在 -`custom/conf/app.ini` 当中。在发行版中可能会以 `/etc/gitea/` 的形式为 `custom` 设置一个符号链接,查看配置详情请移步: - -- [快速备忘单](administration/config-cheat-sheet.md) -- [完整配置清单](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) - -如果您在 binary 同目录下无法找到 `custom` 文件夹,请检查您的 `GITEA_CUSTOM` -环境变量配置, 因为它可能被配置到了其他地方(可能被一些启动脚本设置指定了目录)。 - -- [环境变量清单](administration/environment-variables.md) - -**注:** 必须完全重启 Gitea 以使配置生效。 - -## 使用自定义 /robots.txt - -将 [想要展示的内容](http://www.robotstxt.org/) 存放在 `custom` 目录中的 -`robots.txt` 文件来让 Gitea 使用自定义的`/robots.txt` (默认:空 404)。 - -## 使用自定义的公共文件 - -将自定义的公共文件(比如页面和图片)作为 webroot 放在 `custom/public/` 中来让 Gitea 提供这些自定义内容(符号链接将被追踪)。 - -举例说明:`image.png` 存放在 `custom/public/assets/`中,那么它可以通过链接 http://gitea.domain.tld/assets/image.png 访问。 - -## 修改默认头像 - -替换以下目录中的 png 图片: `custom/public/assets/img/avatar\_default.png` - -## 自定义 Gitea 页面 - -您可以改变 Gitea `custom/templates` 的每个单页面。您可以在 Gitea 源码的 `templates` 目录中找到用于覆盖的模板文件,应用将根据 -`custom/templates` 目录下的路径结构进行匹配和覆盖。 - -包含在 `{{` 和 `}}` 中的任何语句都是 Gitea 的模板语法,如果您不完全理解这些组件,不建议您对它们进行修改。 - -### 添加链接和页签 - -如果您只是想添加额外的链接到顶部导航栏或额外的选项卡到存储库视图,您可以将它们放在您 `custom/templates/custom/` 目录下的 `extra_links.tmpl` 和 `extra_tabs.tmpl` 文件中。 - -举例说明:假设您需要在网站放置一个静态的“关于”页面,您只需将该页面放在您的 -"custom/public/"目录下(比如 `custom/public/impressum.html`)并且将它与 `custom/templates/custom/extra_links.tmpl` 链接起来即可。 - -这个链接应当使用一个名为“item”的 class 来匹配当前样式,您可以使用 `{{AppSubUrl}}` 来获取 base URL: -`<a class="item" href="{{AppSubUrl}}/assets/impressum.html">Impressum</a>` - -同理,您可以将页签添加到 `extra_tabs.tmpl` 中,使用同样的方式来添加页签。它的具体样式需要与 -`templates/repo/header.tmpl` 中已有的其他选项卡的样式匹配 -([source in GitHub](https://github.com/go-gitea/gitea/blob/main/templates/repo/header.tmpl)) - -### 页面的其他新增内容 - -除了 `extra_links.tmpl` 和 `extra_tabs.tmpl`,您可以在您的 `custom/templates/custom/` 目录中存放一些其他有用的模板,例如: - -- `header.tmpl`,在 `<head>` 标记结束之前的模板,例如添加自定义CSS文件 -- `body_outer_pre.tmpl`,在 `<body>` 标记开始处的模板 -- `body_inner_pre.tmpl`,在顶部导航栏之前,但在主 container 内部的模板,例如添加一个 `<div class="full height">` -- `body_inner_post.tmpl`,在主 container 结束处的模板 -- `body_outer_post.tmpl`,在底部 `<footer>` 元素之前. -- `footer.tmpl`,在 `<body>` 标签结束处的模板,可以在这里填写一些附加的 Javascript 脚本。 - -## 自定义 gitignores,labels, licenses, locales 以及 readmes - -将自定义文件放在 `custom/options` 下相应子的文件夹中即可 - -## 更改 Gitea 外观 - -内置主题是“gitea-light”、“gitea-dark”和“gitea-auto”(自动适应操作系统设置)。 - -默认主题可以通过 `app.ini` 的 [ui](administration/config-cheat-sheet.md#ui-ui) 部分中的 `DEFAULT_THEME` 进行更改。 diff --git a/docs/content/administration/email-setup.en-us.md b/docs/content/administration/email-setup.en-us.md deleted file mode 100644 index f9621e6075..0000000000 --- a/docs/content/administration/email-setup.en-us.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -date: "2019-10-15T10:10:00+05:00" -title: "Email setup" -slug: "email-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /en-us/email-setup -menu: - sidebar: - parent: "administration" - name: "Email setup" - sidebar_position: 12 - identifier: "email-setup" ---- - -# Email setup - -Gitea has mailer functionality for sending transactional emails (such as registration confirmation). It can be configured to either use Sendmail (or compatible MTAs like Postfix and msmtp) or directly use SMTP server. - -## Using Sendmail - -Use `sendmail` command as mailer. - -Note: For use in the official Gitea Docker image, please configure with the SMTP version (see the following section). - -Note: For Internet-facing sites consult documentation of your MTA for instructions to send emails over TLS. Also set up SPF, DMARC, and DKIM DNS records to make emails sent be accepted as legitimate by various email providers. - -```ini -[mailer] -ENABLED = true -FROM = gitea@mydomain.com -PROTOCOL = sendmail -SENDMAIL_PATH = /usr/sbin/sendmail -SENDMAIL_ARGS = "--" ; most "sendmail" programs take options, "--" will prevent an email address being interpreted as an option. -``` - -## Using SMTP - -Directly use SMTP server as relay. This option is useful if you don't want to set up MTA on your instance but you have an account at email provider. - -```ini -[mailer] -ENABLED = true -FROM = gitea@mydomain.com -PROTOCOL = smtps -SMTP_ADDR = mail.mydomain.com -SMTP_PORT = 587 -USER = gitea@mydomain.com -PASSWD = `password` -``` - -Restart Gitea for the configuration changes to take effect. - -To send a test email to validate the settings, go to Gitea > Site Administration > Configuration > SMTP Mailer Configuration. - -For the full list of options check the [Config Cheat Sheet](administration/config-cheat-sheet.md) - -Please note: authentication is only supported when the SMTP server communication is encrypted with TLS or `HOST=localhost`. TLS encryption can be through: - -- STARTTLS (also known as Opportunistic TLS) via port 587. Initial connection is done over cleartext, but then be upgraded over TLS if the server supports it. -- SMTPS connection (SMTP over TLS) via the default port 465. Connection to the server use TLS from the beginning. -- Forced SMTPS connection with `PROTOCOL=smtps`. (These are both known as Implicit TLS.) -This is due to protections imposed by the Go internal libraries against STRIPTLS attacks. - -Note that Implicit TLS is recommended by [RFC8314](https://tools.ietf.org/html/rfc8314#section-3) since 2018. - -### Gmail - -The following configuration should work with GMail's SMTP server: - -```ini -[mailer] -ENABLED = true -HOST = smtp.gmail.com:465 ; Remove this line for Gitea >= 1.18.0 -SMTP_ADDR = smtp.gmail.com -SMTP_PORT = 465 -FROM = example.user@gmail.com -USER = example.user -PASSWD = `***` -PROTOCOL = smtps -``` - -Note that you'll need to create and use an [App password](https://support.google.com/accounts/answer/185833?hl=en) by enabling 2FA on your Google -account. You won't be able to use your Google account password directly. diff --git a/docs/content/administration/email-setup.zh-cn.md b/docs/content/administration/email-setup.zh-cn.md deleted file mode 100644 index 2e670be85b..0000000000 --- a/docs/content/administration/email-setup.zh-cn.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "Email 设置" -slug: "email-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /zh-cn/email-setup -menu: - sidebar: - parent: "administration" - name: "Email 设置" - sidebar_position: 12 - identifier: "email-setup" ---- - -# Email 设置 - -Gitea 具有邮件功能,用于发送事务性邮件(例如注册确认邮件)。它可以配置为使用 Sendmail(或兼容的 MTA,例如 Postfix 和 msmtp)或直接使用 SMTP 服务器。 - -## 使用 Sendmail - -使用 `sendmail` 命令作为邮件传输代理(mailer)。 - -注意:对于在官方Gitea Docker镜像中使用,请使用SMTP版本进行配置(请参考下一节)。 - -注意:对于面向互联网的网站,请查阅您的 MTA 文档以了解通过TLS发送邮件的说明。同时设置 SPF、DMARC 和 DKIM DNS 记录,以使发送的邮件被各个电子邮件提供商接受为合法邮件。 - -```ini -[mailer] -ENABLED = true -FROM = gitea@mydomain.com -PROTOCOL = sendmail -SENDMAIL_PATH = /usr/sbin/sendmail -SENDMAIL_ARGS = "--" ; 大多数 "sendmail" 程序都接受选项,使用 "--" 将防止电子邮件地址被解释为选项。 -``` - -## 使用 SMTP - -直接使用 SMTP 服务器作为中继。如果您不想在实例上设置 MTA,但在电子邮件提供商那里有一个帐户,这个选项非常有用。 - -```ini -[mailer] -ENABLED = true -FROM = gitea@mydomain.com -PROTOCOL = smtps -SMTP_ADDR = mail.mydomain.com -SMTP_PORT = 587 -USER = gitea@mydomain.com -PASSWD = `password` -``` - -重启 Gitea 以使配置更改生效。 - -要发送测试邮件以验证设置,请转到 Gitea > 站点管理 > 配置 > SMTP 邮件配置。 - -有关所有选项的完整列表,请查看[配置速查表](administration/config-cheat-sheet.md)。 - -请注意:只有在使用 TLS 或 `HOST=localhost` 加密 SMTP 服务器通信时才支持身份验证。TLS 加密可以通过以下方式进行: - -- 通过端口 587 的 STARTTLS(也称为 Opportunistic TLS)。初始连接是明文的,但如果服务器支持,则可以升级为 TLS。 -- 通过默认端口 465 的 SMTPS 连接。连接到服务器从一开始就使用 TLS。 -- 使用 `PROTOCOL=smtps` 进行强制的 SMTPS 连接。(这两种方式都被称为 Implicit TLS) -这是由于 Go 内部库对 STRIPTLS 攻击的保护机制。 - -请注意,自2018年起,[RFC8314](https://tools.ietf.org/html/rfc8314#section-3) 推荐使用 Implicit TLS。 - -### Gmail - -以下配置应该适用于 Gmail 的 SMTP 服务器: - -```ini -[mailer] -ENABLED = true -HOST = smtp.gmail.com:465 ; 对于 Gitea >= 1.18.0,删除此行 -SMTP_ADDR = smtp.gmail.com -SMTP_PORT = 465 -FROM = example.user@gmail.com -USER = example.user -PASSWD = `***` -PROTOCOL = smtps -``` - -请注意,您需要创建并使用一个 [应用密码](https://support.google.com/accounts/answer/185833?hl=en) 并在您的 Google 帐户上启用 2FA。您将无法直接使用您的 Google 帐户密码。 diff --git a/docs/content/administration/environment-variables.en-us.md b/docs/content/administration/environment-variables.en-us.md deleted file mode 100644 index 2c6fcbe681..0000000000 --- a/docs/content/administration/environment-variables.en-us.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -date: "2017-04-08T11:34:00+02:00" -title: "Environment variables" -slug: "environment-variables" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /en-us/environment-variables -menu: - sidebar: - parent: "administration" - name: "Environment variables" - sidebar_position: 10 - identifier: "environment-variables" ---- - -# Environment variables - -This is an inventory of Gitea environment variables. They change Gitea behaviour. - -Initialize them before Gitea command to be effective, for example: - -```sh -GITEA_CUSTOM=/home/gitea/custom ./gitea web -``` - -## From Go language - -As Gitea is written in Go, it uses some variables that influence the behaviour of Go's runtime, such as: - -- `GOMEMLIMIT` -- `GOGC` -- `GOMAXPROCS` -- `GODEBUG` - -For documentation about each of the variables available, refer to the -[official Go documentation on runtime environment variables](https://pkg.go.dev/runtime#hdr-Environment_Variables). - -## Gitea files - -- `GITEA_WORK_DIR`: Absolute path of working directory. -- `GITEA_CUSTOM`: Gitea uses `WorkPath`/custom folder by default. Use this variable to change _custom_ directory. - -## Operating system specifics - -- `USER`: System user that Gitea will run as. Used for some repository access strings. -- `USERNAME`: if no `USER` found, Gitea will use `USERNAME` -- `HOME`: User home directory path. The `USERPROFILE` environment variable is used in Windows. - -### Only on Windows - -- `USERPROFILE`: User home directory path. If empty, uses `HOMEDRIVE` + `HOMEPATH` -- `HOMEDRIVE`: Main drive path used to access the home directory (C:) -- `HOMEPATH`: Home relative path in the given home drive path - -## Miscellaneous - -- `SKIP_MINWINSVC`: If set to 1, do not run as a service on Windows. diff --git a/docs/content/administration/environment-variables.zh-cn.md b/docs/content/administration/environment-variables.zh-cn.md deleted file mode 100644 index d5be9e03c2..0000000000 --- a/docs/content/administration/environment-variables.zh-cn.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -date: "2017-04-08T11:34:00+02:00" -title: "环境变量清单" -slug: "environment-variables" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /zh-cn/environment-variables -menu: - sidebar: - parent: "administration" - name: "环境变量清单" - sidebar_position: 10 - identifier: "environment-variables" ---- - -# 环境变量清单 - -这里是用来控制 Gitea 行为表现的的环境变量清单,您需要在执行如下 Gitea 启动命令前设置它们来确保配置生效: - -``` -GITEA_CUSTOM=/home/gitea/custom ./gitea web -``` - -## Go 的配置 - -因为 Gitea 使用 Go 语言编写,因此它使用了一些相关的 Go 的配置参数: - -* `GOOS` -* `GOARCH` -* [`GOPATH`](https://go.dev/cmd/go/#hdr-GOPATH_environment_variable) - -您可以在[官方文档](https://go.dev/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。 - -## Gitea 的文件目录 - -* `GITEA_WORK_DIR`:工作目录的绝对路径 -* `GITEA_CUSTOM`:默认情况下 Gitea 使用默认目录 `GITEA_WORK_DIR`/custom,您可以使用这个参数来配置 *custom* 目录 -* `GOGS_WORK_DIR`: 已废弃,请使用 `GITEA_WORK_DIR` 替代 -* `GOGS_CUSTOM`: 已废弃,请使用 `GITEA_CUSTOM` 替代 - -## 操作系统配置 - -* `USER`:Gitea 运行时使用的系统用户,它将作为一些 repository 的访问地址的一部分 -* `USERNAME`: 如果没有配置 `USER`, Gitea 将使用 `USERNAME` -* `HOME`: 用户的 home 目录,在 Windows 中会使用 `USERPROFILE` 环境变量 - -### 仅限于 Windows 的配置 - -* `USERPROFILE`: 用户的主目录,如果未配置则会使用 `HOMEDRIVE` + `HOMEPATH` -* `HOMEDRIVE`: 用于访问 home 目录的主驱动器路径(C盘) -* `HOMEPATH`:在指定主驱动器下的 home 目录相对路径 - -## Miscellaneous - -* `SKIP_MINWINSVC`:如果设置为 1,在 Windows 上不会以 service 的形式运行。 diff --git a/docs/content/administration/external-renderers.en-us.md b/docs/content/administration/external-renderers.en-us.md deleted file mode 100644 index fec2ab64d4..0000000000 --- a/docs/content/administration/external-renderers.en-us.md +++ /dev/null @@ -1,192 +0,0 @@ ---- -date: "2018-11-23:00:00+02:00" -title: "External renderers" -slug: "external-renderers" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /en-us/external-renderers -menu: - sidebar: - parent: "administration" - name: "External renderers" - sidebar_position: 60 - identifier: "external-renderers" ---- - -# Custom files rendering configuration - -Gitea supports custom file renderings (i.e., Jupyter notebooks, asciidoc, etc.) through external binaries, -it is just a matter of: - -- installing external binaries -- add some configuration to your `app.ini` file -- restart your Gitea instance - -This supports rendering of whole files. If you want to render code blocks in markdown you would need to do something with javascript. See some examples on the [Customizing Gitea](administration/customizing-gitea.md) page. - -## Installing external binaries - -In order to get file rendering through external binaries, their associated packages must be installed. -If you're using a Docker image, your `Dockerfile` should contain something along this lines: - -```docker -FROM gitea/gitea:@version@ -[...] - -COPY custom/app.ini /data/gitea/conf/app.ini -[...] - -RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev py3-pyzmq pipx -# install any other package you need for your external renderers - -RUN pipx install jupyter docutils --include-deps -# add above any other python package you may need to install -``` - -## `app.ini` file configuration - -add one `[markup.XXXXX]` section per external renderer on your custom `app.ini`: - -```ini -[markup.asciidoc] -ENABLED = true -FILE_EXTENSIONS = .adoc,.asciidoc -RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -" -; Input is not a standard input but a file -IS_INPUT_FILE = false - -[markup.jupyter] -ENABLED = true -FILE_EXTENSIONS = .ipynb -RENDER_COMMAND = "jupyter nbconvert --stdin --stdout --to html --template basic" -IS_INPUT_FILE = false - -[markup.restructuredtext] -ENABLED = true -FILE_EXTENSIONS = .rst -RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst" -IS_INPUT_FILE = false -``` - -If your external markup relies on additional classes and attributes on the generated HTML elements, you might need to enable custom sanitizer policies. Gitea uses the [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) package as our HTML sanitizer. The example below could be used to support server-side [KaTeX](https://katex.org/) rendering output from [`pandoc`](https://pandoc.org/). - -```ini -[markup.sanitizer.TeX] -; Pandoc renders TeX segments as <span>s with the "math" class, optionally -; with "inline" or "display" classes depending on context. -; - note this is different from the built-in math support in our markdown parser which uses <code> -ELEMENT = span -ALLOW_ATTR = class -REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+ - -[markup.markdown] -ENABLED = true -FILE_EXTENSIONS = .md,.markdown -RENDER_COMMAND = pandoc -f markdown -t html --katex -``` - -You must define `ELEMENT` and `ALLOW_ATTR` in each section. - -To define multiple entries, add a unique alphanumeric suffix (e.g., `[markup.sanitizer.1]` and `[markup.sanitizer.something]`). - -To apply a sanitisation rules only for a specify external renderer they must use the renderer name, e.g. `[markup.sanitizer.asciidoc.rule-1]`, `[markup.sanitizer.<renderer>.rule-1]`. - -**Note**: If the rule is defined above the renderer ini section or the name does not match a renderer it is applied to every renderer. - -Once your configuration changes have been made, restart Gitea to have changes take effect. - -**Note**: Prior to Gitea 1.12 there was a single `markup.sanitiser` section with keys that were redefined for multiple rules, however, -there were significant problems with this method of configuration necessitating configuration through multiple sections. - -### Example: HTML - -Render HTML files directly: - -```ini -[markup.html] -ENABLED = true -FILE_EXTENSIONS = .html,.htm -RENDER_COMMAND = cat -; Input is not a standard input but a file -IS_INPUT_FILE = true - -[markup.sanitizer.html.1] -ELEMENT = div -ALLOW_ATTR = class - -[markup.sanitizer.html.2] -ELEMENT = a -ALLOW_ATTR = class -``` - -### Example: Office DOCX - -Display Office DOCX files with [`pandoc`](https://pandoc.org/): - -```ini -[markup.docx] -ENABLED = true -FILE_EXTENSIONS = .docx -RENDER_COMMAND = "pandoc --from docx --to html --self-contained --template /path/to/basic.html" - -[markup.sanitizer.docx.img] -ALLOW_DATA_URI_IMAGES = true -``` - -The template file has the following content: - -``` -$body$ -``` - -### Example: Jupyter Notebook - -Display Jupyter Notebook files with [`nbconvert`](https://github.com/jupyter/nbconvert): - -```ini -[markup.jupyter] -ENABLED = true -FILE_EXTENSIONS = .ipynb -RENDER_COMMAND = "jupyter-nbconvert --stdin --stdout --to html --template basic" - -[markup.sanitizer.jupyter.img] -ALLOW_DATA_URI_IMAGES = true -``` - -## Customizing CSS - -The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `<div>` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML. - -And so you could write some CSS: - -```css -.markup.XXXXX html { - font-size: 100%; - overflow-y: scroll; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} - -.markup.XXXXX body { - color: #444; - font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif; - font-size: 12px; - line-height: 1.7; - padding: 1em; - margin: auto; - max-width: 42em; - background: #fefefe; -} - -.markup.XXXXX p { - color: orangered; -} -``` - -Add your stylesheet to your custom directory e.g `custom/public/assets/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`: - -```html -<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" /> -``` diff --git a/docs/content/administration/external-renderers.zh-cn.md b/docs/content/administration/external-renderers.zh-cn.md deleted file mode 100644 index 1e56d95a66..0000000000 --- a/docs/content/administration/external-renderers.zh-cn.md +++ /dev/null @@ -1,201 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "外部渲染器" -slug: "external-renderers" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /zh-cn/external-renderers -menu: - sidebar: - parent: "administration" - name: "外部渲染器" - sidebar_position: 60 - identifier: "external-renderers" ---- - -# 自定义文件渲染配置 - -Gitea 通过外部二进制文件支持自定义文件渲染(例如 Jupyter notebooks、asciidoc 等),只需要进行以下步骤: - -- 安装外部二进制文件 -- 在您的 `app.ini` 文件中添加一些配置 -- 重新启动 Gitea 实例 - -此功能支持整个文件的渲染。如果您想要在 Markdown 中渲染代码块,您需要使用 JavaScript 进行一些操作。请参阅 [自定义 Gitea 配置](administration/customizing-gitea.md) 页面上的一些示例。 - -## 安装外部二进制文件 - -为了通过外部二进制文件进行文件渲染,必须安装它们的关联软件包。 -如果您正在使用 Docker 镜像,则您的 `Dockerfile` 应该包含以下内容: - -```docker -FROM gitea/gitea:@version@ -[...] - -COPY custom/app.ini /data/gitea/conf/app.ini -[...] - -RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev py3-pyzmq pipx -# 安装其他您需要的外部渲染器的软件包 - -RUN pipx install jupyter docutils --include-deps -# 在上面添加您需要安装的任何其他 Python 软件包 -``` - -## `app.ini` 文件配置 - -在您的自定义 `app.ini` 文件中为每个外部渲染器添加一个 `[markup.XXXXX]` 部分: - -```ini -[markup.asciidoc] -ENABLED = true -FILE_EXTENSIONS = .adoc,.asciidoc -RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -" -; 输入不是标准输入而是文件 -IS_INPUT_FILE = false - -[markup.jupyter] -ENABLED = true -FILE_EXTENSIONS = .ipynb -RENDER_COMMAND = "jupyter nbconvert --stdin --stdout --to html --template basic" -IS_INPUT_FILE = false - -[markup.restructuredtext] -ENABLED = true -FILE_EXTENSIONS = .rst -RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst" -IS_INPUT_FILE = false -``` - -如果您的外部标记语言依赖于在生成的 HTML 元素上的额外类和属性,您可能需要启用自定义的清理策略。Gitea 使用 [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) 包作为我们的 HTML 清理器。下面的示例可以用于支持从 [`pandoc`](https://pandoc.org/) 输出的服务器端 [KaTeX](https://katex.org/) 渲染结果。 - -```ini -[markup.sanitizer.TeX] -; Pandoc 渲染 TeX 段落为带有 "math" 类的 <span> 元素,根据上下文可能还带有 "inline" 或 "display" 类。 -; - 请注意,这与我们的 Markdown 解析器中内置的数学支持不同,后者使用 <code> 元素。 -ELEMENT = span -ALLOW_ATTR = class -REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+ - -[markup.markdown] -ENABLED = true -FILE_EXTENSIONS = .md,.markdown -RENDER_COMMAND = pandoc -f markdown -t html --katex -``` - -您必须在每个部分中定义 `ELEMENT` 和 `ALLOW_ATTR`。 - -要定义多个条目,请添加唯一的字母数字后缀(例如,`[markup.sanitizer.1]` 和 `[markup.sanitizer.something]`)。 - -要仅为特定的外部渲染器应用清理规则,它们必须使用渲染器名称,例如 `[markup.sanitizer.asciidoc.rule-1]`、`[markup.sanitizer.<renderer>.rule-1]`。 - -**注意**:如果规则在渲染器 ini 部分之前定义,或者名称与渲染器不匹配,它将应用于所有渲染器。 - -完成配置更改后,请重新启动 Gitea 以使更改生效。 - -**注意**:在 Gitea 1.12 之前,存在一个名为 `markup.sanitiser` 的单个部分,其中的键被重新定义为多个规则,但是,这种配置方法存在重大问题,需要通过多个部分进行配置。 - -### 示例:HTML - -直接渲染 HTML 文件: - -```ini -[markup.html] -ENABLED = true -FILE_EXTENSIONS = .html,.htm -RENDER_COMMAND = cat -; 输入不是标准输入,而是文件 -IS_INPUT_FILE = true - -[markup.sanitizer.html.1] -ELEMENT = div -ALLOW_ATTR = class - -[markup.sanitizer.html.2] -ELEMENT = a -ALLOW_ATTR = class -``` - -请注意:此示例中的配置将允许渲染 HTML 文件,并使用 `cat` 命令将文件内容输出为 HTML。此外,配置中的两个清理规则将允许 `<div>` 和 `<a>` 元素使用 `class` 属性。 - -在进行配置更改后,请重新启动 Gitea 以使更改生效。 - -### 示例:Office DOCX - -使用 [`pandoc`](https://pandoc.org/) 显示 Office DOCX 文件: - -```ini -[markup.docx] -ENABLED = true -FILE_EXTENSIONS = .docx -RENDER_COMMAND = "pandoc --from docx --to html --self-contained --template /path/to/basic.html" - -[markup.sanitizer.docx.img] -ALLOW_DATA_URI_IMAGES = true -``` - -在此示例中,配置将允许显示 Office DOCX 文件,并使用 `pandoc` 命令将文件转换为 HTML 格式。同时,清理规则中的 `ALLOW_DATA_URI_IMAGES` 设置为 `true`,允许使用 Data URI 格式的图片。 - -模板文件的内容如下: - -``` -$body$ -``` - -### 示例:Jupyter Notebook - -使用 [`nbconvert`](https://github.com/jupyter/nbconvert) 显示 Jupyter Notebook 文件: - -```ini -[markup.jupyter] -ENABLED = true -FILE_EXTENSIONS = .ipynb -RENDER_COMMAND = "jupyter-nbconvert --stdin --stdout --to html --template basic" - -[markup.sanitizer.jupyter.img] -ALLOW_DATA_URI_IMAGES = true -``` - -在此示例中,配置将允许显示 Jupyter Notebook 文件,并使用 `nbconvert` 命令将文件转换为 HTML 格式。同样,清理规则中的 `ALLOW_DATA_URI_IMAGES` 设置为 `true`,允许使用 Data URI 格式的图片。 - -在进行配置更改后,请重新启动 Gitea 以使更改生效。 - -## 自定义 CSS - -在 `.ini` 文件中,可以使用 `[markup.XXXXX]` 的格式指定外部渲染器,并且由外部渲染器生成的 HTML 将被包装在一个带有 `markup` 和 `XXXXX` 类的 `<div>` 中。`markup` 类提供了预定义的样式(如果 `XXXXX` 是 `markdown`,则使用 `markdown` 类)。否则,您可以使用这些类来针对渲染的 HTML 内容进行定制样式。 - -因此,您可以编写一些 CSS 样式: - -```css -.markup.XXXXX html { - font-size: 100%; - overflow-y: scroll; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} - -.markup.XXXXX body { - color: #444; - font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif; - font-size: 12px; - line-height: 1.7; - padding: 1em; - margin: auto; - max-width: 42em; - background: #fefefe; -} - -.markup.XXXXX p { - color: orangered; -} -``` - -将您的样式表添加到自定义目录中,例如 `custom/public/assets/css/my-style-XXXXX.css`,并使用自定义的头文件 `custom/templates/custom/header.tmpl` 进行导入: - -```html -<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" /> -``` - -通过以上步骤,您可以将自定义的 CSS 样式应用到特定的外部渲染器,使其具有所需的样式效果。 diff --git a/docs/content/administration/fail2ban-setup.en-us.md b/docs/content/administration/fail2ban-setup.en-us.md deleted file mode 100644 index c90f88c886..0000000000 --- a/docs/content/administration/fail2ban-setup.en-us.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -date: "2018-05-11T11:00:00+02:00" -title: "Fail2ban Setup " -slug: "fail2ban-setup" -sidebar_position: 16 -toc: false -draft: false -aliases: - - /en-us/fail2ban-setup -menu: - sidebar: - parent: "administration" - name: "Fail2ban setup" - sidebar_position: 16 - identifier: "fail2ban-setup" ---- - -# Fail2ban setup to block users after failed login attempts - -**Remember that fail2ban is powerful and can cause lots of issues if you do it incorrectly, so make -sure to test this before relying on it so you don't lock yourself out.** - -Gitea returns an HTTP 200 for bad logins in the web logs, but if you have logging options on in -`app.ini`, then you should be able to go off of `log/gitea.log`, which gives you something like this -on a bad authentication from the web or CLI using SSH or HTTP respectively: - -```log -2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx -``` - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:143:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:155:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:198:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:213:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:227:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) - -```log -2020/10/15 16:05:09 modules/ssh/ssh.go:249:sshConnectionFailed() [W] Failed authentication attempt from xxx.xxx.xxx.xxx -``` - -(From 1.15 this new message will available and doesn't have any of the false positive results that above messages from publicKeyHandler do. This will only be logged if the user has completely failed authentication.) - -```log -2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] invalid credentials from xxx.xxx.xxx.xxx -``` - -Add our filter in `/etc/fail2ban/filter.d/gitea.conf`: - -```ini -# gitea.conf -[Definition] -failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST> -ignoreregex = -``` - -Add our jail in `/etc/fail2ban/jail.d/gitea.conf`: - -```ini -[gitea] -enabled = true -filter = gitea -logpath = /var/lib/gitea/log/gitea.log -maxretry = 10 -findtime = 3600 -bantime = 900 -action = iptables-allports -``` - -If you're using Docker, you'll also need to add an additional jail to handle the **FORWARD** -chain in **iptables**. Configure it in `/etc/fail2ban/jail.d/gitea-docker.conf`: - -```ini -[gitea-docker] -enabled = true -filter = gitea -logpath = /var/lib/gitea/log/gitea.log -maxretry = 10 -findtime = 3600 -bantime = 900 -action = iptables-allports[chain="FORWARD"] -``` - -Then simply run `service fail2ban restart` to apply your changes. You can check to see if -fail2ban has accepted your configuration using `service fail2ban status`. - -Make sure and read up on fail2ban and configure it to your needs, this bans someone -for **15 minutes** (from all ports) when they fail authentication 10 times in an hour. - -If you run Gitea behind a reverse proxy with Nginx (for example with Docker), you need to add -this to your Nginx configuration so that IPs don't show up as 127.0.0.1: - -``` -proxy_set_header X-Real-IP $remote_addr; -``` - -The security options in `app.ini` need to be adjusted to allow the interpretation of the headers -as well as the list of IP addresses and networks that describe trusted proxy servers -(See the [configuration cheat sheet](administration/config-cheat-sheet.md#security-security) for more information). - -``` -REVERSE_PROXY_LIMIT = 1 -REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.1/8 ; 172.17.0.0/16 for the docker default network -``` diff --git a/docs/content/administration/fail2ban-setup.zh-cn.md b/docs/content/administration/fail2ban-setup.zh-cn.md deleted file mode 100644 index 457afba959..0000000000 --- a/docs/content/administration/fail2ban-setup.zh-cn.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -date: "2022-08-01T00:00:00+00:00" -title: "设置 Fail2ban" -slug: "fail2ban-setup" -sidebar_position: 16 -toc: false -draft: false -aliases: - - /zh-cn/fail2ban-setup -menu: - sidebar: - parent: "administration" - name: "设置 Fail2ban" - sidebar_position: 16 - identifier: "fail2ban-setup" ---- - -# 使用 Fail2ban 阻止攻击者的暴力登录 - -**Fail2ban 检查客户端登录日志,将多次登录失败的客户端识别为攻击者并在一段时间内阻止其访问服务。如果你的实例是公开的,这一点尤其重要。请管理员仔细设置 fail2ban,错误的配置将导致防火墙阻止你访问自己的服务器。** - -Gitea 会在日志文件 `log/gitea.log` 中记录登录失败的 CLI、SSH 或 HTTP 客户端 IP 地址,而你需要将 Gitea 的日志输出模式从默认的 `console` 更改为 `file`。这表示将日志输出到文件,使得 fail2ban 可以定期扫描日志内容。 - -当用户的身份验证失败时,日志中会记录此类信息: - -```log -2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx -``` - -```log -2020/10/15 16:08:44 [E] invalid credentials from xxx.xxx.xxx.xxx -``` - -## 设置 Fail2ban - -添加日志过滤器规则到配置文件 `/etc/fail2ban/filter.d/gitea.conf`: - -```ini -[Definition] -failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST> -ignoreregex = -``` - -添加监狱规则到配置文件 `/etc/fail2ban/jail.d/gitea.conf`: - -```ini -[gitea] -enabled = true -filter = gitea -logpath = /var/lib/gitea/log/gitea.log -maxretry = 10 -findtime = 3600 -bantime = 900 -action = iptables-allports -``` - -如果你的 Gitea 实例运行在 Docker 容器中,并且直接将容器端口暴露到外部网络, -你还需要添加 `chain="FORWARD"` 到监狱规则配置文件 `/etc/fail2ban/jail.d/gitea-docker.conf` -以适应 Docker 的网络转发规则。但如果你在容器的宿主机上使用 Nginx 反向代理连接到 Gitea 则无需这样配置。 - -```ini -[gitea-docker] -enabled = true -filter = gitea -logpath = /var/lib/gitea/log/gitea.log -maxretry = 10 -findtime = 3600 -bantime = 900 -action = iptables-allports[chain="FORWARD"] -``` - -最后,运行 `systemctl restart fail2ban` 即可应用更改。现在,你可以使用 `systemctl status fail2ban` 检查 fail2ban 运行状态。 - -上述规则规定客户端在 1 小时内,如果登录失败的次数达到 10 次,则通过 iptables 锁定该客户端 IP 地址 15 分钟。 - -## 设置反向代理 - -如果你使用 Nginx 反向代理到 Gitea 实例,你还需要设置 Nginx 的 HTTP 头部值 `X-Real-IP` 将真实的客户端 IP 地址传递给 Gitea。否则 Gitea 程序会将客户端地址错误解析为反向代理服务器的地址,例如回环地址 `127.0.0.1`。 - -``` -proxy_set_header X-Real-IP $remote_addr; -``` - -额外注意,在 Gitea 的配置文件 `app.ini` 中存在下列默认值: - -``` -REVERSE_PROXY_LIMIT = 1 -REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128 -``` - -`REVERSE_PROXY_LIMIT` 限制反向代理服务器的层数,设置为 `0` 表示不使用这些标头。 -`REVERSE_PROXY_TRUSTED_PROXIES` 表示受信任的反向代理服务器网络地址, -经过该网络地址转发来的流量会经过解析 `X-Real-IP` 头部得到真实客户端地址。 -(参考 [configuration cheat sheet](administration/config-cheat-sheet.md#security-security)) diff --git a/docs/content/administration/git-lfs-support.en-us.md b/docs/content/administration/git-lfs-support.en-us.md deleted file mode 100644 index d2c55a29fb..0000000000 --- a/docs/content/administration/git-lfs-support.en-us.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -date: "2019-10-06T08:00:00+05:00" -title: "Git LFS setup" -slug: "git-lfs-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /en-us/git-lfs-setup -menu: - sidebar: - parent: "administration" - name: "Git LFS setup" - sidebar_position: 12 - identifier: "git-lfs-setup" ---- - -# Git Large File Storage setup - -To use Gitea's built-in LFS support, you must update the `app.ini` file: - -```ini -[server] -; Enables git-lfs support. true or false, default is false. -LFS_START_SERVER = true - -[lfs] -; Where your lfs files reside, default is data/lfs. -PATH = /home/gitea/data/lfs -``` - -**Note**: LFS server support needs at least Git v2.1.2 installed on the server diff --git a/docs/content/administration/git-lfs-support.zh-cn.md b/docs/content/administration/git-lfs-support.zh-cn.md deleted file mode 100644 index 268f40f3f0..0000000000 --- a/docs/content/administration/git-lfs-support.zh-cn.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "Git LFS 设置" -slug: "git-lfs-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /zh-cn/git-lfs-setup -menu: - sidebar: - parent: "administration" - name: "Git LFS 设置" - sidebar_position: 12 - identifier: "git-lfs-setup" ---- - -# 配置 Git 大文件存储(Large File Storage,LFS) - -要使用 Gitea 内置的 LFS 支持,您需要更新 `app.ini` 文件: - -```ini -[server] -; 启用 git-lfs 支持。true 或 false,默认为 false。 -LFS_START_SERVER = true - -[lfs] -; 存放 LFS 文件的路径,默认为 data/lfs。 -PATH = /home/gitea/data/lfs -``` - -**注意**:LFS 服务器支持需要服务器上安装 Git v2.1.2 以上版本。 diff --git a/docs/content/administration/https-support.en-us.md b/docs/content/administration/https-support.en-us.md deleted file mode 100644 index 981a29bd85..0000000000 --- a/docs/content/administration/https-support.en-us.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -date: "2018-06-02T11:00:00+02:00" -title: "HTTPS setup" -slug: "https-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /en-us/https-setup -menu: - sidebar: - parent: "administration" - name: "HTTPS setup" - sidebar_position: 12 - identifier: "https-setup" ---- - -# HTTPS setup to encrypt connections to Gitea - -## Using the built-in server - -Before you enable HTTPS, make sure that you have valid SSL/TLS certificates. -You could use self-generated certificates for evaluation and testing. Please run `gitea cert --host [HOST]` to generate a self signed certificate. - -If you are using Apache or nginx on the server, it's recommended to check the [reverse proxy guide](administration/reverse-proxies.md). - -To use Gitea's built-in HTTPS support, you must change your `app.ini` file: - -```ini -[server] -PROTOCOL = https -ROOT_URL = https://git.example.com:3000/ -HTTP_PORT = 3000 -CERT_FILE = cert.pem -KEY_FILE = key.pem -``` - -Note that if your certificate is signed by a third party certificate authority (i.e. not self-signed), then cert.pem should contain the certificate chain. The server certificate must be the first entry in cert.pem, followed by the intermediaries in order (if any). The root certificate does not have to be included because the connecting client must already have it in order to establish the trust relationship. -To learn more about the config values, please checkout the [Config Cheat Sheet](administration/config-cheat-sheet.md#server-server). - -For the `CERT_FILE` or `KEY_FILE` field, the file path is relative to the `GITEA_CUSTOM` environment variable when it is a relative path. It can be an absolute path as well. - -### Setting up HTTP redirection - -The Gitea server is only able to listen to one port; to redirect HTTP requests to the HTTPS port, you will need to enable the HTTP redirection service: - -```ini -[server] -REDIRECT_OTHER_PORT = true -; Port the redirection service should listen on -PORT_TO_REDIRECT = 3080 -``` - -If you are using Docker, make sure that this port is configured in your `docker-compose.yml` file. - -## Using ACME (Default: Let's Encrypt) - -[ACME](https://tools.ietf.org/html/rfc8555) is a Certificate Authority standard protocol that allows you to automatically request and renew SSL/TLS certificates. [Let's Encrypt](https://letsencrypt.org/) is a free publicly trusted Certificate Authority server using this standard. Only `HTTP-01` and `TLS-ALPN-01` challenges are implemented. In order for ACME challenges to pass and verify your domain ownership, external traffic to the gitea domain on port `80` (`HTTP-01`) or port `443` (`TLS-ALPN-01`) has to be served by the gitea instance. Setting up [HTTP redirection](#setting-up-http-redirection) and port-forwards might be needed for external traffic to route correctly. Normal traffic to port `80` will otherwise be automatically redirected to HTTPS. **You must consent** to the ACME provider's terms of service (default Let's Encrypt's [terms of service](https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf)). - -Minimum setup using the default Let's Encrypt: - -```ini -[server] -PROTOCOL=https -DOMAIN=git.example.com -ENABLE_ACME=true -ACME_ACCEPTTOS=true -ACME_DIRECTORY=https -;; Email can be omitted here and provided manually at first run, after which it is cached -ACME_EMAIL=email@example.com -``` - -Minimum setup using a [smallstep CA](https://github.com/smallstep/certificates), refer to [their tutorial](https://smallstep.com/docs/tutorials/acme-challenge) for more information. - -```ini -[server] -PROTOCOL=https -DOMAIN=git.example.com -ENABLE_ACME=true -ACME_ACCEPTTOS=true -ACME_URL=https://ca.example.com/acme/acme/directory -;; Can be omitted if using the system's trust is preferred -;ACME_CA_ROOT=/path/to/root_ca.crt -ACME_DIRECTORY=https -ACME_EMAIL=email@example.com -``` - -To learn more about the config values, please checkout the [Config Cheat Sheet](administration/config-cheat-sheet.md#server-server). - -## Using a reverse proxy - -Setup up your reverse proxy as shown in the [reverse proxy guide](administration/reverse-proxies.md). - -After that, enable HTTPS by following one of these guides: - -- [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html) -- [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html) -- [caddy](https://caddyserver.com/docs/tls) - -Note: Enabling HTTPS only at the proxy level is referred as [TLS Termination Proxy](https://en.wikipedia.org/wiki/TLS_termination_proxy). The proxy server accepts incoming TLS connections, decrypts the contents, and passes the now unencrypted contents to Gitea. This is normally fine as long as both the proxy and Gitea instances are either on the same machine, or on different machines within private network (with the proxy is exposed to outside network). If your Gitea instance is separated from your proxy over a public network, or if you want full end-to-end encryption, you can also [enable HTTPS support directly in Gitea using built-in server](#using-the-built-in-server) and forward the connections over HTTPS instead. diff --git a/docs/content/administration/https-support.zh-cn.md b/docs/content/administration/https-support.zh-cn.md deleted file mode 100644 index 8beb06e80f..0000000000 --- a/docs/content/administration/https-support.zh-cn.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -date: "2023-04-09T11:00:00+02:00" -title: "HTTPS配置" -slug: "https-setup" -sidebar_position: 12 -toc: false -draft: false -menu: - sidebar: - parent: "administration" - name: "HTTPS setup" - sidebar_position: 12 - identifier: "https-setup" ---- - -# HTTPS setup to encrypt connections to Gitea - -## 使用内置服务器 - -在启用HTTPS之前,确保您拥有有效的SSL/TLS证书。 -建议在测试和评估情况下使用自签名证书,请运行 `gitea cert --host [HOST]` 以生成自签名证书 - -如果您在服务器上使用阿帕奇(Apache)或Nginx,建议参考 [反向代理指南](administration/reverse-proxies.md)。 - -要使用Gitea内置HTTPS支持,您必须编辑`app.ini`文件。 - -```ini -[server] -PROTOCOL = https -ROOT_URL = https://git.example.com:3000/ -HTTP_PORT = 3000 -CERT_FILE = cert.pem -KEY_FILE = key.pem -``` - -请注意,如果您的证书由第三方证书颁发机构签名(即不是自签名的),则 cert.pem 应包含证书链。服务器证书必须是 cert.pem 中的第一个条目,后跟中介(如果有)。不必包含根证书,因为连接客户端必须已经拥有根证书才能建立信任关系。要了解有关配置值的更多信息,请查看 [配置备忘单](administration/config-cheat-sheet#server-server)。 - -对于“CERT_FILE”或“KEY_FILE”字段,当文件路径是相对路径时,文件路径相对于“GITEA_CUSTOM”环境变量。它也可以是绝对路径。 - -### 设置HTTP重定向 - -Gitea服务器仅支持监听一个端口;要重定向HTTP请求致HTTPS端口,您需要启用HTTP重定向服务: - -```ini -[server] -REDIRECT_OTHER_PORT = true -; Port the redirection service should listen on -PORT_TO_REDIRECT = 3080 -``` - -如果您使用Docker,确保端口已配置在 `docker-compose.yml` 文件 - -## 使用 ACME (默认: Let's Encrypt) - -[ACME](https://tools.ietf.org/html/rfc8555) 是一种证书颁发机构标准协议,允许您自动请求和续订 SSL/TLS 证书。[Let`s Encrypt](https://letsencrypt.org/) 是使用此标准的免费公开信任的证书颁发机构服务器。仅实施“HTTP-01”和“TLS-ALPN-01”挑战。为了使 ACME 质询通过并验证您的域所有权,“80”端口(“HTTP-01”)或“443”端口(“TLS-ALPN-01”)上 gitea 域的外部流量必须由 gitea 实例提供服务。可能需要设置 [HTTP 重定向](#设置http重定向) 和端口转发才能正确路由外部流量。否则,到端口“80”的正常流量将自动重定向到 HTTPS。**您必须同意**ACME提供商的服务条款(默认为Let's Encrypt的 [服务条款](https://letsencrypt.org/documents/LE-SA-v1.2-2017年11月15日.pdf)。 - -使用默认 Let's Encrypt 的最小配置如下: - -```ini -[server] -PROTOCOL=https -DOMAIN=git.example.com -ENABLE_ACME=true -ACME_ACCEPTTOS=true -ACME_DIRECTORY=https -;; Email can be omitted here and provided manually at first run, after which it is cached -ACME_EMAIL=email@example.com -``` - -小型配置请使用 [smallstep CA](https://github.com/smallstep/certificates), 点击 [教程](https://smallstep.com/docs/tutorials/acme-challenge) 了解更多信息。 - -```ini -[server] -PROTOCOL=https -DOMAIN=git.example.com -ENABLE_ACME=true -ACME_ACCEPTTOS=true -ACME_URL=https://ca.example.com/acme/acme/directory -;; Can be omitted if using the system's trust is preferred -;ACME_CA_ROOT=/path/to/root_ca.crt -ACME_DIRECTORY=https -ACME_EMAIL=email@example.com -``` - -要了解关于配置, 请访问 [配置备忘单](administration/config-cheat-sheet.md#server-server)获取更多信息 - -## 使用反向代理服务器 - -按照 [reverse proxy guide](administration/reverse-proxies.md) 的规则设置你的反向代理服务器 - -然后,按照下面的向导启用 HTTPS: - -- [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html) -- [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html) -- [caddy](https://caddyserver.com/docs/tls) - -注意:仅在代理层启用 HTTPS 被称为 [TLS 终止代理](https://en.wikipedia.org/wiki/TLS_termination_proxy)。代理服务器接受传入的 TLS 连接,解密内容,然后将现在未加密的内容传递给 Gitea。只要代理和 Gitea 实例在同一台计算机上或在私有网络中的不同计算机上(代理暴露给外部网络),这通常是可以接受的。如果您的 Gitea 实例与代理隔离在公共网络上,或者如果您想要全端到端的加密,您还可以直接在 Gitea 中 [启用内置服务器的 HTTPS 支持](#使用内置服务器),并将连接转发到 HTTPS 上。 diff --git a/docs/content/administration/logging-config.en-us.md b/docs/content/administration/logging-config.en-us.md deleted file mode 100644 index 33470ca448..0000000000 --- a/docs/content/administration/logging-config.en-us.md +++ /dev/null @@ -1,294 +0,0 @@ ---- -date: "2019-04-02T17:06:00+01:00" -title: "Logging Configuration" -slug: "logging-config" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /en-us/logging-configuration -menu: - sidebar: - parent: "administration" - name: "Logging Configuration" - sidebar_position: 40 - identifier: "logging-config" ---- - -# Logging Configuration - -The logging configuration of Gitea mainly consists of 3 types of components: - -- The `[log]` section for general configuration -- `[log.<mode-name>]` sections for the configuration of different log writers to output logs, aka: "writer mode", the mode name is also used as "writer name". -- The `[log]` section can also contain sub-logger configurations following the key schema `logger.<logger-name>.<CONFIG-KEY>` - -There is a fully functional log output by default, so it is not necessary to define one. - -## Collecting Logs for Help - -To collect logs for help and issue report, see [Support Options](help/support.md). - -## The `[log]` section - -Configuration of logging facilities in Gitea happen in the `[log]` section and its subsections. - -In the top level `[log]` section the following configurations can be placed: - -- `ROOT_PATH`: (Default: **%(GITEA_WORK_DIR)/log**): Base path for log files -- `MODE`: (Default: **console**) List of log outputs to use for the Default logger. -- `LEVEL`: (Default: **Info**) Least severe log events to persist, case-insensitive. Possible values are: `Trace`, `Debug`, `Info`, `Warn`, `Error`, `Fatal`. -- `STACKTRACE_LEVEL`: (Default: **None**) For this and more severe events the stacktrace will be printed upon getting logged. - -And it can contain the following sub-loggers: - -- `logger.router.MODE`: (Default: **,**): List of log outputs to use for the Router logger. -- `logger.access.MODE`: (Default: **_empty_**) List of log outputs to use for the Access logger. By default, the access logger is disabled. -- `logger.xorm.MODE`: (Default: **,**) List of log outputs to use for the XORM logger. - -Setting a comma (`,`) to sub-logger's mode means making it use the default global `MODE`. - -## Quick samples - -### Default (empty) Configuration - -The empty configuration is equivalent to default: - -```ini -[log] -ROOT_PATH = %(GITEA_WORK_DIR)/log -MODE = console -LEVEL = Info -STACKTRACE_LEVEL = None -logger.router.MODE = , -logger.xorm.MODE = , -logger.access.MODE = - -; this is the config options of "console" mode (used by MODE=console above) -[log.console] -MODE = console -FLAGS = stdflags -PREFIX = -COLORIZE = true -``` - -This is equivalent to sending all logs to the console, with default Golang log being sent to the console log too. - -This is only a sample, and it is the default, do not need to write it into your configuration file. - -### Disable Router logs and record some access logs to file - -The Router logger is disabled, the access logs (>=Warn) goes into `access.log`: - -```ini -[log] -logger.router.MODE = -logger.access.MODE = access-file - -[log.access-file] -MODE = file -LEVEL = Warn -FILE_NAME = access.log -``` - -### Set different log levels for different modes - -Default logs (>=Warn) goes into `gitea.log`, while Error logs goes into `file-error.log`: - -```ini -[log] -LEVEL = Warn -MODE = file, file-error - -; by default, the "file" mode will record logs to %(log.ROOT_PATH)/gitea.log, so we don't need to set it -; [log.file] -; by default, the MODE (actually it's the output writer of this logger) is taken from the section name, so we don't need to set it either -; MODE = file - -[log.file-error] -MODE = file -LEVEL = Error -FILE_NAME = file-error.log -``` - -## Log outputs (mode and writer) - -Gitea provides the following log output writers: - -- `console` - Log to `stdout` (or `stderr` if it is set in the config) -- `file` - Log to a file -- `conn` - Log to a socket (network or unix) - -### Common configuration - -Certain configuration is common to all modes of log output: - -- `MODE` is the mode of the log output writer. It will default to the mode name in the ini section. Thus `[log.console]` will default to `MODE = console`. -- `LEVEL` is the lowest level that this output will log. -- `STACKTRACE_LEVEL` is the lowest level that this output will print a stacktrace. -- `COLORIZE` will default to `true` for `console` as described, otherwise it will default to `false`. - -#### `EXPRESSION` - -`EXPRESSION` represents a regular expression that log events must match to be logged by the output writer. -Either the log message, (with colors removed), must match or the `longfilename:linenumber:functionname` must match. -NB: the whole message or string doesn't need to completely match. - -Please note this expression will be run in the writer's goroutine but not the logging event goroutine. - -#### `FLAGS` - -`FLAGS` represents the preceding logging context information that is -printed before each message. It is a comma-separated string set. The order of values does not matter. - -It defaults to `stdflags` (= `date,time,medfile,shortfuncname,levelinitial`) - -Possible values are: - -- `none` or `,` - No flags. -- `date` - the date in the local time zone: `2009/01/23`. -- `time` - the time in the local time zone: `01:23:23`. -- `microseconds` - microsecond resolution: `01:23:23.123123`. Assumes time. -- `longfile` - full file name and line number: `/a/b/c/d.go:23`. -- `shortfile` - final file name element and line number: `d.go:23`. -- `funcname` - function name of the caller: `runtime.Caller()`. -- `shortfuncname` - last part of the function name. Overrides `funcname`. -- `utc` - if date or time is set, use UTC rather than the local time zone. -- `levelinitial` - initial character of the provided level in brackets eg. `[I]` for info. -- `level` - level in brackets `[INFO]`. -- `gopid` - the Goroutine-PID of the context. -- `medfile` - last 20 characters of the filename - equivalent to `shortfile,longfile`. -- `stdflags` - equivalent to `date,time,medfile,shortfuncname,levelinitial`. - -### Console mode - -In this mode the logger will forward log messages to the stdout and -stderr streams attached to the Gitea process. - -For loggers in console mode, `COLORIZE` will default to `true` if not -on windows, or the Windows terminal can be set into ANSI mode or is a -cygwin or Msys pipe. - -Settings: - -- `STDERR`: **false**: Whether the logger should print to `stderr` instead of `stdout`. - -### File mode - -In this mode the logger will save log messages to a file. - -Settings: - -- `FILE_NAME`: The file to write the log events to, relative to `ROOT_PATH`, Default to `%(ROOT_PATH)/gitea.log`. Exception: access log will default to `%(ROOT_PATH)/access.log`. -- `MAX_SIZE_SHIFT`: **28**: Maximum size shift of a single file. 28 represents 256Mb. For details see below. -- `LOG_ROTATE` **true**: Whether to rotate the log files. TODO: if false, will it delete instead on daily rotate, or do nothing?. -- `DAILY_ROTATE`: **true**: Whether to rotate logs daily. -- `MAX_DAYS`: **7**: Delete rotated log files after this number of days. -- `COMPRESS`: **true**: Whether to compress old log files by default with gzip. -- `COMPRESSION_LEVEL`: **-1**: Compression level. For details see below. - -`MAX_SIZE_SHIFT` defines the maximum size of a file by left shifting 1 the given number of times (`1 << x`). -The exact behavior at the time of v1.17.3 can be seen [here](https://github.com/go-gitea/gitea/blob/v1.17.3/modules/setting/log.go#L185). - -The useful values of `COMPRESSION_LEVEL` are from 1 to (and including) 9, where higher numbers mean better compression. -Beware that better compression might come with higher resource usage. -Must be preceded with a `-` sign. - -### Conn mode - -In this mode the logger will send log messages over a network socket. - -Settings: - -- `ADDR`: **:7020**: Sets the address to connect to. -- `PROTOCOL`: **tcp**: Set the protocol, either "tcp", "unix" or "udp". -- `RECONNECT`: **false**: Try to reconnect when connection is lost. -- `RECONNECT_ON_MSG`: **false**: Reconnect host for every single message. - -### The "Router" logger - -The Router logger logs the following message types when Gitea's route handlers work: - -- `started` messages will be logged at TRACE level -- `polling`/`completed` routers will be logged at INFO. Exception: "/assets" static resource requests are also logged at TRACE. -- `slow` routers will be logged at WARN -- `failed` routers will be logged at WARN - -### The "XORM" logger - -To make XORM outputs SQL logs, the `LOG_SQL` in `[database]` section should also be set to `true`. - -### The "Access" logger - -The Access logger is a new logger since Gitea 1.9. It provides a NCSA -Common Log compliant log format. It's highly configurable but caution -should be taken when changing its template. The main benefit of this -logger is that Gitea can now log accesses in a standard log format so -standard tools may be used. - -You can enable this logger using `logger.access.MODE = ...`. - -If desired the format of the Access logger can be changed by changing -the value of the `ACCESS_LOG_TEMPLATE`. - -Please note, the access logger will log at `INFO` level, setting the -`LEVEL` of this logger to `WARN` or above will result in no access logs. - -#### The ACCESS_LOG_TEMPLATE - -This value represents a go template. Its default value is - -```tmpl -{{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"` -``` - -The template is passed following options: - -- `Ctx` is the `context.Context` -- `Identity` is the `SignedUserName` or `"-"` if the user is not logged in -- `Start` is the start time of the request -- `ResponseWriter` is the `http.ResponseWriter` - -Caution must be taken when changing this template as it runs outside of -the standard panic recovery trap. The template should also be as simple -as it runs for every request. - -## Releasing-and-Reopening, Pausing and Resuming logging - -If you are running on Unix you may wish to release-and-reopen logs in order to use `logrotate` or other tools. -It is possible force Gitea to release and reopen it's logging files and connections by sending `SIGUSR1` to the -running process, or running `gitea manager logging release-and-reopen`. - -Alternatively, you may wish to pause and resume logging - this can be accomplished through the use of the -`gitea manager logging pause` and `gitea manager logging resume` commands. Please note that whilst logging -is paused log events below INFO level will not be stored and only a limited number of events will be stored. -Logging may block, albeit temporarily, slowing Gitea considerably whilst paused - therefore it is -recommended that pausing only done for a very short period of time. - -## Adding and removing logging whilst Gitea is running - -It is possible to add and remove logging whilst Gitea is running using the `gitea manager logging add` and `remove` subcommands. -This functionality can only adjust running log systems and cannot be used to start the access or router loggers if they -were not already initialized. If you wish to start these systems you are advised to adjust the app.ini and (gracefully) restart -the Gitea service. - -The main intention of these commands is to easily add a temporary logger to investigate problems on running systems where a restart -may cause the issue to disappear. - -## Using `logrotate` instead of built-in log rotation - -Gitea includes built-in log rotation, which should be enough for most deployments. However, if you instead want to use the `logrotate` utility: - -- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`. -- Install `logrotate`. -- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. - In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, - or run `gitea manager logging release-and-reopen` (with the appropriate environment). - Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections. -- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations. -- If you are using docker and are running from outside the container you can use - `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` - or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the Gitea process itself. - -The next `logrotate` jobs will include your configurations, so no restart is needed. -You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`. diff --git a/docs/content/administration/logging-config.zh-cn.md b/docs/content/administration/logging-config.zh-cn.md deleted file mode 100644 index 273a413592..0000000000 --- a/docs/content/administration/logging-config.zh-cn.md +++ /dev/null @@ -1,272 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "日志配置" -slug: "logging-config" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /zh-cn/logging-configuration -menu: - sidebar: - parent: "administration" - name: "日志配置" - sidebar_position: 40 - identifier: "logging-config" ---- - -# 日志配置 - -Gitea 的日志配置主要由以下三种类型的组件组成: - -- `[log]` 部分用于一般配置 -- `[log.<mode-name>]` 部分用于配置不同的日志输出方式,也称为 "writer mode",模式名称同时也作为 "writer name" -- `[log]` 部分还可以包含遵循 `logger.<logger-name>.<CONFIG-KEY>` 模式的子日志记录器的配置 - -默认情况下,已经有一个完全功能的日志输出,因此不需要重新定义。 - -## 收集日志以获取帮助 - -要收集日志以获取帮助和报告问题,请参阅 [需要帮助](help/support.md)。 - -## `[log]` 部分 - -在 Gitea 中,日志设施的配置在 `[log]` 部分及其子部分。 - -在顶层的 `[log]` 部分,可以放置以下配置项: - -- `ROOT_PATH`:(默认值:**%(GITEA_WORK_DIR)/log**):日志文件的基本路径。 -- `MODE`:(默认值:**console**):要用于默认日志记录器的日志输出列表。 -- `LEVEL`:(默认值:**Info**):要持久化的最严重的日志事件,不区分大小写。可能的值为:`Trace`、`Debug`、`Info`、`Warn`、`Error`、`Fatal`。 -- `STACKTRACE_LEVEL`:(默认值:**None**):对于此类及更严重的事件,将在记录时打印堆栈跟踪。 - -它还可以包含以下子日志记录器: - -- `logger.router.MODE`:(默认值:**,**):用于路由器日志记录器的日志输出列表。 -- `logger.access.MODE`:(默认值:**_empty_**):用于访问日志记录器的日志输出列表。默认情况下,访问日志记录器被禁用。 -- `logger.xorm.MODE`:(默认值:**,**):用于 XORM 日志记录器的日志输出列表。 - -将子日志记录器的模式设置为逗号(`,`)表示使用默认的全局 `MODE`。 - -## 快速示例 - -### 默认(空)配置 - -空配置等同于默认配置: - -```ini -[log] -ROOT_PATH = %(GITEA_WORK_DIR)/log -MODE = console -LEVEL = Info -STACKTRACE_LEVEL = None -logger.router.MODE = , -logger.xorm.MODE = , -logger.access.MODE = - -; 这是“控制台”模式的配置选项(由上面的 MODE=console 使用) -[log.console] -MODE = console -FLAGS = stdflags -PREFIX = -COLORIZE = true -``` - -这等同于将所有日志发送到控制台,并将默认的 Golang 日志也发送到控制台日志中。 - -这只是一个示例,默认情况下不需要将其写入配置文件中。 - -### 禁用路由日志并将一些访问日志记录到文件中 - -禁用路由日志,将访问日志(>=Warn)记录到 `access.log` 中: - -```ini -[log] -logger.router.MODE = -logger.access.MODE = access-file - -[log.access-file] -MODE = file -LEVEL = Warn -FILE_NAME = access.log -``` - -### 为不同的模式设置不同的日志级别 - -将默认日志(>=Warn)记录到 `gitea.log` 中,将错误日志记录到 `file-error.log` 中: - -```ini -[log] -LEVEL = Warn -MODE = file, file-error - -; 默认情况下,"file" 模式会将日志记录到 %(log.ROOT_PATH)/gitea.log,因此我们不需要设置它 -; [log.file] - -[log.file-error] -LEVEL = Error -FILE_NAME = file-error.log -``` - -## 日志输出(模式和写入器) - -Gitea 提供以下日志写入器: - -- `console` - 输出日志到 `stdout`(或 `stderr`,如果已在配置中设置) -- `file` - 输出日志到文件 -- `conn` - 输出日志到套接字(网络或 Unix 套接字) - -### 公共配置 - -某些配置适用于所有日志输出模式: - -- `MODE` 是日志输出写入器的模式。它将默认为 ini 部分的模式名称。因此,`[log.console]` 将默认为 `MODE = console`。 -- `LEVEL` 是此输出将记录的最低日志级别。 -- `STACKTRACE_LEVEL` 是此输出将打印堆栈跟踪的最低日志级别。 -- `COLORIZE` 对于 `console`,默认为 `true`,否则默认为 `false`。 - -#### `EXPRESSION` - -`EXPRESSION` 表示日志事件必须匹配才能被输出写入器记录的正则表达式。 -日志消息(去除颜色)或 `longfilename:linenumber:functionname` 必须匹配其中之一。 -注意:整个消息或字符串不需要完全匹配。 - -请注意,此表达式将在写入器的 goroutine 中运行,而不是在日志事件的 goroutine 中运行。 - -#### `FLAGS` - -`FLAGS` 表示在每条消息之前打印的前置日志上下文信息。 -它是一个逗号分隔的字符串集。值的顺序无关紧要。 - -默认值为 `stdflags`(= `date,time,medfile,shortfuncname,levelinitial`)。 - -可能的值为: - -- `none` 或 `,` - 无标志。 -- `date` - 当地时区的日期:`2009/01/23`。 -- `time` - 当地时区的时间:`01:23:23`。 -- `microseconds` - 微秒精度:`01:23:23.123123`。假定有时间。 -- `longfile` - 完整的文件名和行号:`/a/b/c/d.go:23`。 -- `shortfile` - 文件名的最后一个部分和行号:`d.go:23`。 -- `funcname` - 调用者的函数名:`runtime.Caller()`。 -- `shortfuncname` - 函数名的最后一部分。覆盖 `funcname`。 -- `utc` - 如果设置了日期或时间,则使用 UTC 而不是本地时区。 -- `levelinitial` - 提供的级别的初始字符,放在方括号内,例如 `[I]` 表示 info。 -- `level` - 在方括号内的级别,例如 `[INFO]`。 -- `gopid` - 上下文的 Goroutine-PID。 -- `medfile` - 文件名的最后 20 个字符 - 相当于 `shortfile,longfile`。 -- `stdflags` - 相当于 `date,time,medfile,shortfuncname,levelinitial`。 - -### Console 模式 - -在此模式下,日志记录器将将日志消息转发到 Gitea 进程附加的 stdout 和 stderr 流。 - -对于 console 模式的日志记录器,如果不在 Windows 上,或者 Windows 终端可以设置为 ANSI 模式,或者是 cygwin 或 Msys 管道,则 `COLORIZE` 默认为 `true`。 - -设置: - -- `STDERR`:**false**:日志记录器是否应将日志打印到 `stderr` 而不是 `stdout`。 - -### File 模式 - -在此模式下,日志记录器将将日志消息保存到文件中。 - -设置: - -- `FILE_NAME`:要将日志事件写入的文件,相对于 `ROOT_PATH`,默认为 `%(ROOT_PATH)/gitea.log`。异常情况:访问日志默认为 `%(ROOT_PATH)/access.log`。 -- `MAX_SIZE_SHIFT`:**28**:单个文件的最大大小位移。28 表示 256Mb。详细信息见下文。 -- `LOG_ROTATE` **true**:是否轮转日志文件。 -- `DAILY_ROTATE`:**true**:是否每天旋转日志。 -- `MAX_DAYS`:**7**:在此天数之后删除旋转的日志文件。 -- `COMPRESS`:**true**:默认情况下是否使用 gzip 压缩旧的日志文件。 -- `COMPRESSION_LEVEL`:**-1**:压缩级别。详细信息见下文。 - -`MAX_SIZE_SHIFT` 通过将给定次数左移 1 (`1 << x`) 来定义文件的最大大小。 -在 v1.17.3 版本时的确切行为可以在[这里](https://github.com/go-gitea/gitea/blob/v1.17.3/modules/setting/log.go#L185)中查看。 - -`COMPRESSION_LEVEL` 的有用值范围从 1 到(包括)9,其中较高的数字表示更好的压缩。 -请注意,更好的压缩可能会带来更高的资源使用。 -必须在前面加上 `-` 符号。 - -### Conn 模式 - -在此模式下,日志记录器将通过网络套接字发送日志消息。 - -设置: - -- `ADDR`:**:7020**:设置要连接的地址。 -- `PROTOCOL`:**tcp**:设置协议,可以是 "tcp"、"unix" 或 "udp"。 -- `RECONNECT`:**false**:在连接丢失时尝试重新连接。 -- `RECONNECT_ON_MSG`:**false**:为每条消息重新连接主机。 - -### "Router" 日志记录器 - -当 Gitea 的路由处理程序工作时,Router 日志记录器记录以下消息类型: - -- `started` 消息将以 TRACE 级别记录 -- `polling`/`completed` 路由将以 INFO 级别记录。异常情况:"/assets" 静态资源请求也会以 TRACE 级别记录。 -- `slow` 路由将以 WARN 级别记录 -- `failed` 路由将以 WARN 级别记录 - -### "XORM" 日志记录器 - -为了使 XORM 输出 SQL 日志,还应将 `[database]` 部分中的 `LOG_SQL` 设置为 `true`。 - -### "Access" 日志记录器 - -"Access" 日志记录器是自 Gitea 1.9 版本以来的新日志记录器。它提供了符合 NCSA Common Log 标准的日志格式。虽然它具有高度可配置性,但在更改其模板时应谨慎。此日志记录器的主要好处是,Gitea 现在可以使用标准日志格式记录访问日志,因此可以使用标准工具进行分析。 - -您可以通过使用 `logger.access.MODE = ...` 来启用此日志记录器。 - -如果需要,可以通过更改 `ACCESS_LOG_TEMPLATE` 的值来更改 "Access" 日志记录器的格式。 - -请注意,访问日志记录器将以 `INFO` 级别记录,将此日志记录器的 `LEVEL` 设置为 `WARN` 或更高级别将导致不记录访问日志。 - -#### ACCESS_LOG_TEMPLATE - -此值表示一个 Go 模板。其默认值为 - -```tmpl -{{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"` -``` - -模板接收以下选项: - -- `Ctx` 是 `context.Context` -- `Identity` 是 `SignedUserName`,如果用户未登录,则为 "-" -- `Start` 是请求的开始时间 -- `ResponseWriter` 是 `http.ResponseWriter` - -更改此模板时必须小心,因为它在标准的 panic 恢复陷阱之外运行。此模板应该尽可能简单,因为它会为每个请求运行一次。 - -## 释放和重新打开、暂停和恢复日志记录 - -如果您在 Unix 上运行,您可能希望释放和重新打开日志以使用 `logrotate` 或其他工具。 -可以通过向运行中的进程发送 `SIGUSR1` 信号或运行 `gitea manager logging release-and-reopen` 命令来强制 Gitea 释放并重新打开其日志文件和连接。 - -或者,您可能希望暂停和恢复日志记录 - 可以通过使用 `gitea manager logging pause` 和 `gitea manager logging resume` 命令来实现。请注意,当日志记录暂停时,低于 INFO 级别的日志事件将不会存储,并且只会存储有限数量的事件。在暂停时,日志记录可能会阻塞,尽管是暂时性的,但会大大减慢 Gitea 的运行速度,因此建议仅暂停很短的时间。 - -### 在 Gitea 运行时添加和删除日志记录 - -可以使用 `gitea manager logging add` 和 `remove` 子命令在 Gitea 运行时添加和删除日志记录。 -此功能只能调整正在运行的日志系统,不能用于启动未初始化的访问或路由日志记录器。如果您希望启动这些系统,建议调整 app.ini 并(优雅地)重新启动 Gitea 服务。 - -这些命令的主要目的是在运行中的系统上轻松添加临时日志记录器,以便调查问题,因为重新启动可能会导致问题消失。 - -## 使用 `logrotate` 而不是内置的日志轮转 - -Gitea 包含内置的日志轮转功能,对于大多数部署来说应该已经足够了。但是,如果您想使用 `logrotate` 工具: - -- 在 `app.ini` 中将 `LOG_ROTATE` 设置为 `false`,禁用内置的日志轮转。 -- 安装 `logrotate`。 -- 根据部署要求配置 `logrotate`,有关配置语法细节,请参阅 `man 8 logrotate`。 - 在 `postrotate/endscript` 块中通过 `kill -USR1` 或 `kill -10` 向 `gitea` 进程本身发送 `USR1` 信号, - 或者运行 `gitea manager logging release-and-reopen`(使用适当的环境设置)。 - 确保配置适用于由 Gitea 日志记录器生成的所有文件,如上述部分所述。 -- 始终使用 `logrotate /etc/logrotate.conf --debug` 来测试您的配置。 -- 如果您正在使用 Docker 并从容器外部运行,您可以使用 - `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` - 或 `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'`,或直接向 Gitea 进程本身发送 `USR1` 信号。 - -下一个 `logrotate` 作业将包括您的配置,因此不需要重新启动。 -您还可以立即使用 `logrotate /etc/logrotate.conf --force` 重新加载 `logrotate`。 diff --git a/docs/content/administration/mail-templates.en-us.md b/docs/content/administration/mail-templates.en-us.md deleted file mode 100644 index 8e4e416e8d..0000000000 --- a/docs/content/administration/mail-templates.en-us.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -date: "2019-10-23T17:00:00-03:00" -title: "Mail templates" -slug: "mail-templates" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /en-us/mail-templates -menu: - sidebar: - parent: "administration" - name: "Mail templates" - sidebar_position: 45 - identifier: "mail-templates" ---- - -# Mail templates - -To craft the e-mail subject and contents for certain operations, Gitea can be customized by using templates. The templates -for these functions are located under the [`custom` directory](administration/customizing-gitea.md). -Gitea has an internal template that serves as default in case there's no custom alternative. - -Custom templates are loaded when Gitea starts. Changes made to them are not recognized until Gitea is restarted again. - -## Mail notifications supporting templates - -Currently, the following notification events make use of templates: - -| Action name | Usage | -| ----------- | ------------------------------------------------------------------------------------------------------------ | -| `new` | A new issue or pull request was created. | -| `comment` | A new comment was created in an existing issue or pull request. | -| `close` | An issue or pull request was closed. | -| `reopen` | An issue or pull request was reopened. | -| `review` | The head comment of a review in a pull request. | -| `approve` | The head comment of a approving review for a pull request. | -| `reject` | The head comment of a review requesting changes for a pull request. | -| `code` | A single comment on the code of a pull request. | -| `assigned` | User was assigned to an issue or pull request. | -| `default` | Any action not included in the above categories, or when the corresponding category template is not present. | - -The path for the template of a particular message type is: - -```sh -custom/templates/mail/{action type}/{action name}.tmpl -``` - -Where `{action type}` is one of `issue` or `pull` (for pull requests), and `{action name}` is one of the names listed above. - -For example, the specific template for a mail regarding a comment in a pull request is: - -```sh -custom/templates/mail/pull/comment.tmpl -``` - -However, creating templates for each and every action type/name combination is not required. -A fallback system is used to choose the appropriate template for an event. The _first existing_ -template on this list is used: - -- The specific template for the desired **action type** and **action name**. -- The template for action type `issue` and the desired **action name**. -- The template for the desired **action type**, action name `default`. -- The template for action type `issue`, action name `default`. - -The only mandatory template is action type `issue`, action name `default`, which is already embedded in Gitea -unless it's overridden by the user in the `custom` directory. - -## Template syntax - -Mail templates are UTF-8 encoded text files that need to follow one of the following formats: - -``` -Text and macros for the subject line ------------- -Text and macros for the mail body -``` - -or - -``` -Text and macros for the mail body -``` - -Specifying a _subject_ section is optional (and therefore also the dash line separator). When used, the separator between -_subject_ and _mail body_ templates requires at least three dashes; no other characters are allowed in the separator line. - -_Subject_ and _mail body_ are parsed by [Golang's template engine](https://go.dev/pkg/text/template/) and -are provided with a _metadata context_ assembled for each notification. The context contains the following elements: - -| Name | Type | Available | Usage | -| ------------------ | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `.FallbackSubject` | string | Always | A default subject line. See Below. | -| `.Subject` | string | Only in body | The _subject_, once resolved. | -| `.Body` | string | Always | The message of the issue, pull request or comment, parsed from Markdown into HTML and sanitized. Do not confuse with the _mail body_. | -| `.Link` | string | Always | The address of the originating issue, pull request or comment. | -| `.Issue` | models.Issue | Always | The issue (or pull request) originating the notification. To get data specific to a pull request (e.g. `HasMerged`), `.Issue.PullRequest` can be used, but care should be taken as this field will be `nil` if the issue is _not_ a pull request. | -| `.Comment` | models.Comment | If applicable | If the notification is from a comment added to an issue or pull request, this will contain the information about the comment. | -| `.IsPull` | bool | Always | `true` if the mail notification is associated with a pull request (i.e. `.Issue.PullRequest` is not `nil`). | -| `.Repo` | string | Always | Name of the repository, including owner name (e.g. `mike/stuff`) | -| `.User` | models.User | Always | Owner of the repository from which the event originated. To get the user name (e.g. `mike`),`.User.Name` can be used. | -| `.Doer` | models.User | Always | User that executed the action triggering the notification event. To get the user name (e.g. `rhonda`), `.Doer.Name` can be used. | -| `.IsMention` | bool | Always | `true` if this notification was only generated because the user was mentioned in the comment, while not being subscribed to the source. It will be `false` if the recipient was subscribed to the issue or repository. | -| `.SubjectPrefix` | string | Always | `Re: ` if the notification is about other than issue or pull request creation; otherwise an empty string. | -| `.ActionType` | string | Always | `"issue"` or `"pull"`. Will correspond to the actual _action type_ independently of which template was selected. | -| `.ActionName` | string | Always | It will be one of the action types described above (`new`, `comment`, etc.), and will correspond to the actual _action name_ independently of which template was selected. | -| `.ReviewComments` | []models.Comment | Always | List of code comments in a review. The comment text will be in `.RenderedContent` and the referenced code will be in `.Patch`. | - -All names are case sensitive. - -### The _subject_ part of the template - -The template engine used for the mail _subject_ is golang's [`text/template`](https://go.dev/pkg/text/template/). -Please refer to the linked documentation for details about its syntax. - -The _subject_ is built using the following steps: - -- A template is selected according to the type of notification and to what templates are present. -- The template is parsed and resolved (e.g. `{{.Issue.Index}}` is converted to the number of the issue - or pull request). -- All space-like characters (e.g. `TAB`, `LF`, etc.) are converted to normal spaces. -- All leading, trailing and redundant spaces are removed. -- The string is truncated to its first 256 runes (characters). - -If the end result is an empty string, **or** no subject template was available (i.e. the selected template -did not include a subject part), Gitea's **internal default** will be used. - -The internal default (fallback) subject is the equivalent of: - -```sh -{{.SubjectPrefix}}[{{.Repo}}] {{.Issue.Title}} (#{{.Issue.Index}}) -``` - -For example: `Re: [mike/stuff] New color palette (#38)` - -Gitea's default subject can also be found in the template _metadata_ as `.FallbackSubject` from any of -the two templates, even if a valid subject template is present. - -### The _mail body_ part of the template - -The template engine used for the _mail body_ is golang's [`html/template`](https://go.dev/pkg/html/template/). -Please refer to the linked documentation for details about its syntax. - -The _mail body_ is parsed after the mail subject, so there is an additional _metadata_ field which is -the actual rendered subject, after all considerations. - -The expected result is HTML (including structural elements like`<html>`, `<body>`, etc.). Styling -through `<style>` blocks, `class` and `style` attributes is possible. However, `html/template` -does some [automatic escaping](https://go.dev/pkg/html/template/#hdr-Contexts) that should be considered. - -Attachments (such as images or external style sheets) are not supported. However, other templates can -be referenced too, for example to provide the contents of a `<style>` element in a centralized fashion. -The external template must be placed under `custom/mail` and referenced relative to that directory. -For example, `custom/mail/styles/base.tmpl` can be included using `{{template styles/base}}`. - -The mail is sent with `Content-Type: multipart/alternative`, so the body is sent in both HTML -and text formats. The latter is obtained by stripping the HTML markup. - -## Troubleshooting - -How a mail is rendered is directly dependent on the capabilities of the mail application. Many mail -clients don't even support HTML, so they show the text version included in the generated mail. - -If the template fails to render, it will be noticed only at the moment the mail is sent. -A default subject is used if the subject template fails, and whatever was rendered successfully -from the _mail body_ is used, disregarding the rest. - -Please check [Gitea's logs](administration/logging-config.md) for error messages in case of trouble. - -## Example - -`custom/templates/mail/issue/default.tmpl`: - -```html -[{{.Repo}}] @{{.Doer.Name}} -{{if eq .ActionName "new"}} - created -{{else if eq .ActionName "comment"}} - commented on -{{else if eq .ActionName "close"}} - closed -{{else if eq .ActionName "reopen"}} - reopened -{{else}} - updated -{{end}} -{{if eq .ActionType "issue"}} - issue -{{else}} - pull request -{{end}} -#{{.Issue.Index}}: {{.Issue.Title}} ------------- -<!DOCTYPE html> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <title>{{.Subject}}</title> -</head> - -<body> - {{if .IsMention}} - <p> - You are receiving this because @{{.Doer.Name}} mentioned you. - </p> - {{end}} - <p> - <p> - <a href="{{AppUrl}}/{{.Doer.LowerName}}">@{{.Doer.Name}}</a> - {{if not (eq .Doer.FullName "")}} - ({{.Doer.FullName}}) - {{end}} - {{if eq .ActionName "new"}} - created - {{else if eq .ActionName "close"}} - closed - {{else if eq .ActionName "reopen"}} - reopened - {{else}} - updated - {{end}} - <a href="{{.Link}}">{{.Repo}}#{{.Issue.Index}}</a>. - </p> - {{if not (eq .Body "")}} - <h3>Message content</h3> - <hr> - {{.Body}} - {{end}} - </p> - <hr> - <p> - <a href="{{.Link}}">View it on Gitea</a>. - </p> -</body> -</html> -``` - -This template produces something along these lines: - -### Subject - -> [mike/stuff] @rhonda commented on pull request #38: New color palette - -### Mail body - -> [@rhonda](#) (Rhonda Myers) updated [mike/stuff#38](#). -> -> #### Message content -> -> \_********************************\_******************************** -> -> Mike, I think we should tone down the blues a little. -> \_********************************\_******************************** -> -> [View it on Gitea](#). - -## Advanced - -The template system contains several functions that can be used to further process and format -the messages. Here's a list of some of them: - -| Name | Parameters | Available | Usage | -| ---------------- | ----------- | --------- | ------------------------------------------------------------------- | -| `AppUrl` | - | Any | Gitea's URL | -| `AppName` | - | Any | Set from `app.ini`, usually "Gitea" | -| `AppDomain` | - | Any | Gitea's host name | -| `EllipsisString` | string, int | Any | Truncates a string to the specified length; adds ellipsis as needed | -| `SanitizeHTML` | string | Body only | Sanitizes text by removing any dangerous HTML tags from it | -| `SafeHTML` | string | Body only | Takes the input as HTML, can be used for outputing raw HTML content | - -These are _functions_, not metadata, so they have to be used: - -```html -Like this: {{SanitizeHTML "Escape<my>text"}} -Or this: {{"Escape<my>text" | SanitizeHTML}} -Or this: {{AppUrl}} -But not like this: {{.AppUrl}} -``` diff --git a/docs/content/administration/mail-templates.zh-cn.md b/docs/content/administration/mail-templates.zh-cn.md deleted file mode 100644 index 3c7c2a9397..0000000000 --- a/docs/content/administration/mail-templates.zh-cn.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "邮件模板" -slug: "mail-templates" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /zh-cn/mail-templates -menu: - sidebar: - parent: "administration" - name: "邮件模板" - sidebar_position: 45 - identifier: "mail-templates" ---- - -# 邮件模板 - -为了定制特定操作的电子邮件主题和内容,可以使用模板来自定义 Gitea。这些功能的模板位于 [`custom` 目录](administration/customizing-gitea.md) 下。 -如果没有自定义的替代方案,Gitea 将使用内部模板作为默认模板。 - -自定义模板在 Gitea 启动时加载。对它们的更改在 Gitea 重新启动之前不会被识别。 - -## 支持模板的邮件通知 - -目前,以下通知事件使用模板: - -| 操作名称 | 用途 | -| ----------- | ------------------------------------------------------------------------------------------------------------ | -| `new` | 创建了新的工单或合并请求。 | -| `comment` | 在现有工单或合并请求中创建了新的评论。 | -| `close` | 关闭了工单或合并请求。 | -| `reopen` | 重新打开了工单或合并请求。 | -| `review` | 在合并请求中进行审查的首要评论。 | -| `approve` | 对合并请求进行批准的首要评论。 | -| `reject` | 对合并请求提出更改请求的审查的首要评论。 | -| `code` | 关于合并请求的代码的单个评论。 | -| `assigned` | 用户被分配到工单或合并请求。 | -| `default` | 未包括在上述类别中的任何操作,或者当对应类别的模板不存在时使用的模板。 | - -特定消息类型的模板路径为: - -```sh -custom/templates/mail/{操作类型}/{操作名称}.tmpl -``` - -其中 `{操作类型}` 是 `issue` 或 `pull`(针对合并请求),`{操作名称}` 是上述列出的操作名称之一。 - -例如,有关合并请求中的评论的电子邮件的特定模板是: - -```sh -custom/templates/mail/pull/comment.tmpl -``` - -然而,并不需要为每个操作类型/名称组合创建模板。 -使用回退系统来选择适当的模板。在此列表中,将使用 _第一个存在的_ 模板: - -- 所需**操作类型**和**操作名称**的特定模板。 -- 操作类型为 `issue` 和所需**操作名称**的模板。 -- 所需**操作类型**和操作名称为 `default` 的模板。 -- 操作类型为` issue` 和操作名称为 `default` 的模板。 - -唯一必需的模板是操作类型为 `issue` 操作名称为 `default` 的模板,除非用户在 `custom` 目录中覆盖了它。 - -## 模板语法 - -邮件模板是 UTF-8 编码的文本文件,需要遵循以下格式之一: - -``` -用于主题行的文本和宏 ------------- -用于邮件正文的文本和宏 -``` - -或者 - -``` -用于邮件正文的文本和宏 -``` - -指定 _主题_ 部分是可选的(因此也是虚线分隔符)。在使用时,_主题_ 和 _邮件正文_ 模板之间的分隔符需要至少三个虚线;分隔符行中不允许使用其他字符。 - -_主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://go.dev/pkg/text/template/) 解析,并提供了为每个通知组装的 _元数据上下文_。上下文包含以下元素: - -| 名称 | 类型 | 可用性 | 用途 | -| -------------------- | ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `.FallbackSubject` | string | 始终可用 | 默认主题行。参见下文。 | -| `.Subject` | string | 仅在正文中可用 | 解析后的 _主题_。 | -| `.Body` | string | 始终可用 | 工单、合并请求或评论的消息,从 Markdown 解析为 HTML 并进行了清理。请勿与 _邮件正文_ 混淆。 | -| `.Link` | string | 始终可用 | 源工单、合并请求或评论的地址。 | -| `.Issue` | models.Issue | 始终可用 | 产生通知的工单(或合并请求)。要获取特定于合并请求的数据(例如 `HasMerged`),可以使用 `.Issue.PullRequest`,但需要注意,如果工单 _不是_ 合并请求,则该字段将为 `nil`。 | -| `.Comment` | models.Comment | 如果适用 | 如果通知是针对添加到工单或合并请求的评论,则其中包含有关评论的信息。 | -| `.IsPull` | bool | 始终可用 | 如果邮件通知与合并请求关联(即 `.Issue.PullRequest` 不为 `nil` ),则为 `true`。 | -| `.Repo` | string | 始终可用 | 仓库的名称,包括所有者名称(例如 `mike/stuff`) | -| `.User` | models.User | 始终可用 | 事件来源仓库的所有者。要获取用户名(例如 `mike`),可以使用 `.User.Name`。 | -| `.Doer` | models.User | 始终可用 | 执行触发通知事件的操作的用户。要获取用户名(例如 `rhonda`),可以使用 `.Doer.Name`。 | -| `.IsMention` | bool | 始终可用 | 如果此通知仅是因为在评论中提到了用户而生成的,并且收件人未订阅源,则为 `true`。如果收件人已订阅工单或仓库,则为 `false`。 | -| `.SubjectPrefix` | string | 始终可用 | 如果通知是关于除工单或合并请求创建之外的其他内容,则为 `Re:`;否则为空字符串。 | -| `.ActionType` | string | 始终可用 | `"issue"` 或 `"pull"`。它将与实际的 _操作类型_ 对应,与选择的模板无关。 | -| `.ActionName` | string | 始终可用 | 它将是上述操作类型之一(`new` ,`comment` 等),并与选择的模板对应。 | -| `.ReviewComments` | []models.Comment | 始终可用 | 审查中的代码评论列表。评论文本将在 `.RenderedContent` 中,引用的代码将在 `.Patch` 中。 | - -所有名称区分大小写。 - -### 模板中的主题部分 - -用于邮件主题的模板引擎是 Golang 的 [`text/template`](https://go.dev/pkg/text/template/)。 -有关语法的详细信息,请参阅链接的文档。 - -主题构建的步骤如下: - -- 根据通知类型和可用的模板选择一个模板。 -- 解析并解析模板(例如,将 `{{.Issue.Index}}` 转换为工单或合并请求的编号)。 -- 将所有空格字符(例如 `TAB`,`LF` 等)转换为普通空格。 -- 删除所有前导、尾随和多余的空格。 -- 将字符串截断为前 256 个字母(字符)。 - -如果最终结果为空字符串,**或者**没有可用的主题模板(即所选模板不包含主题部分),将使用Gitea的**内部默认值**。 - -内部默认(回退)主题相当于: - -``` -{{.SubjectPrefix}}[{{.Repo}}] {{.Issue.Title}} (#{{.Issue.Index}}) -``` - -例如:`Re: [mike/stuff] New color palette (#38)` - -即使存在有效的主题模板,Gitea的默认主题也可以在模板的元数据中作为 `.FallbackSubject` 找到。 - -### 模板中的邮件正文部分 - -用于邮件正文的模板引擎是 Golang 的 [`html/template`](https://go.dev/pkg/html/template/)。 -有关语法的详细信息,请参阅链接的文档。 - -邮件正文在邮件主题之后进行解析,因此还有一个额外的 _元数据_ 字段,即在考虑所有情况之后实际呈现的主题。 - -期望的结果是 HTML(包括结构元素,如`<html>`,`<body>`等)。可以通过 `<style>` 块、`class` 和 `style` 属性进行样式设置。但是,`html/template` 会进行一些 [自动转义](https://go.dev/pkg/html/template/#hdr-Contexts),需要考虑这一点。 - -不支持附件(例如图像或外部样式表)。但是,也可以引用其他模板,例如以集中方式提供 `<style>` 元素的内容。外部模板必须放置在 `custom/mail` 下,并相对于该目录引用。例如,可以使用 `{{template styles/base}}` 包含 `custom/mail/styles/base.tmpl`。 - -邮件以 `Content-Type: multipart/alternative` 发送,因此正文以 HTML 和文本格式发送。通过剥离 HTML 标记来获取文本版本。 - -## 故障排除 - -邮件的呈现方式直接取决于邮件应用程序的功能。许多邮件客户端甚至不支持 HTML,因此显示生成邮件中包含的文本版本。 - -如果模板无法呈现,则只有在发送邮件时才会注意到。 -如果主题模板失败,将使用默认主题,如果从 _邮件正文_ 中成功呈现了任何内容,则将使用该内容,忽略其他内容。 - -如果遇到问题,请检查 [Gitea的日志](administration/logging-config.md) 以获取错误消息。 - -## 示例 - -`custom/templates/mail/issue/default.tmpl`: - -```html -[{{.Repo}}] @{{.Doer.Name}} -{{if eq .ActionName "new"}} - 创建了 -{{else if eq .ActionName "comment"}} - 评论了 -{{else if eq .ActionName "close"}} - 关闭了 -{{else if eq .ActionName "reopen"}} - 重新打开了 -{{else}} - 更新了 -{{end}} -{{if eq .ActionType "issue"}} - 工单 -{{else}} - 合并请求 -{{end}} -#{{.Issue.Index}}: {{.Issue.Title}} ------------- -<!DOCTYPE html> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <title>{{.Subject}}</title> -</head> - -<body> - {{if .IsMention}} - <p> - 您收到此邮件是因为 @{{.Doer.Name}} 提到了您。 - </p> - {{end}} - <p> - <p> - <a href="{{AppUrl}}/{{.Doer.LowerName}}">@{{.Doer.Name}}</a> - {{if not (eq .Doer.FullName "")}} - ({{.Doer.FullName}}) - {{end}} - {{if eq .ActionName "new"}} - 创建了 - {{else if eq .ActionName "close"}} - 关闭了 - {{else if eq .ActionName "reopen"}} - 重新打开了 - {{else}} - 更新了 - {{end}} - <a href="{{.Link}}">{{.Repo}}#{{.Issue.Index}}</a>。 - </p> - {{if not (eq .Body "")}} - <h3>消息内容:</h3> - <hr> - {{.Body}} - {{end}} - </p> - <hr> - <p> - <a href="{{.Link}}">在 Gitea 上查看</a>。 - </p> -</body> -</html> -``` - -该模板将生成以下内容: - -### 主题 - -> [mike/stuff] @rhonda 在合并请求 #38 上进行了评论:New color palette - -### 邮件正文 - -> [@rhonda](#)(Rhonda Myers)更新了 [mike/stuff#38](#)。 -> -> #### 消息内容 -> -> \_********************************\_******************************** -> -> Mike, I think we should tone down the blues a little. -> -> \_********************************\_******************************** -> -> [在 Gitea 上查看](#)。 - -## 高级用法 - -模板系统包含一些函数,可用于进一步处理和格式化消息。以下是其中一些函数的列表: - -| 函数名 | 参数 | 可用于 | 用法 | -|------------------| ----------- | ------------ | ------------------------------ | -| `AppUrl` | - | 任何地方 | Gitea 的 URL | -| `AppName` | - | 任何地方 | 从 `app.ini` 中设置,通常为 "Gitea" | -| `AppDomain` | - | 任何地方 | Gitea 的主机名 | -| `EllipsisString` | string, int | 任何地方 | 将字符串截断为指定长度;根据需要添加省略号 | -| `SanitizeHTML` | string | 仅正文部分 | 通过删除其中的危险 HTML 标签对文本进行清理 | -| `SafeHTML` | string | 仅正文部分 | 将输入作为 HTML 处理;可用于输出原始的 HTML 内容 | - -这些都是 _函数_,而不是元数据,因此必须按以下方式使用: - -```html -像这样使用: {{SanitizeHTML "Escape<my>text"}} -或者这样使用: {{"Escape<my>text" | SanitizeHTML}} -或者这样使用: {{AppUrl}} -但不要像这样使用: {{.AppUrl}} -``` diff --git a/docs/content/administration/repo-indexer.en-us.md b/docs/content/administration/repo-indexer.en-us.md deleted file mode 100644 index aa82222911..0000000000 --- a/docs/content/administration/repo-indexer.en-us.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -date: "2019-09-06T01:35:00-03:00" -title: "Repository indexer" -slug: "repo-indexer" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /en-us/repo-indexer -menu: - sidebar: - parent: "administration" - name: "Repository indexer" - sidebar_position: 45 - identifier: "repo-indexer" ---- - -# Repository indexer - -## Builtin repository code search without indexer - -Users could do repository-level code search without setting up a repository indexer. -The builtin code search is based on the `git grep` command, which is fast and efficient for small repositories. -Better code search support could be achieved by setting up the repository indexer. - -## Setting up the repository indexer - -Gitea can search through the files of the repositories by enabling this function in your [`app.ini`](administration/config-cheat-sheet.md): - -```ini -[indexer] -; ... -REPO_INDEXER_ENABLED = true -REPO_INDEXER_PATH = indexers/repos.bleve -MAX_FILE_SIZE = 1048576 -REPO_INDEXER_INCLUDE = -REPO_INDEXER_EXCLUDE = resources/bin/** -``` - -Please bear in mind that indexing the contents can consume a lot of system resources, especially when the index is created for the first time or globally updated (e.g. after upgrading Gitea). - -### Choosing the files for indexing by size - -The `MAX_FILE_SIZE` option will make the indexer skip all files larger than the specified value. - -### Choosing the files for indexing by path - -Gitea applies glob pattern matching from the [`gobwas/glob` library](https://github.com/gobwas/glob) to choose which files will be included in the index. - -Limiting the list of files prevents the indexes from becoming polluted with derived or irrelevant files (e.g. lss, sym, map, etc.), so the search results are more relevant. It can also help reduce the index size. - -`REPO_INDEXER_EXCLUDE_VENDORED` (default: true) excludes vendored files from index. - -`REPO_INDEXER_INCLUDE` (default: empty) is a comma separated list of glob patterns to **include** in the index. An empty list means "_include all files_". -`REPO_INDEXER_EXCLUDE` (default: empty) is a comma separated list of glob patterns to **exclude** from the index. Files that match this list will not be indexed. `REPO_INDEXER_EXCLUDE` takes precedence over `REPO_INDEXER_INCLUDE`. - -Pattern matching works as follows: - -- To match all files with a `.txt` extension no matter what directory, use `**.txt`. -- To match all files with a `.txt` extension _only at the root level of the repository_, use `*.txt`. -- To match all files inside `resources/bin` and below, use `resources/bin/**`. -- To match all files _immediately inside_ `resources/bin`, use `resources/bin/*`. -- To match all files named `Makefile`, use `**Makefile`. -- Matching a directory has no effect; the pattern `resources/bin` will not include/exclude files inside that directory; `resources/bin/**` will. -- All files and patterns are normalized to lower case, so `**Makefile`, `**makefile` and `**MAKEFILE` are equivalent. diff --git a/docs/content/administration/repo-indexer.zh-cn.md b/docs/content/administration/repo-indexer.zh-cn.md deleted file mode 100644 index d70a617ae1..0000000000 --- a/docs/content/administration/repo-indexer.zh-cn.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "仓库索引器" -slug: "repo-indexer" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /zh-cn/repo-indexer -menu: - sidebar: - parent: "administration" - name: "仓库索引器" - sidebar_position: 45 - identifier: "repo-indexer" ---- - -# 仓库索引器 - -## 设置仓库索引器 - -通过在您的 [`app.ini`](administration/config-cheat-sheet.md) 中启用此功能,Gitea 可以通过仓库的文件进行搜索: - -```ini -[indexer] -; ... -REPO_INDEXER_ENABLED = true -REPO_INDEXER_PATH = indexers/repos.bleve -MAX_FILE_SIZE = 1048576 -REPO_INDEXER_INCLUDE = -REPO_INDEXER_EXCLUDE = resources/bin/** -``` - -请记住,索引内容可能会消耗大量系统资源,特别是在首次创建索引或全局更新索引时(例如升级 Gitea 之后)。 - -### 按大小选择要索引的文件 - -`MAX_FILE_SIZE` 选项将使索引器跳过所有大于指定值的文件。 - -### 按路径选择要索引的文件 - -Gitea使用 [`gobwas/glob` 库](https://github.com/gobwas/glob) 中的 glob 模式匹配来选择要包含在索引中的文件。 - -限制文件列表可以防止索引被派生或无关的文件(例如 lss、sym、map 等)污染,从而使搜索结果更相关。这还有助于减小索引的大小。 - -`REPO_INDEXER_EXCLUDE_VENDORED`(默认值为 true)将排除供应商文件不包含在索引中。 - -`REPO_INDEXER_INCLUDE`(默认值为空)是一个逗号分隔的 glob 模式列表,用于在索引中**包含**的文件。空列表表示“_包含所有文件_”。 -`REPO_INDEXER_EXCLUDE`(默认值为空)是一个逗号分隔的 glob 模式列表,用于从索引中**排除**的文件。与该列表匹配的文件将不会被索引。`REPO_INDEXER_EXCLUDE` 优先于 `REPO_INDEXER_INCLUDE`。 - -模式匹配工作方式如下: - -- 要匹配所有带有 `.txt` 扩展名的文件,无论在哪个目录中,请使用 `**.txt`。 -- 要匹配仅在仓库的根级别中具有 `.txt` 扩展名的所有文件,请使用 `*.txt`。 -- 要匹配 `resources/bin` 目录及其子目录中的所有文件,请使用 `resources/bin/**`。 -- 要匹配位于 `resources/bin` 目录下的所有文件,请使用 `resources/bin/*`。 -- 要匹配所有名为 `Makefile` 的文件,请使用 `**Makefile`。 -- 匹配目录没有效果;模式 `resources/bin` 不会包含/排除该目录中的文件;`resources/bin/**` 会。 -- 所有文件和模式都规范化为小写,因此 `**Makefile`、`**makefile` 和 `**MAKEFILE` 是等效的。 diff --git a/docs/content/administration/reverse-proxies.en-us.md b/docs/content/administration/reverse-proxies.en-us.md deleted file mode 100644 index dff58c10eb..0000000000 --- a/docs/content/administration/reverse-proxies.en-us.md +++ /dev/null @@ -1,394 +0,0 @@ ---- -date: "2018-05-22T11:00:00+00:00" -title: "Reverse Proxies" -slug: "reverse-proxies" -sidebar_position: 16 -toc: false -draft: false -aliases: - - /en-us/reverse-proxies -menu: - sidebar: - parent: "administration" - name: "Reverse Proxies" - sidebar_position: 16 - identifier: "reverse-proxies" ---- - -# Reverse Proxies - -## General configuration - -1. Set `[server] ROOT_URL = https://git.example.com/` in your `app.ini` file. -2. Make the reverse-proxy pass `https://git.example.com/foo` to `http://gitea:3000/foo`. -3. Make sure the reverse-proxy does not decode the URI. The request `https://git.example.com/a%2Fb` should be passed as `http://gitea:3000/a%2Fb`. -4. Make sure `Host` and `X-Fowarded-Proto` headers are correctly passed to Gitea to make Gitea see the real URL being visited. - -### Use a sub-path - -Usually it's **not recommended** to put Gitea in a sub-path, it's not widely used and may have some issues in rare cases. - -To make Gitea work with a sub-path (eg: `https://common.example.com/gitea/`), -there are some extra requirements besides the general configuration above: - -1. Use `[server] ROOT_URL = https://common.example.com/gitea/` in your `app.ini` file. -2. Make the reverse-proxy pass `https://common.example.com/gitea/foo` to `http://gitea:3000/foo`. -3. The container registry requires a fixed sub-path `/v2` at the root level which must be configured: - - Make the reverse-proxy pass `https://common.example.com/v2` to `http://gitea:3000/v2`. - - Make sure the URI and headers are also correctly passed (see the general configuration above). - -## Nginx - -If you want Nginx to serve your Gitea instance, add the following `server` section to the `http` section of `nginx.conf`. - -Make sure `client_max_body_size` is large enough, otherwise there would be "413 Request Entity Too Large" error when uploading large files. - -```nginx -server { - ... - location / { - client_max_body_size 512M; - proxy_pass http://localhost:3000; - proxy_set_header Connection $http_connection; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} -``` - -## Nginx with a sub-path - -In case you already have a site, and you want Gitea to share the domain name, -you can setup Nginx to serve Gitea under a sub-path by adding the following `server` section -into the `http` section of `nginx.conf`: - -```nginx -server { - ... - location ~ ^/(gitea|v2)($|/) { - client_max_body_size 512M; - - # make nginx use unescaped URI, keep "%2F" as-is, remove the "/gitea" sub-path prefix, pass "/v2" as-is. - rewrite ^ $request_uri; - rewrite ^(/gitea)?(/.*) $2 break; - proxy_pass http://127.0.0.1:3000$uri; - - # other common HTTP headers, see the "Nginx" config section above - proxy_set_header Connection $http_connection; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} -``` - -Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/gitea/` correctly in your configuration. - -## Nginx and serve static resources directly - -We can tune the performance in splitting requests into categories static and dynamic. - -CSS files, JavaScript files, images and web fonts are static content. -The front page, a repository view or issue list is dynamic content. - -Nginx can serve static resources directly and proxy only the dynamic requests to Gitea. -Nginx is optimized for serving static content, while the proxying of large responses might be the opposite of that -(see [https://serverfault.com/q/587386](https://serverfault.com/q/587386)). - -Download a snapshot of the Gitea source repository to `/path/to/gitea/`. -After this, run `make frontend` in the repository directory to generate the static resources. We are only interested in the `public/` directory for this task, so you can delete the rest. -(You will need to have [Node with npm](https://nodejs.org/en/download/) and `make` installed to generate the static resources) - -Depending on the scale of your user base, you might want to split the traffic to two distinct servers, -or use a cdn for the static files. - -### Single node and single domain - -Set `[server] STATIC_URL_PREFIX = /_/static` in your configuration. - -```nginx -server { - listen 80; - server_name git.example.com; - - location /_/static/assets/ { - alias /path/to/gitea/public/; - } - - location / { - proxy_pass http://localhost:3000; - } -} -``` - -### Two nodes and two domains - -Set `[server] STATIC_URL_PREFIX = http://cdn.example.com/gitea` in your configuration. - -```nginx -# application server running Gitea -server { - listen 80; - server_name git.example.com; - - location / { - proxy_pass http://localhost:3000; - } -} -``` - -```nginx -# static content delivery server -server { - listen 80; - server_name cdn.example.com; - - location /gitea/ { - alias /path/to/gitea/public/; - } - - location / { - return 404; - } -} -``` - -## Apache HTTPD - -If you want Apache HTTPD to serve your Gitea instance, you can add the following to your Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu): - -```apacheconf -<VirtualHost *:80> - ... - ProxyPreserveHost On - ProxyRequests off - AllowEncodedSlashes NoDecode - ProxyPass / http://localhost:3000/ nocanon - RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} -</VirtualHost> -``` - -Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`. - -If you wish to use Let's Encrypt with webroot validation, add the line `ProxyPass /.well-known !` before `ProxyPass` to disable proxying these requests to Gitea. - -## Apache HTTPD with a sub-path - -In case you already have a site, and you want Gitea to share the domain name, you can setup Apache HTTPD to serve Gitea under a sub-path by adding the following to you Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu): - -```apacheconf -<VirtualHost *:80> - ... - <Proxy *> - Order allow,deny - Allow from all - </Proxy> - AllowEncodedSlashes NoDecode - # Note: no trailing slash after either /git or port - ProxyPass /git http://localhost:3000 nocanon - ProxyPreserveHost On - RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} -</VirtualHost> -``` - -Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/git/` correctly in your configuration. - -Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`. - -## Caddy - -If you want Caddy to serve your Gitea instance, you can add the following server block to your Caddyfile: - -``` -git.example.com { - reverse_proxy localhost:3000 -} -``` - -## Caddy with a sub-path - -In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile: - -``` -git.example.com { - route /git/* { - uri strip_prefix /git - reverse_proxy localhost:3000 - } -} -``` - -Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration. - -## IIS - -If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite as reverse proxy. - -1. Setup an empty website in IIS, named let's say, `Gitea Proxy`. -2. Follow the first two steps in [Microsoft's Technical Community Guide to Setup IIS with URL Rewrite](https://techcommunity.microsoft.com/t5/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world/ba-p/846222#M343). That is: - -- Install Application Request Routing (ARR for short) either by using the Microsoft Web Platform Installer 5.1 (WebPI) or downloading the extension from [IIS.net](https://www.iis.net/downloads/microsoft/application-request-routing) -- Once the module is installed in IIS, you will see a new Icon in the IIS Administration Console called URL Rewrite. -- Open the IIS Manager Console and click on the `Gitea Proxy` Website from the tree view on the left. Select and double click the URL Rewrite Icon from the middle pane to load the URL Rewrite interface. -- Choose the `Add Rule` action from the right pane of the management console and select the `Reverse Proxy Rule` from the `Inbound and Outbound Rules` category. -- In the Inbound Rules section, set the server name to be the host that Gitea is running on with its port. e.g. if you are running Gitea on the localhost with port 3000, the following should work: `127.0.0.1:3000` -- Enable SSL Offloading -- In the Outbound Rules, ensure `Rewrite the domain names of the links in HTTP response` is set and set the `From:` field as above and the `To:` to your external hostname, say: `git.example.com` -- Now edit the `web.config` for your website to match the following: (changing `127.0.0.1:3000` and `git.example.com` as appropriate) - -```xml -<?xml version="1.0" encoding="UTF-8"?> -<configuration> - <system.web> - <httpRuntime requestPathInvalidCharacters="" /> - </system.web> - <system.webServer> - <security> - <requestFiltering> - <hiddenSegments> - <clear /> - </hiddenSegments> - <denyUrlSequences> - <clear /> - </denyUrlSequences> - <fileExtensions allowUnlisted="true"> - <clear /> - </fileExtensions> - </requestFiltering> - </security> - <rewrite> - <rules useOriginalURLEncoding="false"> - <rule name="ReverseProxyInboundRule1" stopProcessing="true"> - <match url="(.*)" /> - <action type="Rewrite" url="http://127.0.0.1:3000{UNENCODED_URL}" /> - <serverVariables> - <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" /> - <set name="HTTP_ACCEPT_ENCODING" value="" /> - </serverVariables> - </rule> - </rules> - <outboundRules> - <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> - <!-- set the pattern correctly here - if you only want to accept http or https --> - <!-- change the pattern and the action value as appropriate --> - <match filterByTags="A, Form, Img" pattern="^http(s)?://127.0.0.1:3000/(.*)" /> - <action type="Rewrite" value="http{R:1}://git.example.com/{R:2}" /> - </rule> - <rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding"> - <match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" /> - <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" /> - </rule> - <preConditions> - <preCondition name="ResponseIsHtml1"> - <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> - </preCondition> - <preCondition name="NeedsRestoringAcceptEncoding"> - <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" /> - </preCondition> - </preConditions> - </outboundRules> - </rewrite> - <urlCompression doDynamicCompression="true" /> - <handlers> - <clear /> - <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" /> - </handlers> - <!-- Map all extensions to the same MIME type, so all files can be - downloaded. --> - <staticContent> - <clear /> - <mimeMap fileExtension="*" mimeType="application/octet-stream" /> - </staticContent> - </system.webServer> -</configuration> -``` - -## HAProxy - -If you want HAProxy to serve your Gitea instance, you can add the following to your HAProxy configuration - -add an acl in the frontend section to redirect calls to gitea.example.com to the correct backend - -``` -frontend http-in - ... - acl acl_gitea hdr(host) -i gitea.example.com - use_backend gitea if acl_gitea - ... -``` - -add the previously defined backend section - -``` -backend gitea - server localhost:3000 check -``` - -If you redirect the http content to https, the configuration work the same way, just remember that the connection between HAProxy and Gitea will be done via http so you do not have to enable https in Gitea's configuration. - -## HAProxy with a sub-path - -In case you already have a site, and you want Gitea to share the domain name, you can setup HAProxy to serve Gitea under a sub-path by adding the following to you HAProxy configuration: - -``` -frontend http-in - ... - acl acl_gitea path_beg /gitea - use_backend gitea if acl_gitea - ... -``` - -With that configuration http://example.com/gitea/ will redirect to your Gitea instance. - -then for the backend section - -``` -backend gitea - http-request replace-path /gitea\/?(.*) \/\1 - server localhost:3000 check -``` - -The added http-request will automatically add a trailing slash if needed and internally remove /gitea from the path to allow it to work correctly with Gitea by setting properly http://example.com/gitea as the root. - -Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration. - -## Traefik - -If you want traefik to serve your Gitea instance, you can add the following label section to your `docker-compose.yaml` (Assuming the provider is docker). - -```yaml -gitea: - image: gitea/gitea - ... - labels: - - "traefik.enable=true" - - "traefik.http.routers.gitea.rule=Host(`example.com`)" - - "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000" -``` - -This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik. - -## Traefik with a sub-path - -In case you already have a site, and you want Gitea to share the domain name, you can setup Traefik to serve Gitea under a sub-path by adding the following to your `docker-compose.yaml` (Assuming the provider is docker) : - -```yaml -gitea: - image: gitea/gitea - ... - labels: - - "traefik.enable=true" - - "traefik.http.routers.gitea.rule=Host(`example.com`) && PathPrefix(`/gitea`)" - - "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000" - - "traefik.http.middlewares.gitea-stripprefix.stripprefix.prefixes=/gitea" - - "traefik.http.routers.gitea.middlewares=gitea-stripprefix" -``` - -This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik. - -Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration. diff --git a/docs/content/administration/reverse-proxies.zh-cn.md b/docs/content/administration/reverse-proxies.zh-cn.md deleted file mode 100644 index 4c7de782c7..0000000000 --- a/docs/content/administration/reverse-proxies.zh-cn.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -date: "2018-05-22T11:00:00+00:00" -title: "反向代理" -slug: "reverse-proxies" -sidebar_position: 16 -toc: false -draft: false -aliases: - - /zh-cn/reverse-proxies -menu: - sidebar: - parent: "administration" - name: "反向代理" - sidebar_position: 16 - identifier: "reverse-proxies" ---- - -# 反向代理 - -## 使用 Nginx 作为反向代理服务 - -如果您想使用 Nginx 作为 Gitea 的反向代理服务,您可以参照以下 `nginx.conf` 配置中 `server` 的 `http` 部分: - -``` -server { - listen 80; - server_name git.example.com; - - location / { - proxy_pass http://localhost:3000; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} -``` - -## 使用 Nginx 作为反向代理服务并将 Gitea 路由至一个子路径 - -如果您已经有一个域名并且想与 Gitea 共享该域名,您可以增加以下 `nginx.conf` 配置中 `server` 的 `http` 部分,为 Gitea 添加路由规则: - -``` -server { - listen 80; - server_name git.example.com; - - # 注意: /git/ 最后需要有一个路径符号 - location /git/ { - # 注意: 反向代理后端 URL 的最后需要有一个路径符号 - proxy_pass http://localhost:3000/; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} -``` - -然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。 - -## 使用 Apache HTTPD 作为反向代理服务 - -如果您想使用 Apache HTTPD 作为 Gitea 的反向代理服务,您可以为您的 Apache HTTPD 作如下配置(在 Ubuntu 中,配置文件通常在 `/etc/apache2/httpd.conf` 目录下): - -``` -<VirtualHost *:80> - ... - ProxyPreserveHost On - ProxyRequests off - AllowEncodedSlashes NoDecode - ProxyPass / http://localhost:3000/ nocanon -</VirtualHost> -``` - -注:必须启用以下 Apache HTTPD 组件:`proxy`, `proxy_http` - -## 使用 Apache HTTPD 作为反向代理服务并将 Gitea 路由至一个子路径 - -如果您已经有一个域名并且想与 Gitea 共享该域名,您可以增加以下配置为 Gitea 添加路由规则(在 Ubuntu 中,配置文件通常在 `/etc/apache2/httpd.conf` 目录下): - -``` -<VirtualHost *:80> - ... - <Proxy *> - Order allow,deny - Allow from all - </Proxy> - AllowEncodedSlashes NoDecode - # 注意: 路径和 URL 后面都不要写路径符号 '/' - ProxyPass /git http://localhost:3000 nocanon -</VirtualHost> -``` - -然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。 - -注:必须启用以下 Apache HTTPD 组件:`proxy`, `proxy_http` - -## 使用 Caddy 作为反向代理服务 - -如果您想使用 Caddy 作为 Gitea 的反向代理服务,您可以在 `Caddyfile` 中添加如下配置: - -``` -git.example.com { - proxy / http://localhost:3000 -} -``` - -## 使用 Caddy 作为反向代理服务并将 Gitea 路由至一个子路径 - -如果您已经有一个域名并且想与 Gitea 共享该域名,您可以在您的 `Caddyfile` 文件中增加以下配置,为 Gitea 添加路由规则: - -``` -git.example.com { - # 注意: 路径 /git/ 最后需要有路径符号 - proxy /git/ http://localhost:3000 -} -``` - -然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。 - -## 使用 Traefik 作为反向代理服务 - -如果您想使用 traefik 作为 Gitea 的反向代理服务,您可以在 `docker-compose.yaml` 中添加 label 部分(假设使用 docker 作为 traefik 的 provider): - -```yaml -gitea: - image: gitea/gitea - ... - labels: - - "traefik.enable=true" - - "traefik.http.routers.gitea.rule=Host(`example.com`)" - - "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000" -``` - -这份配置假设您使用 traefik 来处理 HTTPS 服务,并在其和 Gitea 之间使用 HTTP 进行通信。 diff --git a/docs/content/administration/search-engines-indexation.en-us.md b/docs/content/administration/search-engines-indexation.en-us.md deleted file mode 100644 index 664940697d..0000000000 --- a/docs/content/administration/search-engines-indexation.en-us.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -date: "2019-12-31T13:55:00+05:00" -title: "Search Engines Indexation" -slug: "search-engines-indexation" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /en-us/search-engines-indexation -menu: - sidebar: - parent: "administration" - name: "Search Engines Indexation" - sidebar_position: 60 - identifier: "search-engines-indexation" ---- - -# Search engines indexation of your Gitea installation - -By default your Gitea installation will be indexed by search engines. -If you don't want your repository to be visible for search engines read further. - -## Block search engines indexation using robots.txt - -To make Gitea serve a custom `robots.txt` (default: empty 404) for top level installations, -create a file with path `public/robots.txt` in the [`custom` folder or `CustomPath`](administration/customizing-gitea.md) - -Examples on how to configure the `robots.txt` can be found at [https://moz.com/learn/seo/robotstxt](https://moz.com/learn/seo/robotstxt). - -```txt -User-agent: * -Disallow: / -``` - -If you installed Gitea in a subdirectory, you will need to create or edit the `robots.txt` in the top level directory. - -```txt -User-agent: * -Disallow: /gitea/ -``` diff --git a/docs/content/administration/search-engines-indexation.zh-cn.md b/docs/content/administration/search-engines-indexation.zh-cn.md deleted file mode 100644 index 904e6de11b..0000000000 --- a/docs/content/administration/search-engines-indexation.zh-cn.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "搜索引擎索引" -slug: "search-engines-indexation" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /zh-cn/search-engines-indexation -menu: - sidebar: - parent: "administration" - name: "搜索引擎索引" - sidebar_position: 60 - identifier: "search-engines-indexation" ---- - -# Gitea 安装的搜索引擎索引 - -默认情况下,您的 Gitea 安装将被搜索引擎索引。 -如果您不希望您的仓库对搜索引擎可见,请进一步阅读。 - -## 使用 robots.txt 阻止搜索引擎索引 - -为了使 Gitea 为顶级安装提供自定义的`robots.txt`(默认为空的 404),请在 [`custom`文件夹或`CustomPath`](administration/customizing-gitea.md)中创建一个名为 `public/robots.txt` 的文件。 - -有关如何配置 `robots.txt` 的示例,请参考 [https://moz.com/learn/seo/robotstxt](https://moz.com/learn/seo/robotstxt)。 - -```txt -User-agent: * -Disallow: / -``` - -如果您将Gitea安装在子目录中,则需要在顶级目录中创建或编辑 `robots.txt`。 - -```txt -User-agent: * -Disallow: /gitea/ -``` diff --git a/docs/content/administration/signing.en-us.md b/docs/content/administration/signing.en-us.md deleted file mode 100644 index 837af14bb1..0000000000 --- a/docs/content/administration/signing.en-us.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -date: "2019-08-17T10:20:00+01:00" -title: "GPG Commit Signatures" -slug: "signing" -sidebar_position: 50 -toc: false -draft: false -aliases: - - /en-us/signing -menu: - sidebar: - parent: "administration" - name: "GPG Commit Signatures" - sidebar_position: 50 - identifier: "signing" ---- - -# GPG Commit Signatures - -Gitea will verify GPG commit signatures in the provided tree by -checking if the commits are signed by a key within the Gitea database, -or if the commit matches the default key for Git. - -Keys are not checked to determine if they have expired or revoked. -Keys are also not checked with keyservers. - -A commit will be marked with a grey unlocked icon if no key can be -found to verify it. If a commit is marked with a red unlocked icon, -it is reported to be signed with a key with an id. - -Please note: The signer of a commit does not have to be an author or -committer of a commit. - -This functionality requires Git >= 1.7.9 but for full functionality -this requires Git >= 2.0.0. - -## Automatic Signing - -There are a number of places where Gitea will generate commits itself: - -- Repository Initialisation -- Wiki Changes -- CRUD actions using the editor or the API -- Merges from Pull Requests - -Depending on configuration and server trust you may want Gitea to -sign these commits. - -## Installing and generating a GPG key for Gitea - -It is up to a server administrator to determine how best to install -a signing key. Gitea generates all its commits using the server `git` -command at present - and therefore the server `gpg` will be used for -signing (if configured.) Administrators should review best-practices -for GPG - in particular it is probably advisable to only install a -signing secret subkey without the master signing and certifying secret -key. - -## General Configuration - -Gitea's configuration for signing can be found with the -`[repository.signing]` section of `app.ini`: - -```ini -... -[repository.signing] -SIGNING_KEY = default -SIGNING_NAME = -SIGNING_EMAIL = -INITIAL_COMMIT = always -CRUD_ACTIONS = pubkey, twofa, parentsigned -WIKI = never -MERGES = pubkey, twofa, basesigned, commitssigned - -... -``` - -### `SIGNING_KEY` - -The first option to discuss is the `SIGNING_KEY`. There are three main -options: - -- `none` - this prevents Gitea from signing any commits -- `default` - Gitea will default to the key configured within `git config` -- `KEYID` - Gitea will sign commits with the gpg key with the ID - `KEYID`. In this case you should provide a `SIGNING_NAME` and - `SIGNING_EMAIL` to be displayed for this key. - -The `default` option will interrogate `git config` for -`commit.gpgsign` option - if this is set, then it will use the results -of the `user.signingkey`, `user.name` and `user.email` as appropriate. - -Please note: by adjusting Git's `config` file within Gitea's -repositories, `SIGNING_KEY=default` could be used to provide different -signing keys on a per-repository basis. However, this is clearly not an -ideal UI and therefore subject to change. - -**Since 1.17**, Gitea runs git in its own home directory `[git].HOME_PATH` (default to `%(APP_DATA_PATH)/home`) -and uses its own config `{[git].HOME_PATH}/.gitconfig`. -If you have your own customized git config for Gitea, you should set these configs in system git config (aka `/etc/gitconfig`) -or the Gitea internal git config `{[git].HOME_PATH}/.gitconfig`. -Related home files for git command (like `.gnupg`) should also be put in Gitea's git home directory `[git].HOME_PATH`. -If you like to keep the `.gnupg` directory outside of `{[git].HOME_PATH}/`, consider setting the `$GNUPGHOME` environment variable to your preferred location. - -### `INITIAL_COMMIT` - -This option determines whether Gitea should sign the initial commit -when creating a repository. The possible values are: - -- `never`: Never sign -- `pubkey`: Only sign if the user has a public key -- `twofa`: Only sign if the user logs in with two factor authentication -- `always`: Always sign - -Options other than `never` and `always` can be combined as a comma -separated list. The commit will be signed if all selected options are true. - -### `WIKI` - -This options determines if Gitea should sign commits to the Wiki. -The possible values are: - -- `never`: Never sign -- `pubkey`: Only sign if the user has a public key -- `twofa`: Only sign if the user logs in with two-factor authentication -- `parentsigned`: Only sign if the parent commit is signed. -- `always`: Always sign - -Options other than `never` and `always` can be combined as a comma -separated list. The commit will be signed if all selected options are true. - -### `CRUD_ACTIONS` - -This option determines if Gitea should sign commits from the web -editor or API CRUD actions. The possible values are: - -- `never`: Never sign -- `pubkey`: Only sign if the user has a public key -- `twofa`: Only sign if the user logs in with two-factor authentication -- `parentsigned`: Only sign if the parent commit is signed. -- `always`: Always sign - -Options other than `never` and `always` can be combined as a comma -separated list. The change will be signed if all selected options are true. - -### `MERGES` - -This option determines if Gitea should sign merge commits from PRs. -The possible options are: - -- `never`: Never sign -- `pubkey`: Only sign if the user has a public key -- `twofa`: Only sign if the user logs in with two-factor authentication -- `basesigned`: Only sign if the parent commit in the base repo is signed. -- `headsigned`: Only sign if the head commit in the head branch is signed. -- `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed. -- `approved`: Only sign approved merges to a protected branch. -- `always`: Always sign - -Options other than `never` and `always` can be combined as a comma -separated list. The merge will be signed if all selected options are true. - -## Obtaining the Public Key of the Signing Key - -The public key used to sign Gitea's commits can be obtained from the API at: - -```sh -/api/v1/signing-key.gpg -``` - -In cases where there is a repository specific key this can be obtained from: - -```sh -/api/v1/repos/:username/:reponame/signing-key.gpg -``` diff --git a/docs/content/administration/signing.zh-cn.md b/docs/content/administration/signing.zh-cn.md deleted file mode 100644 index 5910b1bf78..0000000000 --- a/docs/content/administration/signing.zh-cn.md +++ /dev/null @@ -1,142 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "GPG 提交签名" -slug: "signing" -sidebar_position: 50 -toc: false -draft: false -aliases: - - /zh-cn/signing -menu: - sidebar: - parent: "administration" - name: "GPG 提交签名" - sidebar_position: 50 - identifier: "signing" ---- - -# GPG 提交签名 - -Gitea 将通过检查提交是否由 Gitea 数据库中的密钥签名,或者提交是否与 Git 的默认密钥匹配,来验证提供的树中的 GPG 提交签名。 - -密钥不会被检查以确定它们是否已过期或撤销。密钥也不会与密钥服务器进行检查。 - -如果找不到用于验证提交的密钥,提交将被标记为灰色的未锁定图标。如果提交被标记为红色的未锁定图标,则表示它使用带有 ID 的密钥签名。 - -请注意:提交的签署者不必是提交的作者或提交者。 - -此功能要求 Git >= 1.7.9,但要实现全部功能,需要 Git >= 2.0.0。 - -## 自动签名 - -有许多地方 Gitea 会生成提交: - -- 仓库初始化 -- Wiki 更改 -- 使用编辑器或 API 进行的 CRUD 操作 -- 从合并请求进行合并 - -根据配置和服务器信任,您可能希望 Gitea 对这些提交进行签名。 - -## 安装和生成 Gitea 的 GPG 密钥 - -如何安装签名密钥由服务器管理员决定。Gitea 目前使用服务器的 `git` 命令生成所有提交,因此将使用服务器的 `gpg` 进行签名(如果配置了)。管理员应该审查 GPG 的最佳实践 - 特别是可能建议仅安装签名的子密钥,而不是主签名和认证的密钥。 - -## 通用配置 - -Gitea 的签名配置可以在 `app.ini` 的 `[repository.signing]` 部分找到: - -```ini -... -[repository.signing] -SIGNING_KEY = default -SIGNING_NAME = -SIGNING_EMAIL = -INITIAL_COMMIT = always -CRUD_ACTIONS = pubkey, twofa, parentsigned -WIKI = never -MERGES = pubkey, twofa, basesigned, commitssigned - -... -``` - -### `SIGNING_KEY` - -首先讨论的选项是 `SIGNING_KEY`。有三个主要选项: - -- `none` - 这将阻止 Gitea 对任何提交进行签名 -- `default` - Gitea 将使用 `git config` 中配置的默认密钥 -- `KEYID` - Gitea 将使用具有 ID `KEYID` 的 GPG 密钥对提交进行签名。在这种情况下,您应该提供 `SIGNING_NAME` 和 `SIGNING_EMAIL`,以便显示此密钥的信息。 - -`default` 选项将读取 `git config` 中的 `commit.gpgsign` 选项 - 如果设置了该选项,它将使用 `user.signingkey`、`user.name` 和 `user.email` 的结果。 - -请注意:通过在 Gitea 的仓库中调整 Git 的 `config` 文件,可以使用 `SIGNING_KEY=default` 为每个仓库提供不同的签名密钥。然而,这显然不是一个理想的用户界面,因此可能会发生更改。 - -**自 1.17 起**,Gitea 在自己的主目录 `[git].HOME_PATH`(默认为 `%(APP_DATA_PATH)/home`)中运行 git,并使用自己的配置文件 `{[git].HOME_PATH}/.gitconfig`。 -如果您有自己定制的 Gitea git 配置,您应该将这些配置设置在系统 git 配置文件中(例如 `/etc/gitconfig`)或者 Gitea 的内部 git 配置文件 `{[git].HOME_PATH}/.gitconfig` 中。 -与 git 命令相关的主目录文件(如 `.gnupg`)也应该放在 Gitea 的 git 主目录 `[git].HOME_PATH` 中。 -如果您希望将 `.gnupg` 目录放在 `{[git].HOME_PATH}/` 之外的位置,请考虑设置 `$GNUPGHOME` 环境变量为您首选的位置。 - -### `INITIAL_COMMIT` - -此选项确定在创建仓库时,Gitea 是否应该对初始提交进行签名。可能的取值有: - -- `never`:从不签名 -- `pubkey`:仅在用户拥有公钥时进行签名 -- `twofa`:仅在用户使用 2FA 登录时进行签名 -- `always`:始终签名 - -除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则提交将被签名。 - -### `WIKI` - -此选项确定 Gitea 是否应该对 Wiki 的提交进行签名。可能的取值有: - -- `never`:从不签名 -- `pubkey`:仅在用户拥有公钥时进行签名 -- `twofa`:仅在用户使用 2FA 登录时进行签名 -- `parentsigned`:仅在父提交已签名时进行签名。 -- `always`:始终签名 - -除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则提交将被签名。 - -### `CRUD_ACTIONS` - -此选项确定 Gitea 是否应该对 Web 编辑器或 API CRUD 操作的提交进行签名。可能的取值有: - -- `never`:从不签名 -- `pubkey`:仅在用户拥有公钥时进行签名 -- `twofa`:仅在用户使用 2FA 登录时进行签名 -- `parentsigned`:仅在父提交已签名时进行签名。 -- `always`:始终签名 - -除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则更改将被签名。 - -### `MERGES` - -此选项确定 Gitea 是否应该对 PR 的合并提交进行签名。可能的选项有: - -- `never`:从不签名 -- `pubkey`:仅在用户拥有公钥时进行签名 -- `twofa`:仅在用户使用 2FA 登录时进行签名 -- `basesigned`:仅在基础仓库中的父提交已签名时进行签名。 -- `headsigned`:仅在头分支中的头提交已签名时进行签名。 -- `commitssigned`:仅在头分支中的所有提交到合并点的提交都已签名时进行签名。 -- `approved`:仅对已批准的合并到受保护分支的提交进行签名。 -- `always`:始终签名 - -除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则合并将被签名。 - -## 获取签名密钥的公钥 - -用于签署 Gitea 提交的公钥可以通过 API 获取: - -```sh -/api/v1/signing-key.gpg -``` - -在存在特定于仓库的密钥的情况下,可以通过以下方式获取: - -```sh -/api/v1/repos/:username/:reponame/signing-key.gpg -``` diff --git a/docs/content/contributing.en-us.md b/docs/content/contributing.en-us.md deleted file mode 100644 index 8cd2e2bd89..0000000000 --- a/docs/content/contributing.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2021-01-22T00:00:00+02:00" -title: "Contributing" -slug: "contributing" -sidebar_position: 35 -toc: false -draft: false -menu: - sidebar: - name: "Contributing" - sidebar_position: 50 - identifier: "contributing" ---- diff --git a/docs/content/contributing/_index.en-us.md b/docs/content/contributing/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/contributing/_index.en-us.md +++ /dev/null diff --git a/docs/content/contributing/_index.zh-cn.md b/docs/content/contributing/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/contributing/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/contributing/guidelines-backend.en-us.md b/docs/content/contributing/guidelines-backend.en-us.md deleted file mode 100644 index 3159a5ff7d..0000000000 --- a/docs/content/contributing/guidelines-backend.en-us.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -date: "2021-11-01T23:41:00+08:00" -title: "Guidelines for Backend Development" -slug: "guidelines-backend" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /en-us/guidelines-backend -menu: - sidebar: - parent: "contributing" - name: "Guidelines for Backend" - sidebar_position: 20 - identifier: "guidelines-backend" ---- - -# Guidelines for Backend Development - -## Background - -Gitea uses Golang as the backend programming language. It uses many third-party packages and also write some itself. -For example, Gitea uses [Chi](https://github.com/go-chi/chi) as basic web framework. [Xorm](https://xorm.io) is an ORM framework that is used to interact with the database. -So it's very important to manage these packages. Please take the below guidelines before you start to write backend code. - -## Package Design Guideline - -### Packages List - -To maintain understandable code and avoid circular dependencies it is important to have a good code structure. The Gitea backend is divided into the following parts: - -- `build`: Scripts to help build Gitea. -- `cmd`: All Gitea actual sub commands includes web, doctor, serv, hooks, admin and etc. `web` will start the web service. `serv` and `hooks` will be invoked by Git or OpenSSH. Other sub commands could help to maintain Gitea. -- `tests`: Common test utility functions - - `tests/integration`: Integration tests, to test back-end regressions - - `tests/e2e`: E2e tests, to test front-end and back-end compatibility and visual regressions. -- `models`: Contains the data structures used by xorm to construct database tables. It also contains functions to query and update the database. Dependencies to other Gitea code should be avoided. You can make exceptions in cases such as logging. - - `models/db`: Basic database operations. All other `models/xxx` packages should depend on this package. The `GetEngine` function should only be invoked from `models/`. - - `models/fixtures`: Sample data used in unit tests and integration tests. One `yml` file means one table which will be loaded into database when beginning the tests. - - `models/migrations`: Stores database migrations between versions. PRs that change a database structure **MUST** also have a migration step. -- `modules`: Different modules to handle specific functionality in Gitea. Work in Progress: Some of them should be moved to `services`, in particular those that depend on models because they rely on the database. - - `modules/setting`: Store all system configurations read from ini files and has been referenced by everywhere. But they should be used as function parameters when possible. - - `modules/git`: Package to interactive with `Git` command line or Gogit package. -- `public`: Compiled frontend files (javascript, images, css, etc.) -- `routers`: Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) must not depend on routers. - - `routers/api` Contains routers for `/api/v1` aims to handle RESTful API requests. - - `routers/install` Could only respond when system is in INSTALL mode (INSTALL_LOCK=false). - - `routers/private` will only be invoked by internal sub commands, especially `serv` and `hooks`. - - `routers/web` will handle HTTP requests from web browsers or Git SMART HTTP protocols. -- `services`: Support functions for common routing operations or command executions. Uses `models` and `modules` to handle the requests. -- `templates`: Golang templates for generating the html output. - -### Package Dependencies - -Since Golang doesn't support import cycles, we have to decide the package dependencies carefully. There are some levels between those packages. Below is the ideal package dependencies direction. - -`cmd` -> `routers` -> `services` -> `models` -> `modules` - -From left to right, left packages could depend on right packages, but right packages MUST not depend on left packages. The sub packages on the same level could depend on according this level's rules. - -**NOTICE** - -Why do we need database transactions outside of `models`? And how? -Some actions should allow for rollback when database record insertion/update/deletion failed. -So services must be allowed to create a database transaction. Here is some example, - -```go -// services/repository/repository.go -func CreateXXXX() error { - return db.WithTx(func(ctx context.Context) error { - // do something, if err is returned, it will rollback automatically - if err := issues.UpdateIssue(ctx, repoID); err != nil { - // ... - return err - } - // ... - return nil - }) -} -``` - -You should **not** use `db.GetEngine(ctx)` in `services` directly, but just write a function under `models/`. -If the function will be used in the transaction, just let `context.Context` as the function's first parameter. - -```go -// models/issues/issue.go -func UpdateIssue(ctx context.Context, repoID int64) error { - e := db.GetEngine(ctx) - - // ... -} -``` - -### Package Name - -For the top level package, use a plural as package name, i.e. `services`, `models`, for sub packages, use singular, -i.e. `services/user`, `models/repository`. - -### Import Alias - -Since there are some packages which use the same package name, it is possible that you find packages like `modules/user`, `models/user`, and `services/user`. When these packages are imported in one Go file, it's difficult to know which package we are using and if it's a variable name or an import name. So, we always recommend to use import aliases. To differ from package variables which are commonly in camelCase, just use **snake_case** for import aliases. -i.e. `import user_service "code.gitea.io/gitea/services/user"` - -### Implementing `io.Closer` - -If a type implements `io.Closer`, calling `Close` multiple times must not fail or `panic` but return an error or `nil`. - -### Important Gotchas - -- Never write `x.Update(exemplar)` without an explicit `WHERE` clause: - - This will cause all rows in the table to be updated with the non-zero values of the exemplar - including IDs. - - You should usually write `x.ID(id).Update(exemplar)`. -- If during a migration you are inserting into a table using `x.Insert(exemplar)` where the ID is preset: - - You will need to ``SET IDENTITY_INSERT `table` ON`` for the MSSQL variant (the migration will fail otherwise) - - However, you will also need to update the id sequence for postgres - the migration will silently pass here but later insertions will fail: - ``SELECT setval('table_name_id_seq', COALESCE((SELECT MAX(id)+1 FROM `table_name`), 1), false)`` - -### Future Tasks - -Currently, we are creating some refactors to do the following things: - -- Correct that codes which doesn't follow the rules. -- There are too many files in `models`, so we are moving some of them into a sub package `models/xxx`. -- Some `modules` sub packages should be moved to `services` because they depend on `models`. diff --git a/docs/content/contributing/guidelines-backend.zh-cn.md b/docs/content/contributing/guidelines-backend.zh-cn.md deleted file mode 100644 index 33129dc086..0000000000 --- a/docs/content/contributing/guidelines-backend.zh-cn.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -date: "2023-05-25T23:41:00+08:00" -title: "后端开发指南" -slug: "guidelines-backend" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/guidelines-backend -menu: - sidebar: - parent: "contributing" - name: "后端开发指南" - sidebar_position: 20 - identifier: "guidelines-backend" ---- - -# 后端开发指南 - -## 背景 - -Gitea使用Golang作为后端编程语言。它使用了许多第三方包,并且自己也编写了一些包。 -例如,Gitea使用[Chi](https://github.com/go-chi/chi)作为基本的Web框架。[Xorm](https://xorm.io)是一个用于与数据库交互的ORM框架。 -因此,管理这些包非常重要。在开始编写后端代码之前,请参考以下准则。 - -## 包设计准则 - -### 包列表 - -为了保持易于理解的代码并避免循环依赖,拥有良好的代码结构是很重要的。Gitea后端分为以下几个部分: - -- `build`:帮助构建Gitea的脚本。 -- `cmd`:包含所有Gitea的实际子命令,包括web、doctor、serv、hooks、admin等。`web`将启动Web服务。`serv`和`hooks`将被Git或OpenSSH调用。其他子命令可以帮助维护Gitea。 -- `tests`:常用的测试函数 -- `tests/integration`:集成测试,用于测试后端回归。 -- `tests/e2e`:端到端测试,用于测试前端和后端的兼容性和视觉回归。 -- `models`:包含由xorm用于构建数据库表的数据结构。它还包含查询和更新数据库的函数。应避免与其他Gitea代码的依赖关系。在某些情况下,比如日志记录时可以例外。 - - `models/db`:基本的数据库操作。所有其他`models/xxx`包都应依赖于此包。`GetEngine`函数只能从models/中调用。 - - `models/fixtures`:单元测试和集成测试中使用的示例数据。一个`yml`文件表示一个将在测试开始时加载到数据库中的表。 - - `models/migrations`:存储不同版本之间的数据库迁移。修改数据库结构的PR**必须**包含一个迁移步骤。 -- `modules`:在Gitea中处理特定功能的不同模块。工作正在进行中:其中一些模块应该移到`services`中,特别是那些依赖于models的模块,因为它们依赖于数据库。 - - `modules/setting`:存储从ini文件中读取的所有系统配置,并在各处引用。但是在可能的情况下,应将其作为函数参数使用。 - - `modules/git`:用于与`Git`命令行或Gogit包交互的包。 -- `public`:编译后的前端文件(JavaScript、图像、CSS等) -- `routers`:处理服务器请求。由于它使用其他Gitea包来处理请求,因此其他包(models、modules或services)不能依赖于routers。 - - `routers/api`:包含`/api/v1`相关路由,用于处理RESTful API请求。 - - `routers/install`:只能在系统处于安装模式(INSTALL_LOCK=false)时响应。 - - `routers/private`:仅由内部子命令调用,特别是`serv`和`hooks`。 - - `routers/web`:处理来自Web浏览器或Git SMART HTTP协议的HTTP请求。 -- `services`:用于常见路由操作或命令执行的支持函数。使用`models`和`modules`来处理请求。 -- `templates`:用于生成HTML输出的Golang模板。 - -### 包依赖关系 - -由于Golang不支持导入循环,我们必须仔细决定包之间的依赖关系。这些包之间有一些级别。以下是理想的包依赖关系方向。 - -`cmd` -> `routers` -> `services` -> `models` -> `modules` - -从左到右,左侧的包可以依赖于右侧的包,但右侧的包不能依赖于左侧的包。在同一级别的子包中,可以根据该级别的规则进行依赖。 - -**注意事项** - -为什么我们需要在`models`之外使用数据库事务?以及如何使用? -某些操作在数据库记录插入/更新/删除失败时应该允许回滚。 -因此,服务必须能够创建数据库事务。以下是一些示例: - -```go -// services/repository/repository.go -func CreateXXXX() error { - return db.WithTx(func(ctx context.Context) error { - // do something, if err is returned, it will rollback automatically - if err := issues.UpdateIssue(ctx, repoID); err != nil { - // ... - return err - } - // ... - return nil - }) -} -``` - -在`services`中**不应该**直接使用`db.GetEngine(ctx)`,而是应该在`models/`下编写一个函数。 -如果该函数将在事务中使用,请将`context.Context`作为函数的第一个参数。 - -```go -// models/issues/issue.go -func UpdateIssue(ctx context.Context, repoID int64) error { - e := db.GetEngine(ctx) - - // ... -} -``` - -### 包名称 - -对于顶层包,请使用复数作为包名,例如`services`、`models`,对于子包,请使用单数,例如`services/user`、`models/repository`。 - -### 导入别名 - -由于有一些使用相同包名的包,例如`modules/user`、`models/user`和`services/user`,当这些包在一个Go文件中被导入时,很难知道我们使用的是哪个包以及它是变量名还是导入名。因此,我们始终建议使用导入别名。为了与常见的驼峰命名法的包变量区分开,建议使用**snake_case**作为导入别名的命名规则。 -例如:`import user_service "code.gitea.io/gitea/services/user"` - -### 重要注意事项 - -- 永远不要写成`x.Update(exemplar)`,而没有明确的`WHERE`子句: - - 这将导致表中的所有行都被使用exemplar的非零值进行更新,包括ID。 - - 通常应该写成`x.ID(id).Update(exemplar)`。 -- 如果在迁移过程中使用`x.Insert(exemplar)`向表中插入记录,而ID是预设的: - - 对于MSSQL变体,你将需要执行``SET IDENTITY_INSERT `table` ON``(否则迁移将失败) - - 对于PostgreSQL,你还需要更新ID序列,否则迁移将悄无声息地通过,但后续的插入将失败: - ``SELECT setval('table_name_id_seq', COALESCE((SELECT MAX(id)+1 FROM `table_name`), 1), false)`` - -### 未来的任务 - -目前,我们正在进行一些重构,以完成以下任务: - -- 纠正不符合规则的代码。 -- `models`中的文件太多了,所以我们正在将其中的一些移动到子包`models/xxx`中。 -- 由于它们依赖于`models`,因此应将某些`modules`子包移动到`services`中。 diff --git a/docs/content/contributing/guidelines-frontend.en-us.md b/docs/content/contributing/guidelines-frontend.en-us.md deleted file mode 100644 index 5539532c52..0000000000 --- a/docs/content/contributing/guidelines-frontend.en-us.md +++ /dev/null @@ -1,165 +0,0 @@ ---- -date: "2021-10-13T16:00:00+02:00" -title: "Guidelines for Frontend Development" -slug: "guidelines-frontend" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /en-us/guidelines-frontend -menu: - sidebar: - parent: "contributing" - name: "Guidelines for Frontend" - sidebar_position: 30 - identifier: "guidelines-frontend" ---- - -# Guidelines for Frontend Development - -## Background - -Gitea uses [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend. - -The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template). - -The source files can be found in the following directories: - -* **CSS styles:** `web_src/css/` -* **JavaScript files:** `web_src/js/` -* **Vue components:** `web_src/js/components/` -* **Go HTML templates:** `templates/` - -## General Guidelines - -We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) and [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) - -### Gitea specific guidelines - -1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories. -2. HTML ids and classes should use kebab-case, it's preferred to contain 2-3 feature related keywords. -3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript. -4. CSS styling for classes provided by frameworks should not be overwritten. Always use new class names with 2-3 feature related keywords to overwrite framework styles. Gitea's helper CSS classes in `helpers.less` could be helpful. -5. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`, but do not expose whole models to the frontend to avoid leaking sensitive data. -6. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue3. -7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`. -8. Use semantic elements, prefer `<button class="ui button">` instead of `<div class="ui button">`. -9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided. -10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event. -11. Custom event names are recommended to use `ce-` prefix. -12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-ellipsis`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`). -13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided. - -### Accessibility / ARIA - -In history, Gitea heavily uses Fomantic UI which is not an accessibility-friendly framework. -Gitea uses some patches to make Fomantic UI more accessible (see `aria.md` and related JS files), -but there are still many problems which need a lot of work and time to fix. - -### Framework Usage - -Mixing different frameworks together is discouraged, it makes the code difficult to be maintained. -A JavaScript module should follow one major framework and follow the framework's best practice. - -Recommended implementations: - -* Vue + Vanilla JS -* Fomantic-UI (jQuery) -* htmx (partial page reloads for otherwise static components) -* Vanilla JS - -Discouraged implementations: - -* Vue + Fomantic-UI (jQuery) -* jQuery + Vanilla JS -* htmx + any other framework which requires heavy JS code, or unnecessary features like htmx scripting (`hx-on`) - -To make UI consistent, Vue components can use Fomantic-UI CSS classes. -We use htmx for simple interactions. You can see an example for simple interactions where htmx should be used in this [PR](https://github.com/go-gitea/gitea/pull/28908). Do not use htmx if you require more advanced reactivity, use another framework (Vue/Vanilla JS). -Although mixing different frameworks is discouraged, -it should also work if the mixing is necessary and the code is well-designed and maintainable. - -### Typescript - -Gitea is in the process of migrating to type-safe Typescript. Here are some specific guidelines regarding Typescript in the codebase: - -#### Use type aliases instead of interfaces - -Prefer to use type aliases because they can represent any type and are generally more flexible to use than interfaces. - -#### Use separate type imports - -We use `verbatimModuleSyntax` so type and non-type imports from the same file must be split into two `import type` statements. This enables the typescript compiler to completely eliminate the type import statements during compilation. - -#### Use `@ts-expect-error` instead of `@ts-ignore` - -Both annotations should be avoided, but if you have to use them, use `@ts-expect-error` because it will not leave ineffective statements after the issue is fixed. - -### `async` Functions - -Only mark a function as `async` if and only if there are `await` calls -or `Promise` returns inside the function. - -It's not recommended to use `async` event listeners, which may lead to problems. -The reason is that the code after await is executed outside the event dispatch. -Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md - -If an event listener must be `async`, the `e.preventDefault()` should be before any `await`, -it's recommended to put it at the beginning of the function. - -If we want to call an `async` function in a non-async context, -it's recommended to use `const _promise = asyncFoo()` to tell readers -that this is done by purpose, we want to call the async function and ignore the Promise. -Some lint rules and IDEs also have warnings if the returned Promise is not handled. - -### Fetching data - -To fetch data, use the wrapper functions `GET`, `POST` etc. from `modules/fetch.js`. They -accept a `data` option for the content, will automatically set CSRF token and return a -Promise for a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). - -### HTML Attributes and `dataset` - -The usage of `dataset` is forbidden, its camel-casing behaviour makes it hard to grep for attributes. -However, there are still some special cases, so the current guideline is: - -* For legacy code: - * `$.data()` should be refactored to `$.attr()`. - * `$.data()` can be used to bind some non-string data to elements in rare cases, but it is highly discouraged. - -* For new code: - * `node.dataset` should not be used, use `node.getAttribute` instead. - * never bind any user data to a DOM node, use a suitable design pattern to describe the relation between node and data. - -### Show/Hide Elements - -* Vue components are recommended to use `v-if` and `v-show` to show/hide elements. -* Go template code should use `.tw-hidden` and `showElem()/hideElem()/toggleElem()`, see more details in `.tw-hidden`'s comment. - -### Styles and Attributes in Go HTML Template - -It's recommended to use: - -```html -<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div> -``` - -instead of: - -```html -<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div> -``` - -to make the code more readable. - -### Legacy Code - -A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines. - -### Vue3 and JSX - -Gitea is using Vue3 now. We decided not to introduce JSX to keep the HTML and the JavaScript code separated. - -### UI Examples - -Gitea uses some self-made UI elements and customizes others to integrate them better into the general UI approach. When running Gitea in development mode (`RUN_MODE=dev`), a page with some standardized UI examples is available under `http(s)://your-gitea-url:port/devtest`. diff --git a/docs/content/contributing/guidelines-frontend.zh-cn.md b/docs/content/contributing/guidelines-frontend.zh-cn.md deleted file mode 100644 index 198e1227e5..0000000000 --- a/docs/content/contributing/guidelines-frontend.zh-cn.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -date: "2023-05-25T16:00:00+02:00" -title: "前端开发指南" -slug: "guidelines-frontend" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/guidelines-frontend -menu: - sidebar: - parent: "contributing" - name: "前端开发指南" - sidebar_position: 20 - identifier: "guidelines-frontend" ---- - -# 前端开发指南 - -## 背景 - -Gitea 在其前端中使用[Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html)(基于[jQuery](https://api.jquery.com))和 [Vue3](https://vuejs.org/)。 - -HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。 - -源文件可以在以下目录中找到: - -* **CSS 样式**: `web_src/css/` -* **JavaScript 文件**: `web_src/js/` -* **Vue 组件**: `web_src/js/components/` -* **Go HTML 模板**: `templates/` - -## 通用准则 - -我们推荐使用[Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)和[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)。 - -## Gitea 特定准则 - -1. 每个功能(Fomantic-UI/jQuery 模块)应放在单独的文件/目录中。 -2. HTML 的 id 和 class 应使用 kebab-case,最好包含2-3个与功能相关的关键词。 -3. 在 JavaScript 中使用的 HTML 的 id 和 class 应在整个项目中是唯一的,并且应包含2-3个与功能相关的关键词。建议在仅在 JavaScript 中使用的 class 中使用 `js-` 前缀。 -4. 不应覆盖框架提供的 class 的 CSS 样式。始终使用具有2-3个与功能相关的关键词的新 class 名称来覆盖框架样式。Gitea 中的帮助 CSS 类在 `helpers.less` 中。 -5. 后端可以通过使用`ctx.PageData["myModuleData"] = map[]{}`将复杂数据传递给前端,但不要将整个模型暴露给前端,以避免泄露敏感数据。 -6. 简单页面和与 SEO 相关的页面使用 Go HTML 模板渲染生成静态的 Fomantic-UI HTML 输出。复杂页面可以使用 Vue3。 -7. 明确变量类型,优先使用`elem.disabled = true`而不是`elem.setAttribute('disabled', 'anything')`,优先使用`$el.prop('checked', var === 'yes')`而不是`$el.prop('checked', var)`。 -8. 使用语义化元素,优先使用`<button class="ui button">`而不是`<div class="ui button">`。 -9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。 -10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。 -11. 推荐使用自定义事件名称前缀`ce-`。 -12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-ellipsis`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。 -13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。 - -### 可访问性 / ARIA - -在历史上,Gitea大量使用了可访问性不友好的框架 Fomantic UI。 -Gitea 使用一些补丁使 Fomantic UI 更具可访问性(参见 `aria.md`), -但仍然存在许多问题需要大量的工作和时间来修复。 - -### 框架使用 - -不建议混合使用不同的框架,这会使代码难以维护。 -一个 JavaScript 模块应遵循一个主要框架,并遵循该框架的最佳实践。 - -推荐的实现方式: - -* Vue + Vanilla JS -* Fomantic-UI(jQuery) -* htmx (部分页面重新加载其他静态组件) -* Vanilla JS - -不推荐的实现方式: - -* Vue + Fomantic-UI(jQuery) -* jQuery + Vanilla JS -* htmx + 任何其他需要大量 JavaScript 代码或不必要的功能,如 htmx 脚本 (`hx-on`) - -为了保持界面一致,Vue 组件可以使用 Fomantic-UI 的 CSS 类。 -尽管不建议混合使用不同的框架, -我们使用 htmx 进行简单的交互。您可以在此 [PR](https://github.com/go-gitea/gitea/pull/28908) 中查看一个简单交互的示例,其中应使用 htmx。如果您需要更高级的反应性,请不要使用 htmx,请使用其他框架(Vue/Vanilla JS)。 -但如果混合使用是必要的,并且代码设计良好且易于维护,也可以工作。 - -### `async` 函数 - -只有当函数内部存在`await`调用或返回`Promise`时,才将函数标记为`async`。 - -不建议使用`async`事件监听器,这可能会导致问题。 -原因是`await`后的代码在事件分发之外执行。 -参考:https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md - -如果一个事件监听器必须是`async`,应在任何`await`之前使用`e.preventDefault()`, -建议将其放在函数的开头。 - -如果我们想在非异步上下文中调用`async`函数, -建议使用`const _promise = asyncFoo()`来告诉读者 -这是有意为之的,我们想调用异步函数并忽略Promise。 -一些 lint 规则和 IDE 也会在未处理返回的 Promise 时发出警告。 - -### 获取数据 - -要获取数据,请使用`modules/fetch.js`中的包装函数`GET`、`POST`等。他们 -接受内容的`data`选项,将自动设置 CSRF 令牌并返回 -[Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)。 - -### HTML 属性和 dataset - -禁止使用`dataset`,它的驼峰命名行为使得搜索属性变得困难。 -然而,仍然存在一些特殊情况,因此当前的准则是: - -* 对于旧代码: - * 应将`$.data()`重构为`$.attr()`。 - * 在极少数情况下,可以使用`$.data()`将一些非字符串数据绑定到元素上,但强烈不推荐使用。 - -* 对于新代码: - * 不应使用`node.dataset`,而应使用`node.getAttribute`。 - * 不要将任何用户数据绑定到 DOM 节点上,使用合适的设计模式描述节点和数据之间的关系。 - -### 显示/隐藏元素 - -* 推荐在Vue组件中使用`v-if`和`v-show`来显示/隐藏元素。 -* Go 模板代码应使用 `.tw-hidden` 和 `showElem()/hideElem()/toggleElem()` 来显示/隐藏元素,请参阅`.tw-hidden`的注释以获取更多详细信息。 - -### Go HTML 模板中的样式和属性 - -建议使用以下方式: - -```html -<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div> -``` - -而不是: - -```html -<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div> -``` - -以使代码更易读。 - -### 旧代码 - -许多旧代码已经存在于本文撰写之前。建议重构旧代码以遵循指南。 - -### Vue3 和 JSX - -Gitea 现在正在使用 Vue3。我们决定不引入 JSX,以保持 HTML 代码和 JavaScript 代码分离。 - -### UI示例 - -Gitea 使用一些自制的 UI 元素并自定义其他元素,以将它们更好地集成到通用 UI 方法中。当在开发模式(`RUN_MODE=dev`)下运行 Gitea 时,在 `http(s)://your-gitea-url:port/devtest` 下会提供一个包含一些标准化 UI 示例的页面。 diff --git a/docs/content/contributing/guidelines-refactoring.en-us.md b/docs/content/contributing/guidelines-refactoring.en-us.md deleted file mode 100644 index 5d368a120d..0000000000 --- a/docs/content/contributing/guidelines-refactoring.en-us.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -date: "2023-02-14T00:00:00+00:00" -title: "Guidelines for Refactoring" -slug: "guidelines-refactoring" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /en-us/guidelines-refactoring -menu: - sidebar: - parent: "contributing" - name: "Guidelines for Refactoring" - sidebar_position: 40 - identifier: "guidelines-refactoring" ---- - -# Guidelines for Refactoring - -## Background - -Since the first line of code was written at Feb 12, 2014, Gitea has grown to be a large project. -As a result, the codebase has become larger and larger. The larger the codebase is, the more difficult it is to maintain. -A lot of outdated mechanisms exist, a lot of frameworks are mixed together, some legacy code might cause bugs and block new features. -To make the codebase more maintainable and make Gitea better, developers should keep in mind to use modern mechanisms to refactor the old code. - -This document is a collection of guidelines for refactoring the codebase. - -## Refactoring Suggestions - -* Design more about the future, but not only resolve the current problem. -* Reduce ambiguity, reduce conflicts, improve maintainability. -* Describe the refactoring, for example: - * Why the refactoring is needed. - * How the legacy problems would be solved. - * What's the Pros/Cons of the refactoring. -* Only do necessary changes, keep the old logic as much as possible. -* Introduce some intermediate steps to make the refactoring easier to review, a complete refactoring plan could be done in several PRs. -* If there is any divergence, the TOC(Technical Oversight Committee) should be involved to help to make decisions. -* Add necessary tests to make sure the refactoring is correct. -* Non-bug refactoring is preferred to be done at the beginning of a milestone, it would be easier to find problems before the release. - -## Reviewing & Merging Suggestions - -* A refactoring PR shouldn't be kept open for a long time (usually 7 days), it should be reviewed as soon as possible. -* A refactoring PR should be merged as soon as possible, it should not be blocked by other PRs. -* If there is no objection from TOC, a refactoring PR could be merged after 7 days with one core member's approval (not the author). -* Tolerate some dirty/hacky intermediate steps if the final result is good. -* Tolerate some regression bugs if the refactoring is necessary, fix bugs as soon as possible. diff --git a/docs/content/contributing/guidelines-refactoring.zh-cn.md b/docs/content/contributing/guidelines-refactoring.zh-cn.md deleted file mode 100644 index d65fe486dc..0000000000 --- a/docs/content/contributing/guidelines-refactoring.zh-cn.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -date: "2023-05-25T00:00:00+00:00" -title: "重构指南" -slug: "guidelines-refactoring" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/guidelines-refactoring -menu: - sidebar: - parent: "contributing" - name: "重构指南" - sidebar_position: 20 - identifier: "guidelines-refactoring" ---- - -# 重构指南 - -## 背景 - -自2014年2月12日编写了第一行代码以来,Gitea已经发展成为一个庞大的项目。 -因此,代码库变得越来越大。代码库越大,维护就越困难。 -存在许多过时的机制,许多框架混合在一起,一些遗留代码可能会导致错误并阻碍新功能的开发。 -为了使代码库更易于维护,使Gitea变得更好,开发人员应牢记使用现代机制来重构旧代码。 - -本文档是关于重构代码库的指南集合。 - -## 重构建议 - -* 设计更多关于未来的内容,而不仅仅解决当前问题。 -* 减少模糊性,减少冲突,提高可维护性。 -* 描述重构,例如: - * 为什么需要重构。 - * 如何解决旧问题。 - * 重构的优点/缺点是什么。 -* 只做必要的更改,尽量保留旧逻辑。 -* 引入一些中间步骤,使重构更容易审查,完整的重构计划可以在几个PR中完成。 -* 如果存在分歧,应该请TOC(技术监督委员会)参与决策。 -* 添加必要的测试以确保重构的正确性。 -* 非错误重构优先在里程碑的开始时进行,这样可以更容易地在发布之前发现问题。 - -## 审查和合并建议 - -* 重构的PR不应该长时间保持打开状态(通常为7天),应尽快进行审查。 -* 重构的PR应尽快合并,不应被其他PR阻塞。 -* 如果TOC没有异议,重构的PR可以在7天后由一名核心成员(非作者)批准后合并。 -* 如果最终结果良好,容忍一些不完美/临时的步骤。 -* 如果重构是必要的,容忍一些回归错误,并尽快修复错误。 diff --git a/docs/content/contributing/localization.de-de.md b/docs/content/contributing/localization.de-de.md deleted file mode 100644 index 0741179240..0000000000 --- a/docs/content/contributing/localization.de-de.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -date: "2021-01-22T00:00:00+02:00" -title: "Übersetzungs Richtlinien" -slug: "localization" -sidebar_position: 70 -toc: false -draft: false -menu: - sidebar: - parent: "contributing" - name: "Übersetzungsrichtlinien" - sidebar_position: 70 - identifier: "localization" ---- - -## Allgemeines - -Anrede: Wenig förmlich: - -* "Du"-Form -* Keine "Amtsdeusch"-Umschreibungen, einfach so als ob man den Nutzer direkt persönlich ansprechen würde - -Genauer definiert: - -* "falsch" anstatt "nicht korrekt/inkorrekt" -* Benutzerkonto oder Konto? Oder Account? -* "Wende dich an ..." anstatt "kontaktiere ..." -* In der selben Zeit übersetzen (sonst wird aus "is" "war") -* Richtige Anführungszeichen verwenden. Also `"` statt `''` oder `'` oder \` oder `´` - * `„` für beginnende Anführungszeichen, `“` für schließende Anführungszeichen - -Es gelten Artikel und Worttrennungen aus dem Duden. - -## Formulierungen in Modals und Buttons - -Es sollten die gleichen Formulierungen auf Buttons und Modals verwendet werden. - -Beispiel: Wenn der Button mit `löschen` beschriftet ist, sollte im Modal die Frage lauten `Willst du das wirklich löschen?` und nicht `Willst du das wirklich entfernen?`. Gleiches gilt für Success/Errormeldungen nach der Aktion. - -## Trennungen - -* Pull-Request -* Time-Tracker -* E-Mail-Adresse (siehe Duden) - -## Artikeldefinitionen für Anglizismen - -* _Der_ Commit (m.) -* _Der_ Branch (m.), plural: die Branches -* _Das_ Issue (n.) -* _Der_ Fork (m.) -* _Das_ Repository (n.), plural: die Repositories -* _Der_ Pull-Request (m.) -* _Der_ Token (m.), plural: die Token -* _Das_ Review (n.) -* _Der_ Key (m.) -* _Der_ Committer (m.), plural: die Committer - -## Weiterführende Links - -Diese beiden Links sind sehr empfehlenswert: - -* http://docs.translatehouse.org/projects/localization-guide/en/latest/guide/translation_guidelines_german.html -* https://docs.qgis.org/2.18/en/docs/documentation_guidelines/do_translations.html diff --git a/docs/content/contributing/localization.en-us.md b/docs/content/contributing/localization.en-us.md deleted file mode 100644 index 05ff5ee121..0000000000 --- a/docs/content/contributing/localization.en-us.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Localization" -slug: "localization" -sidebar_position: 70 -toc: false -draft: false -aliases: - - /en-us/localization -menu: - sidebar: - parent: "contributing" - name: "Localization" - sidebar_position: 70 - identifier: "localization" ---- - -# Localization - -Gitea's localization happens through our [Crowdin project](https://crowdin.com/project/gitea). - -For changes to an **English** translation, a pull request can be made that changes the appropriate key in -the [english locale](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.ini). - -For changes to a **non-English** translation, refer to the Crowdin project above. - -## Supported Languages - -Any language listed in the above Crowdin project will be supported as long as 25% or more has been translated. - -After a translation has been accepted, it will be reflected in the main repository after the next Crowdin sync, which is generally after any PR is merged. - -At the time of writing, this means that a changed translation may not appear until the following Gitea release. - -If you use a bleeding edge build, it should appear as soon as you update after the change is synced. - -# How to Contribute - -Different Languages have different translation guidelines. Please visit the respective page for more information. diff --git a/docs/content/contributing/localization.zh-cn.md b/docs/content/contributing/localization.zh-cn.md deleted file mode 100644 index 9f2353e0e9..0000000000 --- a/docs/content/contributing/localization.zh-cn.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "本地化" -slug: "localization" -sidebar_position: 70 -toc: false -draft: false -aliases: - - /zh-cn/localization -menu: - sidebar: - parent: "contributing" - name: "本地化" - sidebar_position: 70 - identifier: "localization" ---- - -# 本地化 - -Gitea的本地化是通过我们的[Crowdin项目](https://crowdin.com/project/gitea)进行的。 - -对于对**英语翻译**的更改,可以发出pull-request,来更改[英语语言环境](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.ini)中合适的关键字。 - -有关对**非英语**翻译的更改,请参阅上面的 Crowdin 项目。 - -## 支持的语言 - -上述 Crowdin 项目中列出的任何语言一旦翻译了 25% 或更多都将得到支持。 - -翻译被接受后,它将在下一次 Crowdin 同步后反映在主存储库中,这通常是在任何 PR 合并之后。 - -在撰写本文时,这意味着更改后的翻译可能要到 Gitea 的下一个版本才会出现。 - -如果使用开发版本,则在同步更改内容后,它应该会在更新后立即显示。 diff --git a/docs/content/contributing/translation.zh-cn.md b/docs/content/contributing/translation.zh-cn.md deleted file mode 100644 index 80ce6fd743..0000000000 --- a/docs/content/contributing/translation.zh-cn.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -date: "2023-05-25T00:00:00+02:00" -title: "翻译指南" -sidebar_position: 70 -toc: true -draft: false -menu: - sidebar: - parent: "contributing" - name: "翻译指南" - sidebar_position: 70 - identifier: "translation-guidelines" ---- - -本页面用于提供一套通用规则,以确保翻译的一致性。 - -* [German](/de-de/übersetzungs-richtlinien/) diff --git a/docs/content/development.en-us.md b/docs/content/development.en-us.md deleted file mode 100644 index 92201b1f5b..0000000000 --- a/docs/content/development.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Development" -slug: "development" -sidebar_position: 40 -toc: false -draft: false -menu: - sidebar: - name: "Development" - sidebar_position: 40 - identifier: "development" ---- diff --git a/docs/content/development.zh-cn.md b/docs/content/development.zh-cn.md deleted file mode 100644 index 4992b313d1..0000000000 --- a/docs/content/development.zh-cn.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "开发" -slug: "development" -sidebar_position: 40 -toc: false -draft: false -menu: - sidebar: - name: "开发" - sidebar_position: 40 - identifier: "development" ---- diff --git a/docs/content/development/_index.en-us.md b/docs/content/development/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/development/_index.en-us.md +++ /dev/null diff --git a/docs/content/development/_index.zh-cn.md b/docs/content/development/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/development/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/development/api-usage.en-us.md b/docs/content/development/api-usage.en-us.md deleted file mode 100644 index 4fe376b11b..0000000000 --- a/docs/content/development/api-usage.en-us.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -date: "2018-06-24:00:00+02:00" -title: "API Usage" -slug: "api-usage" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /en-us/api-usage -menu: - sidebar: - parent: "development" - name: "API Usage" - sidebar_position: 40 - identifier: "api-usage" ---- - -# API Usage - -## Enabling/configuring API access - -By default, `ENABLE_SWAGGER` is true, and `MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat Sheet](administration/config-cheat-sheet.md) for more information. - -## Authentication - -Gitea supports these methods of API authentication: - -- HTTP basic authentication -- `token=...` parameter in URL query string -- `access_token=...` parameter in URL query string -- `Authorization: token ...` header in HTTP headers - -All of these methods accept the same API key token type. You can -better understand this by looking at the code -- as of this writing, -Gitea parses queries and headers to find the token in -[modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47). - -## Generating and listing API tokens - -A new token can be generated with a `POST` request to -`/users/:name/tokens`. - -Note that `/users/:name/tokens` is a special endpoint and requires you -to authenticate using `BasicAuth` and a password, as follows: - -```sh -$ curl -H "Content-Type: application/json" -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens -{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"} -``` - -The ``sha1`` (the token) is only returned once and is not stored in -plain-text. It will not be displayed when listing tokens with a `GET` -request; e.g. - -```sh -$ curl --url https://yourusername:password@gitea.your.host/api/v1/users/<username>/tokens -[{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}] -``` - -To use the API with basic authentication with two factor authentication -enabled, you'll need to send an additional header that contains the one -time password (6 digitrotating token). -An example of the header is `X-Gitea-OTP: 123456` where `123456` -is where you'd place the code from your authenticator. -Here is how the request would look like in curl: - -```sh -$ curl -H "X-Gitea-OTP: 123456" --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens -``` - -You can also create an API key token via your Gitea installation's web -interface: `Settings | Applications | Generate New Token`. - -## OAuth2 Provider - -Access tokens obtained from Gitea's [OAuth2 provider](development/oauth2-provider.md) are accepted by these methods: - -- `Authorization bearer ...` header in HTTP headers -- `token=...` parameter in URL query string -- `access_token=...` parameter in URL query string - -### More on the `Authorization:` header - -For historical reasons, Gitea needs the word `token` included before -the API key token in an authorization header, like this: - -```sh -Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675 -``` - -In a `curl` command, for instance, this would look like: - -```sh -curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \ - -H "accept: application/json" \ - -H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \ - -H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i -``` - -As mentioned above, the token used is the same one you would use in -the `token=` string in a GET request. - -## Pagination - -The API supports pagination. The `page` and `limit` parameters are used to specify the page number and the number of items per page. As well, the `Link` header is returned with the next, previous, and last page links if there are more than one pages. The `x-total-count` is also returned to indicate the total number of items. - -```sh -curl -v "http://localhost/api/v1/repos/search?limit=1" -... -< link: <http://localhost/api/v1/repos/search?limit=1&page=2>; rel="next",<http://localhost/api/v1/repos/search?limit=1&page=5252>; rel="last" -... -< x-total-count: 5252 -``` - -## API Guide - -API Reference guide is auto-generated by swagger and available on: -`https://gitea.your.host/api/swagger` -or on the -[Gitea instance](https://gitea.com/api/swagger) - -The OpenAPI document is at: -`https://gitea.your.host/swagger.v1.json` - -## Sudo - -The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo. - -## SDKs - -- [Official go-sdk](https://gitea.com/gitea/go-sdk) -- [more](https://gitea.com/gitea/awesome-gitea#user-content-sdk) diff --git a/docs/content/development/api-usage.zh-cn.md b/docs/content/development/api-usage.zh-cn.md deleted file mode 100644 index d7aca16f7f..0000000000 --- a/docs/content/development/api-usage.zh-cn.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -date: "2018-06-24:00:00+02:00" -title: "API 使用指南" -slug: "api-usage" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /zh-cn/api-usage -menu: - sidebar: - parent: "development" - name: "API 使用指南" - sidebar_position: 40 - identifier: "api-usage" ---- - -# Gitea API 使用指南 - -## 开启/配置 API 访问 - -通常情况下, `ENABLE_SWAGGER` 默认开启并且参数 `MAX_RESPONSE_ITEMS` 默认为 50。您可以从 [Config Cheat Sheet](administration/config-cheat-sheet.md) 中获取更多配置相关信息。 - -## 通过 API 认证 - -Gitea 支持以下几种 API 认证方式: - -- HTTP basic authentication 方式 -- 通过指定 `token=...` URL 查询参数方式 -- 通过指定 `access_token=...` URL 查询参数方式 -- 通过指定 `Authorization: token ...` HTTP header 方式 - -以上提及的认证方法接受相同的 apiKey token 类型,您可以在编码时通过查阅代码更好地理解这一点。 -Gitea 调用解析查询参数以及头部信息来获取 token 的代码可以在 [modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47) 中找到。 - -您可以通过您的 gitea web 界面来创建 apiKey token: -`Settings | Applications | Generate New Token`. - -### 关于 `Authorization:` header - -由于一些历史原因,Gitea 需要在 header 的 apiKey token 里引入前缀 `token`,类似于如下形式: - -``` -Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675 -``` - -以 `curl` 命令为例,它会以如下形式携带在请求中: - -``` -curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \ - -H "accept: application/json" \ - -H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \ - -H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i -``` - -正如上例所示,您也可以在 GET 请求中使用同一个 token 并以 `token=` 的查询参数形式携带 token 来进行认证。 - -## 通过 API 列出您发布的令牌 - -`/users/:name/tokens` 是一个特殊的接口,需要您使用 basic authentication 进行认证,具体原因在 issue 中 -[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346) 有所提及,使用方法如下所示: - -### 使用 Basic authentication 认证 - -``` -$ curl --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens -[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}] -``` - -## 使用 Sudo 方式请求 API - -此 API 允许管理员借用其他用户身份进行 API 请求。只需在请求中指定查询参数 `sudo=` 或是指定 header 中的 `Sudo:` 为需要使用的用户 username 即可。 diff --git a/docs/content/development/hacking-on-gitea.en-us.md b/docs/content/development/hacking-on-gitea.en-us.md deleted file mode 100644 index 004e803827..0000000000 --- a/docs/content/development/hacking-on-gitea.en-us.md +++ /dev/null @@ -1,374 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Hacking on Gitea" -slug: "hacking-on-gitea" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /en-us/hacking-on-gitea -menu: - sidebar: - parent: "development" - name: "Hacking on Gitea" - sidebar_position: 10 - identifier: "hacking-on-gitea" ---- - -# Hacking on Gitea - -## Quickstart - -To get a quick working development environment you could use Gitpod. - -[![Open in Gitpod](/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea) - -## Installing go - -You should [install go](https://go.dev/doc/install) and set up your go -environment correctly. - -Next, [install Node.js with npm](https://nodejs.org/en/download/) which is -required to build the JavaScript and CSS files. The minimum supported Node.js -version is @minNodeVersion@ and the latest LTS version is recommended. - -**Note**: When executing make tasks that require external tools, like -`make watch-backend`, Gitea will automatically download and build these as -necessary. To be able to use these you must have the `"$GOPATH"/bin` directory -on the executable path. If you don't add the go bin directory to the -executable path you will have to manage this yourself. - -**Note 2**: Go version @minGoVersion@ or higher is required. -Gitea uses `gofmt` to format source code. However, the results of -`gofmt` can differ by the version of `go`. Therefore it is -recommended to install the version of Go that our continuous integration is -running. As of last update, the Go version should be @goVersion@. - -To lint the template files, ensure [Python](https://www.python.org/) and -[Poetry](https://python-poetry.org/) are installed. - -## Installing Make - -Gitea makes heavy use of Make to automate tasks and improve development. This -guide covers how to install Make. - -### On Linux - -Install with the package manager. - -On Ubuntu/Debian: - -```bash -sudo apt-get install make -``` - -On Fedora/RHEL/CentOS: - -```bash -sudo yum install make -``` - -### On Windows - -One of these three distributions of Make will run on Windows: - -- [Single binary build](http://www.equation.com/servlet/equation.cmd?fa=make). Copy somewhere and add to `PATH`. - - [32-bits version](http://www.equation.com/ftpdir/make/32/make.exe) - - [64-bits version](http://www.equation.com/ftpdir/make/64/make.exe) -- [MinGW-w64](https://www.mingw-w64.org) / [MSYS2](https://www.msys2.org/). - - MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software, it includes MinGW-w64. - - In MingGW-w64, the binary is called `mingw32-make.exe` instead of `make.exe`. Add the `bin` folder to `PATH`. - - In MSYS2, you can use `make` directly. See [MSYS2 Porting](https://www.msys2.org/wiki/Porting/). - - To compile Gitea with CGO_ENABLED (eg: SQLite3), you might need to use [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) instead of MSYS2 gcc, because MSYS2 gcc headers lack some Windows-only CRT functions like `_beginthread`. -- [Chocolatey package](https://chocolatey.org/packages/make). Run `choco install make` - -**Note**: If you are attempting to build using make with Windows Command Prompt, you may run into issues. The above prompts (Git bash, or MinGW) are recommended, however if you only have command prompt (or potentially PowerShell) you can set environment variables using the [set](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) command, e.g. `set TAGS=bindata`. - -## Downloading and cloning the Gitea source code - -The recommended method of obtaining the source code is by using `git clone`. - -```bash -git clone https://github.com/go-gitea/gitea -``` - -(Since the advent of go modules, it is no longer necessary to build go projects -from within the `$GOPATH`, hence the `go get` approach is no longer recommended.) - -## Forking Gitea - -Download the main Gitea source code as above. Then, fork the -[Gitea repository](https://github.com/go-gitea/gitea) on GitHub, -and either switch the git remote origin for your fork or add your fork as another remote: - -```bash -# Rename original Gitea origin to upstream -git remote rename origin upstream -git remote add origin "git@github.com:$GITHUB_USERNAME/gitea.git" -git fetch --all --prune -``` - -or: - -```bash -# Add new remote for our fork -git remote add "$FORK_NAME" "git@github.com:$GITHUB_USERNAME/gitea.git" -git fetch --all --prune -``` - -To be able to create pull requests, the forked repository should be added as a remote -to the Gitea sources. Otherwise, changes can't be pushed. - -## Building Gitea (Basic) - -Take a look at our -[instructions](installation/from-source.md) -for [building from source](installation/from-source.md). - -The simplest recommended way to build from source is: - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -The `build` target will execute both `frontend` and `backend` sub-targets. If the `bindata` tag is present, the frontend files will be compiled into the binary. It is recommended to leave out the tag when doing frontend development so that changes will be reflected. - -See `make help` for all available `make` targets. Also see [`.drone.yml`](https://github.com/go-gitea/gitea/blob/main/.drone.yml) to see how our continuous integration works. - -## Building continuously - -To run and continuously rebuild when source files change: - -```bash -# for both frontend and backend -make watch - -# or: watch frontend files (html/js/css) only -make watch-frontend - -# or: watch backend files (go) only -make watch-backend -``` - -On macOS, watching all backend source files may hit the default open files limit which can be increased via `ulimit -n 12288` for the current shell or in your shell startup file for all future shells. - -### Formatting, code analysis and spell check - -Our continuous integration will reject PRs that fail the code linters (including format check, code analysis and spell check). - -You should format your code: - -```bash -make fmt -``` - -and lint the source code: - -```bash -# lint both frontend and backend code -make lint -# lint only backend code -make lint-backend -``` - -**Note**: The results of `gofmt` are dependent on the version of `go` present. -You should run the same version of go that is on the continuous integration -server as mentioned above. - -### Working on JS and CSS - -Frontend development should follow [Guidelines for Frontend Development](contributing/guidelines-frontend.md) - -To build with frontend resources, either use the `watch-frontend` target mentioned above or just build once: - -```bash -make build && ./gitea -``` - -Before committing, make sure the linters pass: - -```bash -make lint-frontend -``` - -### Configuring local ElasticSearch instance - -Start local ElasticSearch instance using docker: - -```sh -mkdir -p $(pwd)/data/elasticsearch -sudo chown -R 1000:1000 $(pwd)/data/elasticsearch -docker run --rm --memory="4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data/elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3 -``` - -Configure `app.ini`: - -```ini -[indexer] -ISSUE_INDEXER_TYPE = elasticsearch -ISSUE_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 -REPO_INDEXER_ENABLED = true -REPO_INDEXER_TYPE = elasticsearch -REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 -``` - -### Building and adding SVGs - -SVG icons are built using the `make svg` target which compiles the icon sources into the output directory `public/assets/img/svg`. Custom icons can be added in the `web_src/svg` directory. - -### Building the Logo - -The PNG and SVG versions of the Gitea logo are built from a single SVG source file `assets/logo.svg` using the `TAGS="gitea" make generate-images` target. To run it, Node.js and npm must be available. - -The same process can also be used to generate custom logo PNGs from a SVG source file by updating `assets/logo.svg` and running `make generate-images`. Omitting the `gitea` tag will update only the user-designated logo files. - -### Updating the API - -When creating new API routes or modifying existing API routes, you **MUST** -update and/or create [Swagger](https://swagger.io/docs/specification/2-0/what-is-swagger/) -documentation for these using [go-swagger](https://goswagger.io/) comments. -The structure of these comments is described in the [specification](https://goswagger.io/use/spec.html#annotation-syntax). -If you want more information about the Swagger structure, you can look at the -[Swagger 2.0 Documentation](https://swagger.io/docs/specification/2-0/basic-structure/) -or compare with a previous PR adding a new API endpoint, e.g. [PR #5483](https://github.com/go-gitea/gitea/pull/5843/files#diff-2e0a7b644cf31e1c8ef7d76b444fe3aaR20) - -You should be careful not to break the API for downstream users which depend -on a stable API. In general, this means additions are acceptable, but deletions -or fundamental changes to the API will be rejected. - -Once you have created or changed an API endpoint, please regenerate the Swagger -documentation using: - -```bash -make generate-swagger -``` - -You should validate your generated Swagger file: - -```bash -make swagger-validate -``` - -You should commit the changed swagger JSON file. The continuous integration -server will check that this has been done using: - -```bash -make swagger-check -``` - -**Note**: Please note you should use the Swagger 2.0 documentation, not the -OpenAPI 3 documentation. - -### Creating new configuration options - -When creating new configuration options, it is not enough to add them to the -`modules/setting` files. You should add information to `custom/conf/app.ini` -and to the -[configuration cheat sheet](administration/config-cheat-sheet.md) -found in `docs/content/doc/administer/config-cheat-sheet.en-us.md` - -### Changing the logo - -When changing the Gitea logo SVG, you will need to run and commit the results -of: - -```bash -make generate-images -``` - -This will create the necessary Gitea favicon and others. - -### Database Migrations - -If you make breaking changes to any of the database persisted structs in the -`models/` directory, you will need to make a new migration. These can be found -in `models/migrations/`. You can ensure that your migrations work for the main -database types using: - -```bash -make test-sqlite-migration # with SQLite switched for the appropriate database -``` - -## Testing - -There are two types of test run by Gitea: Unit tests and Integration Tests. - -### Unit Tests - -Unit tests are covered by `*_test.go` in `go test` system. -You can set the environment variable `GITEA_UNIT_TESTS_LOG_SQL=1` to display all SQL statements when running the tests in verbose mode (i.e. when `GOTESTFLAGS=-v` is set). - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests -``` - -### Integration Tests - -Unit tests will not and cannot completely test Gitea alone. Therefore, we -have written integration tests; however, these are database dependent. - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite -``` - -will run the integration tests in an SQLite environment. Integration tests -require `git lfs` to be installed. Other database tests are available but -may need adjustment to the local environment. - -Take a look at [`tests/integration/README.md`](https://github.com/go-gitea/gitea/blob/main/tests/integration/README.md) -for more information and how to run a single test. - -### Testing for a PR - -Our continuous integration will test the code passes its unit tests and that -all supported databases will pass integration test in a Docker environment. -Migration from several recent versions of Gitea will also be tested. - -Please submit your PR with additional tests and integration tests as -appropriate. - -## Documentation for the website - -Documentation for the website is found in `docs/`. If you change this you -can test your changes to ensure that they pass continuous integration using: - -```bash -make lint-md -``` - -## Visual Studio Code - -A `launch.json` and `tasks.json` are provided within `contrib/ide/vscode` for -Visual Studio Code. Look at -[`contrib/ide/README.md`](https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md) -for more information. - -## GoLand - -Clicking the `Run Application` arrow on the function `func main()` in `/main.go` -can quickly start a debuggable Gitea instance. - -The `Output Directory` in `Run/Debug Configuration` MUST be set to the -gitea project directory (which contains `main.go` and `go.mod`), -otherwise, the started instance's working directory is a GoLand's temporary directory -and prevents Gitea from loading dynamic resources (eg: templates) in a development environment. - -To run unit tests with SQLite in GoLand, set `-tags sqlite,sqlite_unlock_notify` -in `Go tool arguments` of `Run/Debug Configuration`. - -## Submitting PRs - -Once you're happy with your changes, push them up and open a pull request. It -is recommended that you allow Gitea Managers and Owners to modify your PR -branches as we will need to update it to main before merging and/or may be -able to help fix issues directly. - -Any PR requires two approvals from the Gitea maintainers and needs to pass the -continuous integration. Take a look at our -[`CONTRIBUTING.md`](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md) -document. - -If you need more help pop on to [Discord](https://discord.gg/gitea) #Develop -and chat there. - -That's it! You are ready to hack on Gitea. diff --git a/docs/content/development/hacking-on-gitea.zh-cn.md b/docs/content/development/hacking-on-gitea.zh-cn.md deleted file mode 100644 index 7dfea30538..0000000000 --- a/docs/content/development/hacking-on-gitea.zh-cn.md +++ /dev/null @@ -1,343 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "玩转 Gitea" -slug: "hacking-on-gitea" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /zh-cn/hacking-on-gitea -menu: - sidebar: - parent: "development" - name: "玩转 Gitea" - sidebar_position: 10 - identifier: "hacking-on-gitea" ---- - -# Hacking on Gitea - -## 快速入门 - -要获得快速工作的开发环境,您可以使用 Gitpod。 - -[![在 Gitpod 中打开](/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea) - -## 安装 Golang - -您需要 [安装 go]( https://go.dev/doc/install ) 并设置您的 go 环境。 - -接下来,[使用 npm 安装 Node.js](https://nodejs.org/en/download/) ,这是构建 -JavaScript 和 CSS 文件的必要工具。最低支持的 Node.js 版本是 @minNodeVersion@ -并且推荐使用最新的 LTS 版本。 - -**注意** :当执行需要外部工具的 make 任务时,比如 -`make watch-backend`,Gitea 会自动下载并构建这些必要的组件。为了能够使用这些,你必须 -将 `"$GOPATH"/bin` 目录加入到可执行路径上。如果你不把go bin目录添加到可执行路径你必须手动 -指定可执行程序路径。 - -**注意2** :Go版本 @minGoVersion@ 或更高版本是必须的。Gitea 使用 `gofmt` 来 -格式化源代码。然而,`gofmt` 的结果可能因 `go` 的版本而有差异。因此推荐安装我们持续集成使用 -的 Go版本。截至上次更新,Go 版本应该是 @goVersion@。 - -## 安装 Make - -Gitea 大量使用 `Make` 来自动化任务和改进开发。本指南涵盖了如何安装 Make。 - -### 在 Linux 上 - -使用包管理器安装。 - -在 Ubuntu/Debian 上: - -```bash -sudo apt-get install make -``` - -在 Fedora/RHEL/CentOS 上: - -```bash -sudo yum install make -``` - -### 在 Windows 上 - -Make 的这三个发行版都可以在 Windows 上运行: - -- [单个二进制构建]( http://www.equation.com/servlet/equation.cmd?fa=make )。复制到某处并添加到 `PATH`。 - - [32 位版本](http://www.equation.com/ftpdir/make/32/make.exe) - - [64 位版本](http://www.equation.com/ftpdir/make/64/make.exe) -- [MinGW-w64](https://www.mingw-w64.org) / [MSYS2](https://www.msys2.org/)。 - - MSYS2 是一个工具和库的集合,为您提供一个易于使用的环境来构建、安装和运行本机 Windows 软件,它包括 MinGW-w64。 - - 在 MingGW-w64 中,二进制文件称为 `mingw32-make.exe` 而不是 `make.exe`。将 `bin` 文件夹添加到 `PATH`。 - - 在 MSYS2 中,您可以直接使用 `make`。请参阅 [MSYS2 移植](https://www.msys2.org/wiki/Porting/)。 - - 要使用 CGO_ENABLED(例如:SQLite3)编译 Gitea,您可能需要使用 [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) 而不是 MSYS2 gcc,因为 MSYS2 gcc 标头缺少一些 Windows -只有 CRT 函数像 _beginthread 一样。 -- [Chocolatey包管理器]( https://chocolatey.org/packages/make )。运行`choco install make` - -**注意** :如果您尝试在 Windows 命令提示符下使用 make 进行构建,您可能会遇到问题。建议使用上述提示(Git bash 或 MinGW),但是如果您只有命令提示符(或可能是 PowerShell),则可以使用 [set](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) 命令,例如 `set TAGS=bindata`。 - -## 下载并克隆 Gitea 源代码 - -获取源代码的推荐方法是使用 `git clone`。 - -```bash -git clone https://github.com/go-gitea/gitea -``` - -(自从go modules出现后,不再需要构建 go 项目从 `$GOPATH` 中获取,因此不再推荐使用 `go get` 方法。) - -## 派生 Gitea - -如上所述下载主要的 Gitea 源代码。然后,派生 [Gitea 仓库](https://github.com/go-gitea/gitea), -并为您的本地仓库切换 git 远程源,或添加另一个远程源: - -```bash -# 将原来的 Gitea origin 重命名为 upstream -git remote rename origin upstream -git remote add origin "git@github.com:$GITHUB_USERNAME/gitea.git" -git fetch --all --prune -``` - -或者: - -```bash -# 为我们的 fork 添加新的远程 -git remote add "$FORK_NAME" "git@github.com:$GITHUB_USERNAME/gitea.git" -git fetch --all --prune -``` - -为了能够创建合并请求,应将分叉存储库添加为 Gitea 本地仓库的远程,否则无法推送更改。 - -## 构建 Gitea(基本) - -看看我们的 -[说明](installation/from-source.md) -关于如何[从源代码构建](installation/from-source.md) 。 - -从源代码构建的最简单推荐方法是: - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -`build` 目标将同时执行 `frontend` 和 `backend` 子目标。如果存在 `bindata` 标签,资源文件将被编译成二进制文件。建议在进行前端开发时省略 `bindata` 标签,以便实时反映更改。 - -有关所有可用的 `make` 目标,请参阅 `make help`。另请参阅 [`.drone.yml`](https://github.com/go-gitea/gitea/blob/main/.drone.yml) 以了解我们的持续集成是如何工作的。 - -## 持续构建 - -要在源文件更改时运行并持续构建: - -```bash -# 对于前端和后端 -make watch - -# 或者:只看前端文件(html/js/css) -make watch-frontend - -# 或者:只看后端文件 (go) -make watch-backend -``` - -在 macOS 上,监视所有后端源文件可能会达到默认的打开文件限制,这可以通过当前 shell 的 `ulimit -n 12288` 或所有未来 shell 的 shell 启动文件来增加。 - -### 格式化、代码分析和拼写检查 - -我们的持续集成将拒绝未通过代码检查(包括格式检查、代码分析和拼写检查)的 PR。 - -你应该格式化你的代码: - -```bash -make fmt -``` - -并检查源代码: - -```bash -# lint 前端和后端代码 -make lint -# 仅 lint 后端代码 -make lint-backend -``` - -**注意** :`gofmt` 的结果取决于 `go` 的版本。您应该运行与持续集成相同的 go 版本。 - -### 处理 JS 和 CSS - -前端开发应遵循 [Guidelines for Frontend Development](contributing/guidelines-frontend.md)。 - -要使用前端资源构建,请使用上面提到的“watch-frontend”目标或只构建一次: - -```bash -make build && ./gitea -``` - -在提交之前,确保 linters 通过: - -```bash -make lint-frontend -``` - -### 配置本地 ElasticSearch 实例 - -使用 docker 启动本地 ElasticSearch 实例: - -```sh -mkdir -p $(pwd) /data/elasticsearch -sudo chown -R 1000:1000 $(pwd) /data/elasticsearch -docker run --rm --memory= "4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data /elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3 -``` - -配置`app.ini`: - -```ini -[indexer] -ISSUE_INDEXER_TYPE = elasticsearch -ISSUE_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 -REPO_INDEXER_ENABLED = true -REPO_INDEXER_TYPE = elasticsearch -REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 -``` - -### 构建和添加 SVGs - -SVG 图标是使用 `make svg` 命令构建的,该命令将图标资源编译到输出目录 `public/assets/img/svg` 中。可以在 `web_src/svg` 目录中添加自定义图标。 - -### 构建 Logo - -Gitea Logo的 PNG 和 SVG 版本是使用 `TAGS="gitea" make generate-images` 目标从单个 SVG 源文件 assets/logo.svg 构建的。要运行它,Node.js 和 npm 必须可用。 - -通过更新 `assets/logo.svg` 并运行 `make generate-images`,同样的过程也可用于从 SVG 源文件生成自定义 Logo PNG。忽略 gitea 编译选项将仅更新用户指定的 LOGO 文件。 - -### 更新 API - -创建新的 API 路由或修改现有的 API 路由时,您**必须** -更新和/或创建 [Swagger](https://swagger.io/docs/specification/2-0/what-is-swagger/) -这些使用 [go-swagger](https://goswagger.io/) 评论的文档。 -[规范]( https://goswagger.io/use/spec.html#annotation-syntax )中描述了这些注释的结构。 -如果您想了解更多有关 Swagger 结构的信息,可以查看 -[Swagger 2.0 文档](https://swagger.io/docs/specification/2-0/basic-structure/) -或与添加新 API 端点的先前 PR 进行比较,例如 [PR #5483](https://github.com/go-gitea/gitea/pull/5843/files#diff-2e0a7b644cf31e1c8ef7d76b444fe3aaR20) - -您应该注意不要破坏下游用户依赖的 API。在稳定的 API 上,一般来说添加是可以接受的,但删除 -或对 API 进行根本性更改将会被拒绝。 - -创建或更改 API 端点后,请用以下命令重新生成 Swagger 文档: - -```bash -make generate-swagger -``` - -您应该验证生成的 Swagger 文件: - -```bash -make swagger-validate -``` - -您应该提交更改后的 swagger JSON 文件。持续集成服务器将使用以下方法检查是否已完成: - -```bash -make swagger-check -``` - -**注意** :请注意,您应该使用 Swagger 2.0 文档,而不是 OpenAPI 3 文档。 - -### 创建新的配置选项 - -创建新的配置选项时,将它们添加到 `modules/setting` 的对应文件。您应该将信息添加到 `custom/conf/app.ini` -并到[配置备忘单](administration/config-cheat-sheet.md) -在 `docs/content/doc/advanced/config-cheat-sheet.zh-cn.md` 中找到 - -### 更改Logo - -更改 Gitea Logo SVG 时,您将需要运行并提交结果的: - -```bash -make generate-images -``` - -这将创建必要的 Gitea 图标和其他图标。 - -### 数据库迁移 - -如果您对数据库中的任何数据库持久结构进行重大更改 -`models/` 目录,您将需要进行新的迁移。可以找到这些 -在 `models/migrations/` 中。您可以确保您的迁移适用于主要 -数据库类型使用: - -```bash -make test-sqlite-migration # 将 SQLite 切换为适当的数据库 -``` - -## 测试 - -Gitea 运行两种类型的测试:单元测试和集成测试。 - -### 单元测试 - -`go test` 系统中的`*_test.go` 涵盖了单元测试。 -您可以设置环境变量 `GITEA_UNIT_TESTS_LOG_SQL=1` 以在详细模式下运行测试时显示所有 SQL 语句(即设置`GOTESTFLAGS=-v` 时)。 - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests -``` - -### 集成测试 - -单元测试不会也不能完全单独测试 Gitea。因此,我们编写了集成测试;但是,这些依赖于数据库。 - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite -``` - -将在 SQLite 环境中运行集成测试。集成测试需要安装 `git lfs`。其他数据库测试可用,但 -可能需要适应当地环境。 - -看看 [`tests/integration/README.md`](https://github.com/go-gitea/gitea/blob/main/tests/integration/README.md) 有关更多信息以及如何运行单个测试。 - -### 测试 PR - -我们的持续集成将测试代码是否通过了单元测试,并且所有支持的数据库都将在 Docker 环境中通过集成测试。 -还将测试从几个最新版本的 Gitea 迁移。 - -请在PR中附带提交适当的单元测试和集成测试。 - -## 网站文档 - -该网站的文档位于 `docs/` 中。如果你改变了文档内容,你可以使用以下测试方法进行持续集成: - -```bash -make lint-md -``` - -## Visual Studio Code - -`contrib/ide/vscode` 中为 Visual Studio Code 提供了 `launch.json` 和 `tasks.json`。查看 -[`contrib/ide/README.md`](https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md) 了解更多信息。 - -## Goland - -单击 `/main.go` 中函数 `func main()` 上的 `Run Application` 箭头 -可以快速启动一个可调试的 Gitea 实例。 - -`Run/Debug Configuration` 中的 `Output Directory` 必须设置为 -gitea 项目目录(包含 `main.go` 和 `go.mod`), -否则,启动实例的工作目录是 GoLand 的临时目录 -并防止 Gitea 在开发环境中加载动态资源(例如:模板)。 - -要在 GoLand 中使用 SQLite 运行单元测试,请设置 `-tags sqlite,sqlite_unlock_notify` -在 `运行/调试配置` 的 `Go 工具参数` 中。 - -## 提交 PR - -对更改感到满意后,将它们推送并打开拉取请求。它建议您允许 Gitea Managers 和 Owners 修改您的 PR -分支,因为我们需要在合并之前将其更新为 main 和/或可能是能够直接帮助解决问题。 - -任何 PR 都需要 Gitea 维护者的两次批准,并且需要通过持续集成。看看我们的 -[CONTRIBUTING.md](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md) -文档。 - -如果您需要更多帮助,请访问 [Discord](https://discord.gg/gitea) #Develop 频道 -并在那里聊天。 - -现在,您已准备好 Hacking Gitea。 diff --git a/docs/content/development/integrations.en-us.md b/docs/content/development/integrations.en-us.md deleted file mode 100644 index 66ea36243b..0000000000 --- a/docs/content/development/integrations.en-us.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -date: "2019-04-15T17:29:00+08:00" -title: "Integrations" -slug: "integrations" -sidebar_position: 65 -toc: false -draft: false -aliases: - - /en-us/integrations -menu: - sidebar: - parent: "development" - name: "Integrations" - sidebar_position: 65 - identifier: "integrations" ---- - -# Integrations - -Gitea has a wonderful community of third-party integrations, as well as first-class support in various other -projects. - -We are curating a list over at [awesome-gitea](https://gitea.com/gitea/awesome-gitea) to track these! - -If you are looking for [CI/CD](https://gitea.com/gitea/awesome-gitea#user-content-devops), -an [SDK](https://gitea.com/gitea/awesome-gitea#user-content-sdk), -or even some extra [themes](https://gitea.com/gitea/awesome-gitea#user-content-themes), -you can find them listed in the [awesome-gitea](https://gitea.com/gitea/awesome-gitea) repository! - -## Pre-Fill New File name and contents - -If you'd like to open a new file with a given name and contents, -you can do so with query parameters: - -```txt -GET /{{org}}/{{repo}}/_new/{{filepath}} - ?filename={{filename}} - &value={{content}} -``` - -For example: - -```txt -GET https://git.example.com/johndoe/bliss/_new/articles/ - ?filename=hello-world.md - &value=Hello%2C%20World! -``` diff --git a/docs/content/development/integrations.zh-cn.md b/docs/content/development/integrations.zh-cn.md deleted file mode 100644 index 0b8ca0d5a0..0000000000 --- a/docs/content/development/integrations.zh-cn.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -date: "2023-05-25T17:29:00+08:00" -title: "集成" -slug: "integrations" -sidebar_position: 65 -toc: false -draft: false -aliases: - - /zh-cn/integrations -menu: - sidebar: - parent: "development" - name: "集成" - sidebar_position: 65 - identifier: "integrations" ---- - -# 集成 - -Gitea拥有一个出色的第三方集成社区,以及在其他各种项目中的一流支持。 - -我们正在[awesome-gitea](https://gitea.com/gitea/awesome-gitea)上整理一个列表来跟踪这些集成! - -如果你正在寻找[CI/CD](https://gitea.com/gitea/awesome-gitea#user-content-devops), -一个[SDK](https://gitea.com/gitea/awesome-gitea#user-content-sdk), -甚至一些额外的[主题](https://gitea.com/gitea/awesome-gitea#user-content-themes), -你可以在[awesome-gitea](https://gitea.com/gitea/awesome-gitea)中找到它们的列表! - -## 预填新文件名和内容 - -如果你想打开一个具有给定名称和内容的新文件, -你可以使用查询参数来实现: - -```txt -GET /{{org}}/{{repo}}/_new/{{filepath}} - ?filename={{filename}} - &value={{content}} -``` - -例如: - -```txt -GET https://git.example.com/johndoe/bliss/_new/articles/ - ?filename=hello-world.md - &value=Hello%2C%20World! -``` diff --git a/docs/content/development/migrations.en-us.md b/docs/content/development/migrations.en-us.md deleted file mode 100644 index 1e72f1b520..0000000000 --- a/docs/content/development/migrations.en-us.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -date: "2019-04-15T17:29:00+08:00" -title: "Migrations Interfaces" -slug: "migrations-interfaces" -sidebar_position: 55 -toc: false -draft: false -aliases: - - /en-us/migrations-interfaces -menu: - sidebar: - parent: "development" - name: "Migrations Interfaces" - sidebar_position: 55 - identifier: "migrations-interfaces" ---- - -# Migration Features - -Complete migrations were introduced in Gitea 1.9.0. It defines two interfaces to support migrating -repository data from other Git host platforms to Gitea or, in the future, migrating Gitea data to other Git host platforms. - -Currently, migrations from GitHub, GitLab, and other Gitea instances are implemented. - -First of all, Gitea defines some standard objects in packages [modules/migration](https://github.com/go-gitea/gitea/tree/main/modules/migration). -They are `Repository`, `Milestone`, `Release`, `ReleaseAsset`, `Label`, `Issue`, `Comment`, `PullRequest`, `Reaction`, `Review`, `ReviewComment`. - -## Downloader Interfaces - -To migrate from a new Git host platform, there are two steps to be updated. - -- You should implement a `Downloader` which will be used to get repository information. -- You should implement a `DownloaderFactory` which will be used to detect if the URL matches and create the above `Downloader`. - - You'll need to register the `DownloaderFactory` via `RegisterDownloaderFactory` on `init()`. - -You can find these interfaces in [downloader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/downloader.go). - -## Uploader Interface - -Currently, only a `GiteaLocalUploader` is implemented, so we only save downloaded -data via this `Uploader` to the local Gitea instance. Other uploaders are not supported at this time. - -You can find these interfaces in [uploader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/uploader.go). diff --git a/docs/content/development/migrations.zh-cn.md b/docs/content/development/migrations.zh-cn.md deleted file mode 100644 index 923be9046e..0000000000 --- a/docs/content/development/migrations.zh-cn.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -date: "2023-05-25T17:29:00+08:00" -title: "迁移界面" -slug: "migrations-interfaces" -sidebar_position: 55 -toc: false -draft: false -aliases: - - /zh-cn/migrations-interfaces -menu: - sidebar: - parent: "development" - name: "迁移界面" - sidebar_position: 55 - identifier: "migrations-interfaces" ---- - -# 迁移功能 - -完整迁移功能在Gitea 1.9.0版本中引入。它定义了两个接口,用于支持从其他Git托管平台迁移存储库数据到Gitea,或者在将来将Gitea数据迁移到其他Git托管平台。 - -目前已实现了从GitHub、GitLab和其他Gitea实例的迁移。 - -首先,Gitea在包[modules/migration](https://github.com/go-gitea/gitea/tree/main/modules/migration)中定义了一些标准对象。它们是`Repository`、`Milestone`、`Release`、`ReleaseAsset`、`Label`、`Issue`、`Comment`、`PullRequest`、`Reaction`、`Review`、`ReviewComment`。 - -## 下载器接口 - -要从新的Git托管平台迁移,需要进行两个步骤的更新。 - -- 您应该实现一个`Downloader`,用于获取存储库信息。 -- 您应该实现一个`DownloaderFactory`,用于检测URL是否匹配,并创建上述的`Downloader`。 - - 您需要在`init()`中通过`RegisterDownloaderFactory`注册`DownloaderFactory`。 - -您可以在[downloader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/downloader.go)中找到这些接口。 - -## 上传器接口 - -目前,只实现了`GiteaLocalUploader`,因此我们只能通过此Uploader将下载的数据保存到本地的Gitea实例。目前不支持其他上传器。 - -您可以在[uploader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/uploader.go)中找到这些接口。 diff --git a/docs/content/development/oauth2-provider.en-us.md b/docs/content/development/oauth2-provider.en-us.md deleted file mode 100644 index 54674f9246..0000000000 --- a/docs/content/development/oauth2-provider.en-us.md +++ /dev/null @@ -1,214 +0,0 @@ ---- -date: "2023-06-01T08:40:00+08:00" -title: "OAuth2 provider" -slug: "oauth2-provider" -sidebar_position: 41 -toc: false -draft: false -aliases: - - /en-us/oauth2-provider -menu: - sidebar: - parent: "development" - name: "OAuth2 Provider" - sidebar_position: 41 - identifier: "oauth2-provider" ---- - -# OAuth2 provider - -Gitea supports acting as an OAuth2 provider to allow third party applications to access its resources with the user's consent. This feature is available since release 1.8.0. - -## Endpoints - -| Endpoint | URL | -| ------------------------ | ----------------------------------- | -| OpenID Connect Discovery | `/.well-known/openid-configuration` | -| Authorization Endpoint | `/login/oauth/authorize` | -| Access Token Endpoint | `/login/oauth/access_token` | -| OpenID Connect UserInfo | `/login/oauth/userinfo` | -| JSON Web Key Set | `/login/oauth/keys` | - -## Supported OAuth2 Grants - -At the moment Gitea only supports the [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) standard with additional support of the following extensions: - -- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636) -- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) - -To use the Authorization Code Grant as a third party application it is required to register a new application via the "Settings" (`/user/settings/applications`) section of the settings. To test or debug you can use the web-tool https://oauthdebugger.com/. - -## Scopes - -Gitea supports scoped access tokens, which allow users the ability to restrict tokens to operate only on selected url routes. Scopes are grouped by high-level API routes, and further refined to the following: - -- `read`: `GET` routes -- `write`: `POST`, `PUT`, `PATCH`, and `DELETE` routes (in addition to `GET`) - -Gitea token scopes are as follows: - -| Name | Description | -| ---- |------------------------------------------------------------------------------------------------------------------------------------------------------| -| **(no scope)** | Not supported. A scope is required even for public repositories. | -| **activitypub** | `activitypub` API routes: ActivityPub related operations. | -| **read:activitypub** | Grants read access for ActivityPub operations. | -| **write:activitypub** | Grants read/write/delete access for ActivityPub operations. | -| **admin** | `/admin/*` API routes: Site-wide administrative operations (hidden for non-admin accounts). | -| **read:admin** | Grants read access for admin operations, such as getting cron jobs or registered user emails. | -| **write:admin** | Grants read/write/delete access for admin operations, such as running cron jobs or updating user accounts. | -| **issue** | `issues/*`, `labels/*`, `milestones/*` API routes: Issue-related operations. | -| **read:issue** | Grants read access for issues operations, such as getting issue comments, issue attachments, and milestones. | -| **write:issue** | Grants read/write/delete access for issues operations, such as posting or editing an issue comment or attachment, and updating milestones. | -| **misc** | Reserved for future usage. | -| **read:misc** | Reserved for future usage. | -| **write:misc** | Reserved for future usage. | -| **notification** | `notification/*` API routes: user notification operations. | -| **read:notification** | Grants read access to user notifications, such as which notifications users are subscribed to and read new notifications. | -| **write:notification** | Grants read/write/delete access to user notifications, such as marking notifications as read. | -| **organization** | `orgs/*` and `teams/*` API routes: Organization and team management operations. | -| **read:organization** | Grants read access to org and team status, such as listing all orgs a user has visibility to, teams, and team members. | -| **write:organization** | Grants read/write/delete access to org and team status, such as creating and updating teams and updating org settings. | -| **package** | `/packages/*` API routes: Packages operations | -| **read:package** | Grants read access to package operations, such as reading and downloading available packages. | -| **write:package** | Grants read/write/delete access to package operations. Currently the same as `read:package`. | -| **repository** | `/repos/*` API routes except `/repos/issues/*`: Repository file, pull-request, and release operations. | -| **read:repository** | Grants read access to repository operations, such as getting repository files, releases, collaborators. | -| **write:repository** | Grants read/write/delete access to repository operations, such as getting updating repository files, creating pull requests, updating collaborators. | -| **user** | `/user/*` and `/users/*` API routes: User-related operations. | -| **read:user** | Grants read access to user operations, such as getting user repo subscriptions and user settings. | -| **write:user** | Grants read/write/delete access to user operations, such as updating user repo subscriptions, followed users, and user settings. | - -## Pre-configured Applications - -Gitea creates OAuth applications for the following services by default on startup, as we assume that these are universally useful. - -|Application|Description|Client ID| -|-----------|-----------|---------| -|[git-credential-oauth](https://github.com/hickford/git-credential-oauth)|Git credential helper|`a4792ccc-144e-407e-86c9-5e7d8d9c3269`| -|[Git Credential Manager](https://github.com/git-ecosystem/git-credential-manager)|Git credential helper|`e90ee53c-94e2-48ac-9358-a874fb9e0662`| -|[tea](https://gitea.com/gitea/tea)|tea|`d57cb8c4-630c-4168-8324-ec79935e18d4`| - -To prevent unexpected behavior, they are being displayed as locked in the UI and their creation can instead be controlled by the `DEFAULT_APPLICATIONS` parameter in `app.ini`. - -## Client types - -Gitea supports both confidential and public client types, [as defined by RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1). - -For public clients, a redirect URI of a loopback IP address such as `http://127.0.0.1/` allows any port. Avoid using `localhost`, [as recommended by RFC 8252](https://datatracker.ietf.org/doc/html/rfc8252#section-8.3). - -## Examples - -### Confidential client - -**Note:** This example does not use PKCE. - -1. Redirect the user to the authorization endpoint in order to get their consent for accessing the resources: - - ```curl - https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&state=STATE - ``` - - The `CLIENT_ID` can be obtained by registering an application in the settings. The `STATE` is a random string that will be sent back to your application after the user authorizes. The `state` parameter is optional, but should be used to prevent CSRF attacks. - - ![Authorization Page](/authorize.png) - - The user will now be asked to authorize your application. If they authorize it, the user will be redirected to the `REDIRECT_URL`, for example: - - ```curl - https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE - ``` - -2. Using the provided `code` from the redirect, you can request a new application and refresh token. The access token endpoint accepts POST requests with `application/json` and `application/x-www-form-urlencoded` body, for example: - - ```curl - POST https://[YOUR-GITEA-URL]/login/oauth/access_token - ``` - - ```json - { - "client_id": "YOUR_CLIENT_ID", - "client_secret": "YOUR_CLIENT_SECRET", - "code": "RETURNED_CODE", - "grant_type": "authorization_code", - "redirect_uri": "REDIRECT_URI" - } - ``` - - Response: - - ```json - { - "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug", - "token_type": "bearer", - "expires_in": 3600, - "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw" - } - ``` - - The `CLIENT_SECRET` is the unique secret code generated for this application. Please note that the secret will only be visible after you created/registered the application with Gitea and cannot be recovered. If you lose the secret, you must regenerate the secret via the application's settings. - - The `REDIRECT_URI` in the `access_token` request must match the `REDIRECT_URI` in the `authorize` request. - -3. Use the `access_token` to make [API requests](development/api-usage.md#oauth2-provider) to access the user's resources. - -### Public client (PKCE) - -PKCE (Proof Key for Code Exchange) is an extension to the OAuth flow which allows for a secure credential exchange without the requirement to provide a client secret. - -**Note**: Please ensure you have registered your OAuth application as a public client. - -To achieve this, you have to provide a `code_verifier` for every authorization request. A `code_verifier` has to be a random string with a minimum length of 43 characters and a maximum length of 128 characters. It can contain alphanumeric characters as well as the characters `-`, `.`, `_` and `~`. - -Using this `code_verifier` string, a new one called `code_challenge` is created by using one of two methods: - -- If you have the required functionality on your client, set `code_challenge` to be a URL-safe base64-encoded string of the SHA256 hash of `code_verifier`. In that case, your `code_challenge_method` becomes `S256`. -- If you are unable to do so, you can provide your `code_verifier` as a plain string to `code_challenge`. Then you have to set your `code_challenge_method` as `plain`. - -After you have generated this values, you can continue with your request. - -1. Redirect the user to the authorization endpoint in order to get their consent for accessing the resources: - - ```curl - https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&code_challenge_method=CODE_CHALLENGE_METHOD&code_challenge=CODE_CHALLENGE&state=STATE - ``` - - The `CLIENT_ID` can be obtained by registering an application in the settings. The `STATE` is a random string that will be sent back to your application after the user authorizes. The `state` parameter is optional, but should be used to prevent CSRF attacks. - - ![Authorization Page](/authorize.png) - - The user will now be asked to authorize your application. If they authorize it, the user will be redirected to the `REDIRECT_URL`, for example: - - ```curl - https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE - ``` - -2. Using the provided `code` from the redirect, you can request a new application and refresh token. The access token endpoint accepts POST requests with `application/json` and `application/x-www-form-urlencoded` body, for example: - - ```curl - POST https://[YOUR-GITEA-URL]/login/oauth/access_token - ``` - - ```json - { - "client_id": "YOUR_CLIENT_ID", - "code": "RETURNED_CODE", - "grant_type": "authorization_code", - "redirect_uri": "REDIRECT_URI", - "code_verifier": "CODE_VERIFIER", - } - ``` - - Response: - - ```json - { - "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug", - "token_type": "bearer", - "expires_in": 3600, - "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw" - } - ``` - - The `REDIRECT_URI` in the `access_token` request must match the `REDIRECT_URI` in the `authorize` request. - -3. Use the `access_token` to make [API requests](development/api-usage.md#oauth2-provider) to access the user's resources. diff --git a/docs/content/development/oauth2-provider.zh-cn.md b/docs/content/development/oauth2-provider.zh-cn.md deleted file mode 100644 index 80d8469414..0000000000 --- a/docs/content/development/oauth2-provider.zh-cn.md +++ /dev/null @@ -1,137 +0,0 @@ ---- -date: "2019-04-19:44:00+01:00" -title: "OAuth2 提供者" -slug: "oauth2-provider" -sidebar_position: 41 -toc: false -draft: false -aliases: - - /zh-cn/oauth2-provider -menu: - sidebar: - parent: "development" - name: "OAuth2 提供者" - sidebar_position: 41 - identifier: "oauth2-provider" ---- - -# OAuth2 提供者 - -Gitea 支持作为 OAuth2 提供者,允许第三方应用程序在用户同意的情况下访问其资源。此功能自 1.8.0 版起可用。 - -## 端点 - -| 端点 | URL | -| ------------------------ | ----------------------------------- | -| OpenID Connect Discovery | `/.well-known/openid-configuration` | -| Authorization Endpoint | `/login/oauth/authorize` | -| Access Token Endpoint | `/login/oauth/access_token` | -| OpenID Connect UserInfo | `/login/oauth/userinfo` | -| JSON Web Key Set | `/login/oauth/keys` | - -## 支持的 OAuth2 授权 - -目前 Gitea 仅支持 [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) 标准,并额外支持以下扩展: - -- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636) -- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) - -要将 Authorization Code Grant 作为第三方应用程序,您需要通过在设置中添加一个新的 "应用程序" (`/user/settings/applications`)。 - -## 范围 - -Gitea 支持以下令牌范围: - -| 名称 | 介绍 | -| ---- | ----------- | -| **(no scope)** | 授予对公共用户配置文件和公共存储库的只读访问权限 | -| **repo** | 完全控制所有存储库 | -| **repo:status** | 授予对所有存储库中提交状态的读/写访问权限 | -| **public_repo** | 仅授予对公共存储库的读/写访问权限 | -| **admin:repo_hook** | 授予对所有存储库的 Hooks 访问权限,该权限已包含在 `repo` 范围中 | -| **write:repo_hook** | 授予对存储库 Hooks 的读/写访问权限 | -| **read:repo_hook** | 授予对存储库 Hooks 的只读访问权限 | -| **admin:org** | 授予对组织设置的完全访问权限 | -| **write:org** | 授予对组织设置的读/写访问权限 | -| **read:org** | 授予对组织设置的只读访问权限 | -| **admin:public_key** | 授予公钥管理的完全访问权限 | -| **write:public_key** | 授予对公钥的读/写访问权限 | -| **read:public_key** | 授予对公钥的只读访问权限 | -| **admin:org_hook** | 授予对组织级别 Hooks 的完全访问权限 | -| **admin:user_hook** | 授予对用户级别 Hooks 的完全访问权限 | -| **notification** | 授予对通知的完全访问权限 | -| **user** | 授予对用户个人资料信息的完全访问权限 | -| **read:user** | 授予对用户个人资料的读取权限 | -| **user:email** | 授予对用户电子邮件地址的读取权限 | -| **user:follow** | 授予访问权限以关注/取消关注用户 | -| **delete_repo** | 授予删除存储库的权限 | -| **package** | 授予对托管包的完全访问权限 | -| **write:package** | 授予对包的读/写访问权限 | -| **read:package** | 授予对包的读取权限 | -| **delete:package** | 授予对包的删除权限 | -| **admin:gpg_key** | 授予 GPG 密钥管理的完全访问权限 | -| **write:gpg_key** | 授予对 GPG 密钥的读/写访问权限 | -| **read:gpg_key** | 授予对 GPG 密钥的只读访问权限 | -| **admin:application** | 授予应用程序管理的完全访问权限 | -| **write:application** | 授予应用程序管理的读/写访问权限 | -| **read:application** | 授予应用程序管理的读取权限 | -| **sudo** | 允许以站点管理员身份执行操作 | - -## 客户端类型 - -Gitea 支持私密和公共客户端类型,[参见 RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1). - -对于公共客户端, 允许在本地回环地址的重定向 URI 中使用任意端口,例如 `http://127.0.0.1/`。根据 [RFC 8252 的建议](https://datatracker.ietf.org/doc/html/rfc8252#section-8.3),请避免使用 `localhost`。 - -## 示例 - -**注意:** 该示例中尚未使用 PKCE。 - -1. 将用户重定向到授权端点,以获得他们的访问资源授权: - - ```curl - https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE - ``` - - 在设置中注册应用程序以获得 `CLIENT_ID`。`STATE` 是一个随机字符串,它将在获得用户授权后发送回您的应用程序。`state` 参数是可选的,但您应该使用它来防止 CSRF 攻击。 - - ![Authorization Page](/authorize.png) - - 用户将会被询问是否授权给您的应用程序。如果他们同意了授权,用户将会被重定向到 `REDIRECT_URL`,例如: - - ```curl - https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE - ``` - -2. 使用重定向提供的 `code`,您可以请求一个新的应用程序和 Refresh Token。Access Token Endpoint 接受 `application/json` 或 `application/x-www-form-urlencoded` 类型的 POST 请求,例如: - - ```curl - POST https://[YOUR-GITEA-URL]/login/oauth/access_token - ``` - - ```json - { - "client_id": "YOUR_CLIENT_ID", - "client_secret": "YOUR_CLIENT_SECRET", - "code": "RETURNED_CODE", - "grant_type": "authorization_code", - "redirect_uri": "REDIRECT_URI" - } - ``` - - 返回: - - ```json - { - "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug", - "token_type": "bearer", - "expires_in": 3600, - "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw" - } - ``` - - `CLIENT_SECRET` 是生成给应用程序的唯一密钥。请注意,该密钥只会在您使用 Gitea 创建/注册应用程序后出现一次。如果您丢失了密钥,您必须在应用程序设置中重新生成密钥。 - - `access_token` 请求中的 `REDIRECT_URI` 必须与 `authorize` 请求中的 `REDIRECT_URI` 相符。 - -3. 使用 `access_token` 来构造 [API 请求](development/api-usage.md#oauth2-provider) 以读写用户的资源。 diff --git a/docs/content/help.en-us.md b/docs/content/help.en-us.md deleted file mode 100644 index 5a7f4a42bc..0000000000 --- a/docs/content/help.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2017-01-20T15:00:00+08:00" -title: "Help" -slug: "help" -sidebar_position: 5 -toc: false -draft: false -menu: - sidebar: - name: "Help" - sidebar_position: 100 - identifier: "help" ---- diff --git a/docs/content/help.zh-cn.md b/docs/content/help.zh-cn.md deleted file mode 100644 index 60b63bc28a..0000000000 --- a/docs/content/help.zh-cn.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2017-01-20T15:00:00+08:00" -title: "帮助" -slug: "help" -sidebar_position: 5 -toc: false -draft: false -menu: - sidebar: - name: "帮助" - sidebar_position: 100 - identifier: "help" ---- diff --git a/docs/content/help/_index.en-us.md b/docs/content/help/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/help/_index.en-us.md +++ /dev/null diff --git a/docs/content/help/_index.zh-cn.md b/docs/content/help/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/help/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/help/faq.en-us.md b/docs/content/help/faq.en-us.md deleted file mode 100644 index e94f342198..0000000000 --- a/docs/content/help/faq.en-us.md +++ /dev/null @@ -1,434 +0,0 @@ ---- -date: "2019-04-05T16:00:00+02:00" -title: "FAQ" -slug: "faq" -sidebar_position: 5 -toc: false -draft: false -aliases: - - /en-us/faq -menu: - sidebar: - parent: "help" - name: "FAQ" - sidebar_position: 5 - identifier: "faq" ---- - -# Frequently Asked Questions - -This page contains some common questions and answers. - -For more help resources, check all [Support Options](help/support.md). - -## Difference between 1.x and 1.x.x downloads, how can I get latest stable release with bug fixes? - -Version 1.20.x will be used for this example. - -On our [downloads page](https://dl.gitea.com/gitea/) you will see a 1.20 directory, as well as directories for 1.20.0, 1.20.1. - -The 1.20 directory is the nightly build, which is built on each merged commit to the [`release/v1.20`](https://github.com/go-gitea/gitea/tree/release/v1.20) branch. - -The 1.20.0 directory is a release build that was created when the [`v1.20.0`](https://github.com/go-gitea/gitea/releases/tag/v1.20.0) tag was created. - -The nightly builds (1.x) downloads will change as commits are merged to their respective branch, they contain the latest changes/fixes before a tag release is built. - -If a bug fix is targeted on 1.20.1 but 1.20.1 is not released yet, you can get the "1.20-nightly" build to get the bug fix. - -## How to migrate from Gogs/GitHub/etc. to Gitea - -To migrate from Gogs to Gitea: - -- [Gogs version 0.11.46.0418](https://github.com/go-gitea/gitea/issues/4286) - -To migrate from GitHub to Gitea, you can use Gitea's built-in migration form. - -In order to migrate items such as issues, pull requests, etc. you will need to input at least your username. - -[Example (requires login)](https://demo.gitea.com/repo/migrate) - -To migrate from GitLab to Gitea, you can use this non-affiliated tool: - -https://github.com/loganinak/MigrateGitlabToGogs - -## Where does Gitea store what file - -- _`AppWorkPath`_ - - The `WORK_PATH` option in `app.ini` - - Else the `--work-path` flag - - Else Environment variable `GITEA_WORK_DIR` - - Else a built-in value set at build time - - Else the directory that contains the Gitea binary -- `AppDataPath` (default for database, indexers, etc.) - - `APP_DATA_PATH` from `app.ini` - - Else _`AppWorkPath`_`/data` -- _`CustomPath`_ (custom templates) - - The `--custom-path` flag - - Else Environment variable `GITEA_CUSTOM` - - Else a built-in value set at build time - - Else _`AppWorkPath`_`/custom` -- HomeDir - - Unix: Environment variable `HOME` - - Windows: Environment variable `USERPROFILE`, else environment variables `HOMEDRIVE`+`HOMEPATH` -- RepoRootPath - - `ROOT` in the \[repository] section of `app.ini` if absolute - - Else _`AppWorkPath`_`/ROOT` if `ROOT` in the \[repository] section of `app.ini` if relative - - Default `%(APP_DATA_PATH)/gitea-repositories` -- INI (config file) - - `--config` flag - - A possible built-in value set a build time - - Else _`CustomPath`_`/conf/app.ini` -- SQLite Database - - `PATH` in `database` section of `app.ini` - - Else `%(APP_DATA_PATH)/gitea.db` - -## Not seeing a clone URL or the clone URL being incorrect - -There are a few places that could make this show incorrectly. - -1. If using a reverse proxy, make sure you have followed the correction directions in the [reverse proxy guide](administration/reverse-proxies.md) -2. Make sure you have correctly set `ROOT_URL` in the `server` section of your `app.ini` - -If certain clone options aren't showing up (HTTP/S or SSH), the following options can be checked in your `app.ini` - -- `DISABLE_HTTP_GIT`: if set to true, there will be no HTTP/HTTPS link -- `DISABLE_SSH`: if set to true, there will be no SSH link -- `SSH_EXPOSE_ANONYMOUS`: if set to false, SSH links will be hidden for anonymous users - -## File upload fails with: 413 Request Entity Too Large - -This error occurs when the reverse proxy limits the file upload size. - -See the [reverse proxy guide](administration/reverse-proxies.md) for a solution with nginx. - -## Custom Templates not loading or working incorrectly - -Gitea's custom templates must be added to the correct location or Gitea will not find and use them. - -The correct path for the template(s) will be relative to the `CustomPath` - -1. To find `CustomPath`, look for Custom File Root Path in Site Administration -> Configuration -2. If you are still unable to find a path, the default can be [calculated above](#where-does-gitea-store-what-file) -3. Once you have figured out the correct custom path, you can refer to the [customizing Gitea](administration/customizing-gitea.md) page to add your template to the correct location. - -## Does Gitea have a "GitHub/GitLab pages" feature? - -Gitea doesn't provide a built-in Pages server. You need a dedicated domain to serve static pages to avoid CSRF security risks. - -For simple usage, you can use a reverse proxy to rewrite & serve static contents from Gitea's raw file URLs. - -And there are already available third-party services, like a standalone [pages server](https://codeberg.org/Codeberg/pages-server) or a [caddy plugin](https://github.com/42wim/caddy-gitea), that can provide the required functionality. - -## Active user vs login prohibited user - -In Gitea, an "active" user refers to a user that has activated their account via email. - -A "login prohibited" user is a user that is not allowed to log in to Gitea anymore - -## Setting up logging - -- [Official Docs](administration/logging-config.md) - -## What is Swagger? - -[Swagger](https://swagger.io/) is what Gitea uses for its API documentation. - -All Gitea instances have the built-in API and there is no way to disable it completely. -You can, however, disable showing its documentation by setting `ENABLE_SWAGGER` to `false` in the `api` section of your `app.ini`. -For more information, refer to Gitea's [API docs](development/api-usage.md). - -You can see the latest API (for example) on https://gitea.com/api/swagger - -You can also see an example of the `swagger.json` file at https://gitea.com/swagger.v1.json - -## Adjusting your server for public/private use - -### Preventing spammers - -There are multiple things you can combine to prevent spammers. - -1. By whitelisting or blocklisting certain email domains -2. By only whitelisting certain domains with OpenID (see below) -3. Setting `ENABLE_CAPTCHA` to `true` in your `app.ini` and properly configuring `RECAPTCHA_SECRET` and `RECAPTCHA_SITEKEY` -4. Settings `DISABLE_REGISTRATION` to `true` and creating new users via the [CLI](administration/command-line.md), [API](development/api-usage.md), or Gitea's Admin UI - -### Only allow/block certain email domains - -You can configure `EMAIL_DOMAIN_WHITELIST` or `EMAIL_DOMAIN_BLOCKLIST` in your app.ini under `[service]` - -### Only allow/block certain OpenID providers - -You can configure `WHITELISTED_URIS` or `BLACKLISTED_URIS` under `[openid]` in your `app.ini` - -**NOTE:** whitelisted takes precedence, so if it is non-blank then blacklisted is ignored - -### Issue only users - -The current way to achieve this is to create/modify a user with a max repo creation limit of 0. - -### Restricted users - -Restricted users are limited to a subset of the content based on their organization/team memberships and collaborations, ignoring the public flag on organizations/repos etc.\_\_ - -Example use case: A company runs a Gitea instance that requires login. Most repos are public (accessible/browsable by all co-workers). - -At some point, a customer or third party needs access to a specific repo and only that repo. Making such a customer account restricted and granting any needed access using team membership(s) and/or collaboration(s) is a simple way to achieve that without the need to make everything private. - -### Enable Fail2ban - -Use [Fail2Ban](administration/fail2ban-setup.md) to monitor and stop automated login attempts or other malicious behavior based on log patterns - -## SSHD vs built-in SSH - -SSHD is the built-in SSH server on most Unix systems. - -Gitea also provides its own SSH server, for usage when SSHD is not available. - -## Gitea is running slow - -The most common culprit for this is loading federated avatars. - -This can be turned off by setting `ENABLE_FEDERATED_AVATAR` to `false` in your `app.ini` - -Another option that may need to be changed is setting `DISABLE_GRAVATAR` to `true` in your `app.ini` - -## Can't create repositories/files - -Make sure that Gitea has sufficient permissions to write to its home directory and data directory. - -See [AppDataPath and RepoRootPath](#where-does-gitea-store-what-file) - -**Note for Arch users:** At the time of writing this, there is an issue with the Arch package's systemd file including this line: - -`ReadWritePaths=/etc/gitea/app.ini` - -Which makes all other paths non-writeable to Gitea. - -## Translation is incorrect/how to add more translations - -Our translations are currently crowd-sourced on our [Crowdin project](https://crowdin.com/project/gitea) - -Whether you want to change a translation or add a new one, it will need to be there as all translations are overwritten in our CI via the Crowdin integration. - -## Push Hook / Webhook / Actions aren't running - -If you can push but can't see push activities on the home dashboard, or the push doesn't trigger webhook and Actions workflows, it's likely that the git hooks are not working. - -There are a few possibilities: - -1. The git hooks are out of sync: run "Resynchronize pre-receive, update and post-receive hooks of all repositories" on the site admin panel -2. The git repositories (and hooks) are stored on some filesystems (ex: mounted by NAS) which don't support script execution, make sure the filesystem supports `chmod a+x any-script` -3. If you are using docker, make sure Docker Server (not the client) >= 20.10.6 - -## SSH issues - -If you cannot reach repositories over `ssh`, but `https` works fine, consider looking into the following. - -First, make sure you can access Gitea via SSH. - -`ssh git@myremote.example` - -If the connection is successful, you should receive an error message like the following: - -``` -Hi there, You've successfully authenticated, but Gitea does not provide shell access. -If this is unexpected, please log in with password and setup Gitea under another user. -``` - -If you do not get the above message but still connect, it means your SSH key is **not** being managed by Gitea. This means hooks won't run, among other potential problems. - -If you cannot connect at all, your SSH key may not be configured correctly locally. -This is specific to SSH and not Gitea, so will not be covered here. - -### SSH Common Errors - -``` -Permission denied (publickey). -fatal: Could not read from remote repository. -``` - -This error signifies that the server rejected a log in attempt, check the -following things: - -- On the client: - - Ensure the public and private ssh keys are added to the correct Gitea user. - - Make sure there are no issues in the remote url. In particular, ensure the name of the - Git user (before the `@`) is spelled correctly. - - Ensure public and private ssh keys are correct on client machine. -- On the server: - - Make sure the repository exists and is correctly named. - - Check the permissions of the `.ssh` directory in the system user's home directory. - - Verify that the correct public keys are added to `.ssh/authorized_keys`. - - Try to run `Rewrite '.ssh/authorized_keys' file (for Gitea SSH keys)` on the - Gitea admin panel. - - Read Gitea logs. - - Read /var/log/auth (or similar). - - Check permissions of repositories. - -The following is an example of a missing public SSH key where authentication -succeeded, but some other setting is preventing SSH from reaching the correct -repository. - -``` -fatal: Could not read from remote repository. - -Please make sure you have the correct access rights -and the repository exists. -``` - -In this case, look into the following settings: - -- On the server: - - Make sure that the `git` system user has a usable shell set - - Verify this with `getent passwd git | cut -d: -f7` - - `usermod` or `chsh` can be used to modify this. - - Ensure that the `gitea serv` command in `.ssh/authorized_keys` uses the - correct configuration file. - -## Missing releases after migrating repository with tags - -To migrate an repository _with_ all tags, you need to do two things: - -- Push tags to the repository: - -``` - git push --tags -``` - -- (Re-)sync tags of all repositories within Gitea: - -``` -gitea admin repo-sync-releases -``` - -## LFS Issues - -For issues concerning LFS data upload - -``` -batch response: Authentication required: Authorization error: <GITEA_LFS_URL>/info/lfs/objects/batch -Check that you have proper access to the repository -error: failed to push some refs to '<GIT_REPO_URL>' -``` - -Check the value of `LFS_HTTP_AUTH_EXPIRY` in your `app.ini` file. - -By default, your LFS token will expire after 20 minutes. If you have a slow connection or a large file (or both), it may not finish uploading within the time limit. - -You may want to set this value to `60m` or `120m`. - -## How can I create users before starting Gitea - -Gitea provides a sub-command `gitea migrate` to initialize the database, after which you can use the [admin CLI commands](administration/command-line.md#admin) to add users like normal. - -## How can I enable password reset - -There is no setting for password resets. It is enabled when a [mail service](administration/email-setup.md) is configured, and disabled otherwise. - -## How can a user's password be changed - -- As an **admin**, you can change any user's password (and optionally force them to change it on next login)... - - By navigating to your `Site Administration -> User Accounts` page and editing a user. - - By using the [admin CLI commands](administration/command-line.md#admin). - - Keep in mind most commands will also need a [global flag](administration/command-line.md#global-options) to point the CLI at the correct configuration. -- As a **user** you can change it... - - In your account `Settings -> Account` page (this method **requires** you to know your current password). - - By using the `Forgot Password` link. - - If the `Forgot Password/Account Recovery` page is disabled, please contact your administrator to configure a [mail service](administration/email-setup.md). - -## Why is my markdown broken - -In Gitea version `1.11` we moved to [goldmark](https://github.com/yuin/goldmark) for markdown rendering, which is [CommonMark](https://commonmark.org/) compliant. - -If you have markdown that worked as you expected prior to version `1.11` and after upgrading it's not working anymore, please look through the CommonMark spec to see whether the problem is due to a bug or non-compliant syntax. - -If it is the latter, _usually_ there is a compliant alternative listed in the spec. - -## Upgrade errors with MySQL - -If you are receiving errors on upgrade of Gitea using MySQL that read: - -> `ORM engine initialization failed: migrate: do migrate: Error: 1118: Row size too large...` - -Please run `gitea doctor convert` or run `ALTER TABLE table_name ROW_FORMAT=dynamic;` for each table in the database. - -The underlying problem is that the space allocated for indices by the default row format -is too small. Gitea requires that the `ROWFORMAT` for its tables is `DYNAMIC`. - -If you are receiving an error line containing `Error 1071: Specified key was too long; max key length is 1000 bytes...` -then you are attempting to run Gitea on tables which use the ISAM engine. While this may have worked by chance in previous versions of Gitea, it has never been officially supported and -you must use InnoDB. You should run `ALTER TABLE table_name ENGINE=InnoDB;` for each table in the database. - -## Why are Emoji displaying only as placeholders or in monochrome - -Gitea requires the system or browser to have one of the supported Emoji fonts installed, which are Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji and Twemoji Mozilla. Generally, the operating system should already provide one of these fonts, but especially on Linux, it may be necessary to install them manually. - -## Initial logging - -Before Gitea has read the configuration file and set-up its logging it will log a number of things to stdout in order to help debug things if logging does not work. - -You can stop this logging by setting the `--quiet` or `-q` option. Please note this will only stop logging until Gitea has set-up its own logging. - -If you report a bug or issue you MUST give us logs with this information restored. - -You should only set this option once you have completely configured everything. - -## Warnings about struct defaults during database startup - -Sometimes when there are migrations the old columns and default values may be left -unchanged in the database schema. This may lead to warning such as: - -``` -2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0 -``` - -These can safely be ignored, but you are able to stop these warnings by getting Gitea to recreate these tables using: - -``` -gitea doctor recreate-table user -``` - -This will cause Gitea to recreate the user table and copy the old data into the new table -with the defaults set appropriately. - -You can ask Gitea to recreate multiple tables using: - -``` -gitea doctor recreate-table table1 table2 ... -``` - -And if you would like Gitea to recreate all tables simply call: - -``` -gitea doctor recreate-table -``` - -It is highly recommended to back-up your database before running these commands. - -## How to adopt repositories from disk - -- Add your (bare) repositories to the correct spot for your configuration (`repository.ROOT`), ensuring they are in the correct layout `<REPO_ROOT>/[user]/[repo].git`. - - **Note:** the directory names must be lowercase. - - You can also check `<ROOT_URL>/admin/config` for the repository root path. -- Ensure that the user/org exists that you want to adopt repositories for. -- As an admin, go to `<ROOT_URL>/admin/repos/unadopted` and search. - - Users can also be given similar permissions via config [`ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`](administration/config-cheat-sheet.md#repository). -- If the above steps are done correctly, you should be able to select repositories to adopt. - - If no repositories are found, enable [debug logging](administration/config-cheat-sheet.md#repository) to check for any specific errors. - -## Gitea can't start on NFS - -In most cases, it's caused by broken NFS lock system. You can try to stop Gitea process and -run `flock -n /data-nfs/gitea/queues/LOCK echo 'lock acquired'` to see whether the lock can be acquired immediately. -If the lock can't be acquired, NFS might report some errors like `lockd: cannot monitor node-3, statd: server rpc.statd not responding, timed out` in its server logs. - -Then the NFS lock could be reset by: - -```bash -# /etc/init.d/nfs stop -# rm -rf /var/lib/nfs/sm/* -# /etc/init.d/nfs start -``` diff --git a/docs/content/help/faq.zh-cn.md b/docs/content/help/faq.zh-cn.md deleted file mode 100644 index d24dfe24a2..0000000000 --- a/docs/content/help/faq.zh-cn.md +++ /dev/null @@ -1,438 +0,0 @@ ---- -date: "2023-05-25T16:00:00+02:00" -title: "常见问题" -slug: "faq" -sidebar_position: 5 -toc: false -draft: false -aliases: - - /zh-cn/faq -menu: - sidebar: - parent: "help" - name: "常见问题" - sidebar_position: 5 - identifier: "faq" ---- - -# 常见问题 - -本页面包含一些常见问题和答案。 - -有关更多帮助资源,请查看所有[支持选项](help/support.md)。 - -## 1.x和1.x.x下载之间的区别 - -以1.7.x版本为例。 - -**注意:**此示例也适用于Docker镜像! - -在我们的[下载页面](https://dl.gitea.com/gitea/)上,您会看到一个1.7目录,以及1.7.0、1.7.1、1.7.2、1.7.3、1.7.4、1.7.5和1.7.6的目录。 - -1.7目录和1.7.0目录是**不同**的。1.7目录是在每个合并到[`release/v1.7`](https://github.com/go-gitea/gitea/tree/release/v1.7)分支的提交上构建的。 - -然而,1.7.0目录是在创建[`v1.7.0`](https://github.com/go-gitea/gitea/releases/tag/v1.7.0)标签时创建的构建。 - -这意味着1.x的下载会随着提交合并到各自的分支而改变(将其视为每个版本的单独的“main”分支)。 - -另一方面,1.x.x的下载应该永远不会改变。 - -## 如何从Gogs/GitHub等迁移到Gitea - -要从Gogs迁移到Gitea: - -- [Gogs版本0.11.46.0418](https://github.com/go-gitea/gitea/issues/4286) - -要从GitHub迁移到Gitea,您可以使用Gitea内置的迁移表单。 - -为了迁移诸如问题、拉取请求等项目,您需要至少输入您的用户名。 - -[Example (requires login)](https://demo.gitea.com/repo/migrate) - -要从GitLab迁移到Gitea,您可以使用这个非关联的工具: - -https://github.com/loganinak/MigrateGitlabToGogs - -## Gitea存储文件的位置 - -- _`AppWorkPath`_ - - `--work-path`标志 - - 或者环境变量`GITEA_WORK_DIR` - - 或者在构建时设置的内置值 - - 或者包含Gitea二进制文件的目录 -- `%(APP_DATA_PATH)`(数据库、索引器等的默认路径) - - `app.ini`中的`APP_DATA_PATH` - - 或者_`AppWorkPath`_`/data` -- _`CustomPath`_(自定义模板) - - `--custom-path`标志 - - 或者环境变量`GITEA_CUSTOM` - - 或者在构建时设置的内置值 - - 或者_`AppWorkPath`_`/custom` -- HomeDir - - Unix:环境变量`HOME` - - Windows:环境变量`USERPROFILE`,或者环境变量`HOMEDRIVE`+`HOMEPATH` -- RepoRootPath - - `app.ini`中\[repository]部分的`ROOT`(如果是绝对路径) - - 否则_`AppWorkPath`_`/ROOT`(如果`app.ini`中\[repository]部分的`ROOT`是相对路径) - - 默认值为`%(APP_DATA_PATH)/gitea-repositories` -- INI(配置文件) - - `--config`标志 - - 或者在构建时设置的可能内置值 - - 或者 _`CustomPath`_`/conf/app.ini` -- SQLite数据库 - - app.ini中database部分的PATH - - 或者`%(APP_DATA_PATH)/gitea.db` - -## 看不到克隆URL或克隆URL不正确 - -有几个地方可能会导致显示不正确。 - -1. 如果使用反向代理,请确保按照[反向代理指南](administration/reverse-proxies.md)中的正确说明进行设置。 -2. 确保在`app.ini`的`server`部分中正确设置了`ROOT_URL`。 - -如果某些克隆选项未显示(HTTP/S或SSH),可以在`app.ini中` - -- `DISABLE_HTTP_GIT`: 如果设为true, 将会没有HTTP/HTTPS链接 -- `DISABLE_SSH`: 如果设为true, 将会没有SSH链接 -- `SSH_EXPOSE_ANONYMOUS`: 如果设为false, SSH链接将会对匿名用户隐藏 - -## 文件上传失败:413 Request Entity Too Large - -当反向代理限制文件上传大小时,会出现此错误。 - -有关使用nginx解决此问题,请参阅[反向代理指南](administration/reverse-proxies.md)。 - -## 自定义模板无法加载或运行错误 - -Gitea的自定义模板必须将其添加到正确的位置,否则Gitea将无法找到并使用自定义模板。 - -模板的正确路径应该相对于`CustomPath`。 - -1. 要找到`CustomPath`,请在站点管理 -> 配置 中查找自定义文件根路径。 - - 如果找不到,请尝试`echo $GITEA_CUSTOM`。 - -2. 如果仍然找不到,默认值可以被[计算](help/faq.md#where-does-gitea-store-what-file) -3. 如果仍然找不到路径,则可以参考[自定义Gitea](administration/customizing-gitea.md)页面,将模板添加到正确的位置。 - -## Gitea是否有"GitHub/GitLab Pages"功能? - -Gitea不提供内置的Pages服务器。您需要一个专用的域名来提供静态页面,以避免CSRF安全风险。 - -对于简单的用法,您可以使用反向代理来重写和提供Gitea的原始文件URL中的静态内容。 - -还有一些已经可用的第三方服务,比如独立[pages server](https://codeberg.org/Codeberg/pages-server)的或[caddy plugin](https://github.com/42wim/caddy-gitea),可以提供所需的功能。 - -## 活跃用户与禁止登录用户 - -在Gitea中,"活跃用户"是指通过电子邮件激活其帐户的用户。 - -"禁止登录用户"是指不允许再登录到Gitea的用户。 - -## 设置日志记录 - -- [官方文档](administration/logging-config.md) - -## 什么是Swagger? - -[Swagger](https://swagger.io/) 是Gitea用于其API文档的工具。 - -所有Gitea实例都有内置的API,无法完全禁用它。 -但是,您可以在app.ini的api部分将ENABLE_SWAGGER设置为false,以禁用其文档显示。 -有关更多信息,请参阅Gitea的[API文档](development/api-usage.md)。 - -您可以在上查看最新的API(例如)https://gitea.com/api/swagger - -您还可以在上查看`swagger.json`文件的示例 https://gitea.com/swagger.v1.json - -## 调整服务器用于公共/私有使用 - -### 防止垃圾邮件发送者 - -有多种方法可以组合使用来防止垃圾邮件发送者: - -1. 通过设置电子邮件域名的白名单或黑名单。 -2. 通过设置一些域名或者OpenID白名单(见下文)。 -3. 在您的`app.ini`中将`ENABLE_CAPTCHA`设置为`true`,并正确配置`RECAPTCHA_SECRET`和 `RECAPTCHA_SITEKEY`。 -4. 将`DISABLE_REGISTRATION`设置为`true`,并通过 [CLI](administration/command-line.md)、[API](development/api-usage.md) 或 Gitea 的管理界面创建新用户。 - -### 仅允许/阻止特定的电子邮件域名 - -您可以在`app.ini`中的`[service]`下的配置`EMAIL_DOMAIN_WHITELIST` 或 `EMAIL_DOMAIN_BLOCKLIST`。 - -### 仅允许/阻止特定的 OpenID 提供商 - -您可以在`app.ini`的`[openid]`下配置`WHITELISTED_URI`或`BLACKLISTED_URIS`。 - -**注意**: 白名单优先,如果白名单非空,则忽略黑名单。 - -### 仅允许发布问题的用户 - -目前实现这一点的方法是创建/修改一个具有最大仓库创建限制为 0 的用户。 - -### 受限制的用户 - -受限制的用户仅能访问其组织/团队成员和协作所在的内容的子集,而忽略组织/仓库等的公共标志。 - -示例用例:一个公司运行一个需要登录的 Gitea 实例。大多数仓库是公开的(所有同事都可以访问/浏览)。 - -在某些情况下,某个客户或第三方需要访问特定的仓库,并且只能访问该仓库。通过将此类客户帐户设置为受限制帐户,并使用团队成员身份和/或协作来授予所需的任何访问权限,可以简单地实现这一点,而无需使所有内容都变为私有。 - -### 启用 Fail2ban - -使用 [Fail2Ban](administration/fail2ban-setup.md) 监视并阻止基于日志模式的自动登录尝试或其他恶意行为。 - -## SSHD vs 内建SSH - -SSHD是大多数Unix系统上内建的SSH服务器。 - -Gitea还提供了自己的SSH服务器,用于在SSHD不可用时使用。 - -## Gitea运行缓慢 - -导致此问题的最常见原因是加载联合头像。 - -您可以通过在`app.ini`中将`ENABLE_FEDERATED_AVATAR`设置为`false`来关闭此功能。 - -还有一个可能需要更改的选项是在`app.ini`中将`DISABLE_GRAVATAR`设置为`true`。 - -## 无法创建仓库/文件 - -请确保Gitea具有足够的权限来写入其主目录和数据目录。 - -参见[AppDataPath 和 RepoRootPath](help/faq.md#where-does-gitea-store-what-file) - -**适用于Arch用户的注意事项:**在撰写本文时,Arch软件包的systemd文件包含了以下行: - -`ReadWritePaths=/etc/gitea/app.ini` - -这将使得Gitea无法写入其他路径。 - -## 翻译不正确/如何添加更多翻译 - -我们当前的翻译是在我们的[Crowdin项目](https://crowdin.com/project/gitea)上众包进行的 - -无论您想要更改翻译还是添加新的翻译,都需要在Crowdin集成中进行,因为所有翻译都会被CI覆盖。 - -## 推送钩子/ Webhook / Actions 未运行 - -如果您可以推送但无法在主页仪表板上看到推送活动,或者推送不触发 Webhook 和 Actions,可能是 git 钩子不工作而导致的。 - -这可能是由于以下原因: - -1. Git钩子不同步:在站点管理面板上运行“重新同步所有仓库的pre-receive、update和post-receive钩子” -2. Git仓库(和钩子)存储在一些不支持脚本执行的文件系统上(例如由NAS挂载),请确保文件系统支持`chmod a+x any-script` -3. 如果您使用的是Docker,请确保Docker Server(而不是客户端)的版本 >= 20.10.6 - -## SSH问题 - -如果无法通过`ssh`访问仓库,但`https`正常工作,请考虑以下情况。 - -首先,请确保您可以通过SSH访问Gitea。 - -`ssh git@myremote.example` - -如果连接成功,您应该会收到以下错误消息: - -``` -Hi there, You've successfully authenticated, but Gitea does not provide shell access. -If this is unexpected, please log in with password and setup Gitea under another user. -``` - -如果您收到以上消息但仍然连接成功,这意味着您的 SSH 密钥**没有**由 Gitea 管理。这意味着钩子不会运行,在其他一些潜在问题中也包括在内。 - -如果您无法连接,可能是因为您的 SSH 密钥在本地配置不正确。 -这是针对 SSH 而不是 Gitea 的问题,因此在此不涉及。 - -### SSH 常见错误 - -``` -Permission denied (publickey). -fatal: Could not read from remote repository. -``` - -此错误表示服务器拒绝登录尝试, -请检查以下事项: - -- 在客户端: - - 确保公钥和私钥已添加到正确的 Gitea 用户。 - - 确保远程 URL 中没有任何问题。特别是,请确保∂ - Git 用户(@ 之前的部分)的名称拼写正确。 - - 确保客户端机器上的公钥和私钥正确无误。 -- 在服务器上: - - 确保存储库存在并且命名正确。 - - 检查系统用户主目录中的 `.ssh` 目录的权限。 - - 验证正确的公钥是否已添加到 `.ssh/authorized_keys` 中。 - - 尝试在 Gitea 管理面板上运行 - `Rewrite '.ssh/authorized_keys' file (for Gitea SSH keys)`。 -- 查看 Gitea 日志。 -- 查看 /var/log/auth(或类似的文件)。 -- 检查存储库的权限。 - -以下是一个示例,其中缺少公共 SSH 密钥, -认证成功,但是其他设置导致 SSH 无法访问正确的 -存储库。 - -``` -fatal: Could not read from remote repository. - -Please make sure you have the correct access rights -and the repository exists. -``` - -在这种情况下,请检查以下设置: - -- 在服务器上: - - 确保`git`系统用户设置了可用的 shell - - 使用`getent passwd git | cut -d: -f7`进行验证 - - 可以使用`usermod`或`chsh`进行修改。 - - 确保`.ssh/authorized_keys`中的`gitea serv`命令使用 - 正确的配置文件。 - -## 迁移带有标签的存储库后缺失发布版本 - -要迁移带有所有标签的存储库,您需要执行两个操作: - -- 推送标签到存储库: - -``` - git push --tags -``` - -- 在 Gitea 中重新同步所有存储库的标签: - -``` -gitea admin repo-sync-releases -``` - -## LFS 问题 - -针对涉及 LFS 数据上传的问题 - -``` -batch response: Authentication required: Authorization error: <GITEA_LFS_URL>/info/lfs/objects/batch -Check that you have proper access to the repository -error: failed to push some refs to '<GIT_REPO_URL>' -``` - -检查`app.ini`文件中的`LFS_HTTP_AUTH_EXPIRY`值。 - -默认情况下,LFS 令牌在 20 分钟后过期。如果您的连接速度较慢或文件较大(或两者都是),可能无法在时间限制内完成上传。 - -您可以将此值设置为`60m`或`120m`。 - -## 如何在启动 Gitea 之前创建用户 - -Gitea 提供了一个子命令`gitea migrate`来初始化数据库,然后您可以使用[管理 CLI 命令](administration/command-line.md#admin)像正常情况下添加用户。 - -## 如何启用密码重置 - -没有密码重置的设置。当配置了[邮件服务](administration/email-setup.md)时,密码重置将自动启用;否则将被禁用。 - -## 如何更改用户的密码 - -- 作为管理员,您可以更改任何用户的密码(并可选择强制其在下次登录时更改密码)... - - 转到您的`站点管理 -> 用户账户`页面并编辑用户。 -- 使用[管理 CLI 命令](administration/command-line.md#admin)。 - - 请注意,大多数命令还需要一个[全局标志](administration/command-line.md#global-options)来指向正确的配置。 -- 作为**用户**,您可以更改密码... - - 在您的账户的`设置 -> 账户`页面(此方法**需要**您知道当前密码)。 - - 使用`忘记密码`链接。 - - 如果`忘记密码/账户恢复`页面被禁用,请联系管理员配置[邮件服务](administration/email-setup.md)。 - -## 为什么我的 Markdown 显示错误 - -在 Gitea 版本 `1.11` 中,我们转换为使用[goldmark](https://github.com/yuin/goldmark)进行 Markdown 渲染,它符合[CommonMark](https://commonmark.org/)标准。 - -如果您在版本`1.11`之前的Markdown正常工作,但在升级后无法正常工作,请仔细阅读CommonMark规范,看看问题是由错误还是非兼容的语法引起的。 - -如果是后者,通常规范中会列出一种符合标准的替代方法。 - -## 使用 MySQL 进行升级时出现的错误 - -如果在使用 MySQL 升级 Gitea 时收到以下错误: - -> `ORM engine initialization failed: migrate: do migrate: Error: 1118: Row size too large...` - -请运行 `gitea doctor convert` 或对数据库中的每个表运行 `ALTER TABLE table_name ROW_FORMAT=dynamic;`。 - -潜在问题是默认行格式分配给每个表的索引空间 -太小。Gitea 要求其表的`ROWFORMAT`为`DYNAMIC`。 - -如果收到包含`Error 1071: Specified key was too long; max key length is 1000 bytes...` -的错误行,则表示您正在尝试在使用 ISAM 引擎的表上运行 Gitea。尽管在先前版本的 Gitea 中可能是凑巧能够工作的,但它从未得到官方支持, -您必须使用 InnoDB。您应该对数据库中的每个表运行`ALTER TABLE table_name ENGINE=InnoDB;`。 - -## 为什么 Emoji 只显示占位符或单色图像 - -Gitea 需要系统或浏览器安装其中一个受支持的 Emoji 字体,例如 Apple Color Emoji、Segoe UI Emoji、Segoe UI Symbol、Noto Color Emoji 和 Twemoji Mozilla。通常,操作系统应该已经提供了其中一个字体,但特别是在 Linux 上,可能需要手动安装它们。 - -## SystemD 和 Docker 上的标准输出日志 - -SystemD 上的标准输出默认会写入日志记录中。您可以尝试使用 `journalctl`、`journalctl -u gitea` 或 `journalctl <path-to-gitea-binary>`来查看。 - -类似地,Docker 上的标准输出可以使用`docker logs <container>`来查看。 - -要收集日志以进行帮助和问题报告,请参阅[支持选项](help/support.md)。 - -## 初始日志记录 - -在 Gitea 读取配置文件并设置其日志记录之前,它会将一些内容记录到标准输出,以帮助调试日志记录无法工作的情况。 - -您可以通过设置`--quiet`或`-q`选项来停止此日志记录。请注意,这只会在 Gitea 设置自己的日志记录之前停止日志记录。 - -如果您报告了错误或问题,必须提供这些信息以恢复初始日志记录。 - -只有在完全配置了所有内容之后,您才应该设置此选项。 - -## 在数据库启动期间出现有关结构默认值的警告 - -有时,在迁移过程中,旧列和默认值可能在数据库架构中保持不变。 -这可能会导致警告,例如: - -``` -2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0 -``` - -可以安全地忽略这些警告,但您可以通过让 Gitea 重新创建这些表来停止这些警告,使用以下命令: - -``` -gitea doctor recreate-table user -``` - -这将导致 Gitea 重新创建用户表并将旧数据复制到新表中, -并正确设置默认值。 - -您可以使用以下命令要求 Gitea 重新创建多个表: - -``` -gitea doctor recreate-table table1 table2 ... -``` - -如果您希望 Gitea 重新创建所有表,请使用以下命令: - -``` -gitea doctor recreate-table -``` - -在运行这些命令之前,强烈建议您备份数据库。 - -## 为什么查看文件时制表符/缩进显示错误 - -如果您正在使用 Cloudflare,请在仪表板中关闭自动缩小选项。 - -`Speed` -> `Optimization` -> 在 `Auto-Minify` 设置中取消选中 `HTML`。 - -## 如何从磁盘采用存储库 - -- 将您的(裸)存储库添加到正确的位置,即您的配置所在的地方(`repository.ROOT`),确保它们位于正确的布局`<REPO_ROOT>/[user]/[repo].git`。 - - **注意:**目录名必须为小写。 - - 您还可以在`<ROOT_URL>/admin/config`中检查存储库根路径。 -- 确保存在要采用存储库的用户/组织。 -- 作为管理员,转到`<ROOT_URL>/admin/repos/unadopted`并搜索。 -- 用户也可以通过配置[`ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`](administration/config-cheat-sheet.md#repository) 获得类似的权限。 -- 如果上述步骤都正确执行,您应该能够选择要采用的存储库。 - - 如果没有找到存储库,请启用[调试日志记录](administration/config-cheat-sheet.md#repository)以检查是否有特定错误。 diff --git a/docs/content/help/support.en-us.md b/docs/content/help/support.en-us.md deleted file mode 100644 index bc8a8e3fd6..0000000000 --- a/docs/content/help/support.en-us.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -date: "2018-05-21T15:00:00+00:00" -title: "Support Options" -slug: "support" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /en-us/seek-help -menu: - sidebar: - parent: "help" - name: "Support Options" - sidebar_position: 20 - identifier: "support" ---- - -# Support Options - -- [Paid Commercial Support](https://about.gitea.com/) -- [Discord](https://discord.gg/Gitea) -- [Forum](https://forum.gitea.com/) -- [Matrix](https://matrix.to/#/#gitea-space:matrix.org) - - NOTE: Most of the Matrix channels are bridged with their counterpart in Discord and may experience some degree of flakiness with the bridge process. -- Chinese Support - - [Discourse Chinese Category](https://forum.gitea.com/c/5-category/5) - - QQ Group 328432459 - -# Bug Report - -If you found a bug, please [create an issue on GitHub](https://github.com/go-gitea/gitea/issues). - -**NOTE:** When asking for support, it may be a good idea to have the following available so that the person helping has all the info they need: - -1. Your `app.ini` (with any sensitive data scrubbed as necessary). -2. Any error messages you are seeing. -3. The Gitea logs, and all other related logs for the situation. - - It's more useful to collect `trace` / `debug` level logs (see the next section). - - When using systemd, use `journalctl --lines 1000 --unit gitea` to collect logs. - - When using docker, use `docker logs --tail 1000 <gitea-container>` to collect logs. -4. Reproducible steps so that others could reproduce and understand the problem more quickly and easily. - - [demo.gitea.com](https://demo.gitea.com) could be used to reproduce the problem. -5. If you encounter slow/hanging/deadlock problems, please report the stacktrace when the problem occurs. - Go to the "Site Admin" -> "Monitoring" -> "Stacktrace" -> "Download diagnosis report". - -# Advanced Bug Report Tips - -## More Config Options for Logs - -By default, the logs are outputted to console with `info` level. -If you need to set log level and/or collect logs from files, -you could just copy the following config into your `app.ini` (remove all other `[log]` sections), -then you will find the `*.log` files in Gitea's log directory (default: `%(GITEA_WORK_DIR)/log`). - -```ini -; To show all SQL logs, you can also set LOG_SQL=true in the [database] section -[log] -LEVEL=debug -MODE=console,file -``` - -## Collecting Stacktrace by Command Line - -Gitea could use Golang's pprof handler and toolchain to collect stacktrace and other runtime information. - -If the web UI stops working, you could try to collect the stacktrace by command line: - -1. Set `app.ini`: - - ``` - [server] - ENABLE_PPROF = true - ``` - -2. Restart Gitea - -3. Try to trigger the bug, when the requests get stuck for a while, - use `curl` or browser to visit: `http://127.0.0.1:6060/debug/pprof/goroutine?debug=1` to get the stacktrace. diff --git a/docs/content/help/support.zh-cn.md b/docs/content/help/support.zh-cn.md deleted file mode 100644 index 6c69584c67..0000000000 --- a/docs/content/help/support.zh-cn.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -date: "2017-01-20T15:00:00+08:00" -title: "需要帮助" -slug: "support" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/seek-help -menu: - sidebar: - parent: "help" - name: "需要帮助" - sidebar_position: 20 - identifier: "support" ---- - -# 支持选项 - -- [付费商业支持](https://about.gitea.com/) -- [Discord](https://discord.gg/Gitea) -- [论坛](https://forum.gitea.com/) -- [Matrix](https://matrix.to/#/#gitea-space:matrix.org) - - 注意:大多数 Matrix 频道都与 Discord 中的对应频道桥接,可能在桥接过程中会出现一定程度的不稳定性。 -- 中文支持 - - [Discourse 中文分类](https://forum.gitea.com/c/5-category/5) - - QQ 群 328432459 - -# Bug 报告 - -如果您发现了 Bug,请在 GitHub 上 [创建一个问题](https://github.com/go-gitea/gitea/issues)。 - -**注意:** 在请求支持时,可能需要准备以下信息,以便帮助者获得所需的所有信息: - -1. 您的 `app.ini`(将任何敏感数据进行必要的清除)。 -2. 您看到的任何错误消息。 -3. Gitea 日志以及与情况相关的所有其他日志。 - - 收集 `trace` / `debug` 级别的日志更有用(参见下一节)。 - - 在使用 systemd 时,使用 `journalctl --lines 1000 --unit gitea` 收集日志。 - - 在使用 Docker 时,使用 `docker logs --tail 1000 <gitea-container>` 收集日志。 -4. 可重现的步骤,以便他人能够更快速、更容易地重现和理解问题。 - - [demo.gitea.com](https://demo.gitea.com) 可用于重现问题。 -5. 如果遇到慢速/挂起/死锁等问题,请在出现问题时报告堆栈跟踪。 - 转到 "Site Admin" -> "Monitoring" -> "Stacktrace" -> "Download diagnosis report"。 - -# 高级 Bug 报告提示 - -## 更多日志的配置选项 - -默认情况下,日志以 `info` 级别输出到控制台。 -如果您需要设置日志级别和/或从文件中收集日志, -您只需将以下配置复制到您的 `app.ini` 中(删除所有其他 `[log]` 部分), -然后您将在 Gitea 的日志目录中找到 `*.log` 文件(默认为 `%(GITEA_WORK_DIR)/log`)。 - -```ini -; 要显示所有 SQL 日志,您还可以在 [database] 部分中设置 LOG_SQL=true -[log] -LEVEL=debug -MODE=console,file -``` - -## 使用命令行收集堆栈跟踪 - -Gitea 可以使用 Golang 的 pprof 处理程序和工具链来收集堆栈跟踪和其他运行时信息。 - -如果 Web UI 停止工作,您可以尝试通过命令行收集堆栈跟踪: - -1. 设置 app.ini: - - ``` - [server] - ENABLE_PPROF = true - ``` - -2. 重新启动 Gitea - -3. 尝试触发bug,当请求卡住一段时间,使用或浏览器访问:获取堆栈跟踪。 -`curl http://127.0.0.1:6060/debug/pprof/goroutine?debug=1` diff --git a/docs/content/index.en-us.md b/docs/content/index.en-us.md deleted file mode 100644 index dc2eb1472a..0000000000 --- a/docs/content/index.en-us.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -date: "2016-11-08T16:00:00+02:00" -title: "Documentation" -slug: / -sidebar_position: 10 -toc: false -draft: false ---- - -# What is Gitea? - -Gitea is a painless self-hosted all-in-one software development service, it includes Git hosting, code review, team collaboration, package registry and CI/CD. It is similar to GitHub, Bitbucket and GitLab. -Gitea was forked from [Gogs](http://gogs.io) originally and almost all the code has been changed. See the [Gitea Announcement](https://blog.gitea.com/welcome-to-gitea/) -blog post to read about the justification for a fork. - -## Purpose - -The goal of this project is to provide the easiest, fastest, and most painless way of setting -up a self-hosted Git service. - -With Go, this can be done platform-independently across -**all platforms** which Go supports, including Linux, macOS, and Windows, -on x86, amd64, ARM and PowerPC architectures. -You can try it out using [the online demo](https://demo.gitea.com). - -## Features - -- Code Hosting: Gitea supports creating and managing repositories, browsing commit history and code files, reviewing and merging code submissions, managing collaborators, handling branches, and more. It also supports many common Git features such as tags, Cherry-pick, hooks, integrated collaboration tools, and more. - -- Lightweight and Fast: One of Gitea's design goals is to be lightweight and fast in response. Unlike some large code hosting platforms, it remains lean, performing well in terms of speed, and is suitable for resource-limited server environments. Due to its lightweight design, Gitea has relatively low resource consumption and performs well in resource-constrained environments. - -- Easy Deployment and Maintenance: It can be easily deployed on various servers without complex configurations or dependencies. This makes it convenient for individual developers or small teams to set up and manage their own Git services. - -- Security: Gitea places a strong emphasis on security, offering features such as user permission management, access control lists, and more to ensure the security of code and data. - -- Code Review: Code review supports both the Pull Request workflow and AGit workflow. Reviewers can browse code online and provide review comments or feedback. Submitters can receive review comments and respond or modify code online. Code reviews can help individuals and organizations enhance code quality. - -- CI/CD: Gitea Actions supports CI/CD functionality, compatible with GitHub Actions. Users can write workflows in familiar YAML format and reuse a variety of existing Actions plugins. Actions plugins support downloading from any Git website. - -- Project Management: Gitea tracks project requirements, features, and bugs through columns and issues. Issues support features like branches, tags, milestones, assignments, time tracking, due dates, dependencies, and more. - -- Artifact Repository: Gitea supports over 20 different types of public or private software package management, including Cargo, Chef, Composer, Conan, Conda, Container, Helm, Maven, npm, NuGet, Pub, PyPI, RubyGems, Vagrant, and more. - -- Open Source Community Support: Gitea is an open-source project based on the MIT license. It has an active open-source community that continuously develops and improves the platform. The project also actively welcomes community contributions, ensuring updates and innovation. - -- Multilingual Support: Gitea provides interfaces in multiple languages, catering to users globally and promoting internationalization and localization. - -Additional Features: For more detailed information, please refer to: https://docs.gitea.com/installation/comparison#general-features - -## System Requirements - -- A Raspberry Pi 3 is powerful enough to run Gitea for small workloads. -- 2 CPU cores and 1GB RAM is typically sufficient for small teams/projects. -- Gitea should be run with a dedicated non-root system account on UNIX-type systems. - - Note: Gitea manages the `~/.ssh/authorized_keys` file. Running Gitea as a regular user could break that user's ability to log in. -- [Git](https://git-scm.com/) version 2.0.0 or later is required. - - [Git Large File Storage](https://git-lfs.github.com/) will be available if enabled and if your Git version is >= 2.1.2 - - Git commit-graph rendering will be enabled automatically if your Git version is >= 2.18 - -## Browser Support - -- Last 2 versions of Chrome, Firefox, Safari and Edge -- Firefox ESR - -## Components - -- Web server framework: [Chi](http://github.com/go-chi/chi) -- ORM: [XORM](https://xorm.io) -- UI frameworks: - - [jQuery](https://jquery.com) - - [Fomantic UI](https://fomantic-ui.com) - - [Vue3](https://vuejs.org) - - and various components (see package.json) -- Editors: - - [CodeMirror](https://codemirror.net) - - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) - - [Monaco Editor](https://microsoft.github.io/monaco-editor) -- Database drivers: - - [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) - - [github.com/lib/pq](https://github.com/lib/pq) - - [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) - - [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) - -## Integrated support - - Please visit [Awesome Gitea](https://gitea.com/gitea/awesome-gitea/) to get more third-party integrated support diff --git a/docs/content/index.zh-cn.md b/docs/content/index.zh-cn.md deleted file mode 100644 index 3cec5b396e..0000000000 --- a/docs/content/index.zh-cn.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -date: "2016-11-08T16:00:00+02:00" -title: "文档" -slug: / -sidebar_position: 10 -toc: false -draft: false ---- - -# 关于Gitea - -Gitea 是一个轻量级的 DevOps 平台软件。从开发计划到产品成型的整个软件生命周期,他都能够高效而轻松的帮助团队和开发者。包括 Git 托管、代码审查、团队协作、软件包注册和 CI/CD。它与 GitHub、Bitbucket 和 GitLab 等比较类似。 -Gitea 最初是从 [Gogs](http://gogs.io) 分支而来,几乎所有代码都已更改。对于我们Fork的原因可以看 -[这里](https://blog.gitea.com/welcome-to-gitea/)。 - -## 目标 - -Gitea的首要目标是创建一个极易安装,运行非常快速,安装和使用体验良好 -的自建 Git 服务。 - -采用Go作为后端语言,只需生成一个可执行程序即可。 -支持 Linux, macOS 和 Windows等多平台, - 支持主流的x86,amd64、 - ARM 和 PowerPC等架构。 - -## 功能特性 - -- 代码托管:Gitea⽀持创建和管理仓库、浏览提交历史和代码⽂件、审查和合并代码提交、管理协作者、管理分⽀等。它还⽀持许多常见的Git特性,⽐如标签、Cherry-pick、hook、集成协作⼯具等。 -- 轻量级和快速: Gitea 的设计目标之一就是轻量级和快速响应。它不像一些大型的代码托管平台那样臃肿,因此在性能方面表现出色,适用于资源有限的服务器环境。由于其轻量级设计,Gitea 在资源消耗方面相对较低,可以在资源有限的环境下运行良好。 -- 易于部署和维护: 轻松地部署在各种服务器上,不需要复杂的配置和依赖。这使得个人开发者或小团队可以方便地设置和管理自己的 Git 服务。 -- 安全性: Gitea 注重安全性,提供了用户权限管理、访问控制列表等功能,可以确保代码和数据的安全性。 -- 代码评审:代码评审同时支持 Pull Request workflow 和 AGit workflow。评审⼈可以在线浏览代码,并提交评审意见或问题。 提交者可以接收到评审意见,并在线回 复或修改代码。代码评审可以帮助用户和企业提⾼代码质量。 -- CI/CD: Gitea Actions⽀持 CI/CD 功能,该功能兼容 GitHub Actions,⽤⼾可以采用熟悉的YAML格式编写workflows,也可以重⽤⼤量的已有的 Actions 插件。Actions 插件支持从任意的 Git 网站中下载。 -- 项目管理:Gitea 通过看板和⼯单来跟踪⼀个项⽬的需求,功能和bug。⼯单⽀持分支,标签、⾥程碑、 指派、时间跟踪、到期时间、依赖关系等功能。 -- 制品库: Gitea支持超过 20 种不同种类的公有或私有软件包管理,包括:Cargo, Chef, Composer, Conan, Conda, Container, Helm, Maven, npm, NuGet, Pub, PyPI, RubyGems, Vagrant等 -- 开源社区支持: Gitea 是一个基于 MIT 许可证的开源项目,Gitea 拥有一个活跃的开源社区,能够持续地进行开发和改进,同时也积极接受社区贡献,保持了平台的更新和创新。 -- 多语言支持: Gitea 提供多种语言界面,适应全球范围内的用户,促进了国际化和本地化。 - -更多功能特性:详见:https://docs.gitea.com/installation/comparison#general-features - -## 系统要求 - -- 树莓派Pi3功能强大,足以运行 Gitea 来处理小型工作负载。 -- 对于小型团队/项目而言,2 个 CPU 内核和 1GB 内存通常就足够了。 -- 在 UNIX 系统上,Gitea 应使用专用的非 root 系统账户运行。 - - 注意:Gitea 管理 `~/.ssh/authorized_keys` 文件。以普通用户身份运行 Gitea 可能会破坏该用户的登录能力。 -- [Git](https://git-scm.com/) 需要 2.0.0 或更高版本。 - - [Git Large File Storage](https://git-lfs.github.com/) 如果启用,且 Git 版本大于等于 2.1.2,则该选项可用 - - 如果 Git 版本大于等于 2.18,将自动启用 Git 提交历史图形化展示功能 - -## 浏览器支持 - -- Last 2 versions of Chrome, Firefox, Safari and Edge -- Firefox ESR - -## 技术栈 - -- Web框架: [Chi](http://github.com/go-chi/chi) -- ORM: [XORM](https://xorm.io) -- UI 框架: - - [jQuery](https://jquery.com) - - [Fomantic UI](https://fomantic-ui.com) - - [Vue3](https://vuejs.org) - - 更多组件参见 package.json -- 编辑器: - - [CodeMirror](https://codemirror.net) - - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) - - [Monaco Editor](https://microsoft.github.io/monaco-editor) -- 数据库驱动: - - [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) - - [github.com/lib/pq](https://github.com/lib/pq) - - [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) - - [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) - -## 集成支持 - -请访问 [Awesome Gitea](https://gitea.com/gitea/awesome-gitea/) 获得更多的第三方集成支持 diff --git a/docs/content/installation.en-us.md b/docs/content/installation.en-us.md deleted file mode 100644 index 32933f0f78..0000000000 --- a/docs/content/installation.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Installation" -slug: "installation" -sidebar_position: 10 -toc: false -draft: false -menu: - sidebar: - name: "Installation" - sidebar_position: 10 - identifier: "installation" ---- diff --git a/docs/content/installation.zh-cn.md b/docs/content/installation.zh-cn.md deleted file mode 100644 index 979abc28c1..0000000000 --- a/docs/content/installation.zh-cn.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "安装" -slug: "installation" -sidebar_position: 10 -toc: false -draft: false -menu: - sidebar: - name: "安装" - sidebar_position: 10 - identifier: "installation" ---- diff --git a/docs/content/installation/_index.en-us.md b/docs/content/installation/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/installation/_index.en-us.md +++ /dev/null diff --git a/docs/content/installation/_index.zh-cn.md b/docs/content/installation/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/installation/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/installation/comparison.en-us.md b/docs/content/installation/comparison.en-us.md deleted file mode 100644 index fdb8c3bcde..0000000000 --- a/docs/content/installation/comparison.en-us.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -date: "2018-05-07T13:00:00+02:00" -title: "Compared to other Git hosting" -slug: "comparison" -sidebar_position: 5 -toc: false -draft: false -aliases: - - /en-us/comparison -menu: - sidebar: - name: "Comparison" - sidebar_position: 5 - parent: installation - identifier: "comparison" ---- - -# Gitea compared to other Git hosting options - -To help decide if Gitea is suited for your needs, here is how it compares to other Git self hosted options. - -Be warned that we don't regularly check for feature changes in other products, so this list may be outdated. If you find anything that needs to be updated in the table below, please [open an issue](https://github.com/go-gitea/gitea/issues/new/choose). - -_Symbols used in table:_ - -- _✓ - supported_ - -- _⁄ - supported with limited functionality_ - -- _✘ - unsupported_ - -- _⚙️ - supported through third-party software_ - -## General Features - -| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | RhodeCode EE | -| ------------------------------------------------ | --------------------------------------------------- | ---- | --------- | --------- | --------- | --------- | ------------ | ------------ | -| Open source and free | ✓ | ✓ | ✘ | ✓ | ✘ | ✘ | ✓ | ✓ | -| Low RAM/ CPU usage | ✓ | ✓ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | -| Multiple database support | ✓ | ✓ | ✘ | ⁄ | ⁄ | ✓ | ✓ | ✓ | -| Multiple OS support | ✓ | ✓ | ✘ | ✘ | ✘ | ✘ | ✓ | ✓ | -| Easy upgrades | ✓ | ✓ | ✘ | ✓ | ✓ | ✘ | ✓ | ✓ | -| Telemetry | **✘** | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Third-party render tool support | ✓ | ✘ | ✘ | ✘ | ✘ | ✓ | ✘ | ✘ | -| WebAuthn (2FA) | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✓ | -| Extensive API | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Built-in Package/Container Registry | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Sync commits to an external repo (push mirror) | ✓ | ✓ | ✘ | ✓ | ✓ | ✘ | ✓ | ✓ | -| Sync commits from an external repo (pull mirror) | ✓ | ✘ | ✘ | ✓ | ✓ | ✘ | ✓ | ✓ | -| Light and Dark Theme | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Custom Theme Support | ✓ | ✓ | ✘ | ✘ | ✘ | ✓ | ✓ | ✓ | -| Markdown support | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| CSV support | ✓ | ✘ | ✓ | ✘ | ✘ | ✓ | ✘ | ✘ | -| 'GitHub / GitLab pages' | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Gists / Snippets | [⚙️][opengist] | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Repo-specific wiki (as a repo itself) | ✓ | ✓ | ✓ | ✓ | ✓ | / | ✘ | ✘ | -| Deploy Tokens | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Repository Tokens with write rights | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| RSS Feeds | ✓ | ✘ | ✓ | ✘ | ✘ | ✘ | ✓ | ✓ | -| Built-in CI/CD | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Subgroups: groups within groups | [✘](https://github.com/go-gitea/gitea/issues/1872) | ✘ | ✘ | ✓ | ✓ | ✘ | ✓ | ✓ | -| Interaction with other instances | [/](https://github.com/go-gitea/gitea/issues/18240) | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | -| Mermaid diagrams in Markdown | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Math syntax in Markdown | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✓ | ✓ | - -## Code management - -| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | RhodeCode EE | -| ------------------------------------------- | --------------------------------------------------- | ---- | --------- | --------- | --------- | --------- | ------------ | ------------ | -| Repository topics | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Repository code search | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Global code search | ✓ | ✘ | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | -| Git LFS 2.0 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Group Milestones | [✘](https://github.com/go-gitea/gitea/issues/14622) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Granular user roles (Code, Issues, Wiki, …) | ✓ | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Verified Committer | ⁄ | ✘ | ? | ✓ | ✓ | ✓ | ✘ | ✘ | -| GPG Signed Commits | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| SSH Signed Commits | ✓ | ✘ | ✓ | ✓ | ✓ | ? | ✘ | ✘ | -| Reject unsigned commits | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Migrating repos from other services | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Repository Activity page | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Branch manager | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Create new branches | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Web code editor | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Commit graph | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Template Repositories | ✓ | ✘ | ✓ | ✘ | ✓ | ✓ | ✘ | ✘ | -| Git Blame | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Visual comparison of image changes | ✓ | ✘ | ✓ | ? | ? | ? | ✘ | ✘ | - -- Gitea has builtin repository-level code search -- Better code search support could be achieved by [using a repository indexer](administration/repo-indexer.md) - -## Issue Tracker - -| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | RhodeCode EE | -| ----------------------------- | --------------------------------------------------- | ---- | --------- | --------- | --------- | --------- | ------------ | ------------ | -| Issue tracker | ✓ | ✓ | ✓ | ✓ | ✓ | / | ✘ | ✘ | -| Issue templates | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Labels | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Time tracking | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Multiple assignees for issues | ✓ | ✘ | ✓ | ✘ | ✓ | ✘ | ✘ | ✘ | -| Related issues | ✘ | ✘ | ⁄ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Confidential issues | [✘](https://github.com/go-gitea/gitea/issues/3217) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Comment reactions | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Lock Discussion | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Batch issue handling | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Projects | [/](https://github.com/go-gitea/gitea/issues/14710) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Create branch from issue | [✘](https://github.com/go-gitea/gitea/issues/20226) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Convert comment to new issue | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Issue search | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Global issue search | [/](https://github.com/go-gitea/gitea/issues/2434) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Issue dependency | ✓ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | -| Create issue via email | [✘](https://github.com/go-gitea/gitea/issues/6226) | ✘ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Service Desk | [✘](https://github.com/go-gitea/gitea/issues/6219) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✘ | - -## Pull/Merge requests - -| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | RhodeCode EE | -| ----------------------------------------------- | -------------------------------------------------- | ---- | --------- | --------- | --------- | --------- | ------------ | ------------ | -| Pull/Merge requests | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Squash merging | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Rebase merging | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Pull/Merge request inline comments | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Pull/Merge request approval | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Pull/Merge require approval | ✓ | ✘ | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | -| Pull/Merge multiple reviewers | ✓ | ✓ | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | -| Merge conflict resolution | [✘](https://github.com/go-gitea/gitea/issues/9014) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Restrict push and merge access to certain users | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Revert specific commits | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Pull/Merge requests templates | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | -| Cherry-picking changes | ✓ | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | ✓ | -| Download Patch | ✓ | ✘ | ✓ | ✓ | ✓ | / | ✓ | ✓ | -| Merge queues | ✘ | ✘ | ✓ | ✘ | ✓ | ✘ | ✘ | ✘ | - -## 3rd-party integrations - -| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | RhodeCode EE | -| ---------------------------------------------- | ------------------------------------------------ | ---- | --------- | --------- | --------- | --------- | ------------ | ------------ | -| Webhooks | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Git Hooks | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| AD / LDAP integration | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Multiple LDAP / AD server support | ✓ | ✓ | ✘ | ✘ | ✓ | ✓ | ✓ | ✓ | -| LDAP user synchronization | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✓ | -| SAML 2.0 service provider | [✘](https://github.com/go-gitea/gitea/issues/5512) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✓ | -| OpenID Connect support | ✓ | ✘ | ✓ | ✓ | ✓ | ? | ✘ | ✓ | -| OAuth 2.0 integration (external authorization) | ✓ | ✘ | ⁄ | ✓ | ✓ | ? | ✘ | ✓ | -| Act as OAuth 2.0 provider | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Two factor authentication (2FA) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✓ | -| Integration with the most common services | ✓ | / | ⁄ | ✓ | ✓ | ⁄ | ✓ | ✓ | -| Incorporate external CI/CD | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - -[gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea -[gitea-pages-server]: https://codeberg.org/Codeberg/pages-server -[opengist]: https://github.com/thomiceli/opengist diff --git a/docs/content/installation/comparison.zh-cn.md b/docs/content/installation/comparison.zh-cn.md deleted file mode 100644 index 422d6314c5..0000000000 --- a/docs/content/installation/comparison.zh-cn.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -date: "2019-02-14T11:51:04+08:00" -title: "对比 Gitea 与其它 Git 托管工具" -slug: "comparison" -sidebar_position: 5 -toc: false -draft: false -aliases: - - /zh-cn/comparison -menu: - sidebar: - parent: "installation" - name: "横向对比" - sidebar_position: 5 - identifier: "comparison" ---- - -# 对比 Gitea 与其它 Git 托管工具 - -这里列出了 Gitea 与其它一些 Git 托管工具之间的异同,以便确认 Gitea 是否能够满足您的需求。 - -请注意,此列表中的某些表项可能已经过时,因为我们并没有定期检查其它产品的功能是否有所更改。你可以前往 [Github issue](https://github.com/go-gitea/gitea/issues) 来帮助我们更新过时的内容,感谢! - -_表格中的符号含义:_ - -* _✓ - 支持_ - -* _⁄ - 部分支持_ - -* _✘ - 不支持_ - -* _⚙️ - 由第三方服务或插件支持_ - -#### 主要特性 - -| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | -| ------------------------------- | -------------------------------------------------- | ---- | --------- | --------- | --------- | -------------- | ------------ | -| 开源免费 | ✓ | ✓ | ✘ | ✓ | ✘ | ✘ | ✓ | -| 低资源开销 (RAM/CPU) | ✓ | ✓ | ✘ | ✘ | ✘ | ✘ | ✘ | -| 支持多种数据库 | ✓ | ✓ | ✘ | ⁄ | ⁄ | ✓ | ✓ | -| 支持多种操作系统 | ✓ | ✓ | ✘ | ✘ | ✘ | ✘ | ✓ | -| 升级简便 | ✓ | ✓ | ✘ | ✓ | ✓ | ✘ | ✓ | -| 可观测性 | **✘** | ✘ | ✓ | ✓ | ✓ | ✓ | ? | -| 支持第三方渲染工具 | ✓ | ✘ | ✘ | ✘ | ✘ | ✓ | ? | -| WebAuthn (2FA) | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ? | -| 扩展 API | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 内置软件包/容器注册中心 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 同步提交到外部仓库 (push mirror) | ✓ | ✓ | ✘ | ✓ | ✓ | ✘ | ✓ | -| 同步外部仓库的提交 (pull mirror) | ✓ | ✘ | ✘ | ✓ | ✓ | ✘ | ? | -| 浅色和深色主题 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ? | -| 自定义主题支持 | ✓ | ✓ | ✘ | ✘ | ✘ | ✓ | ✘ | -| 支持 Markdown | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 支持 CSV | ✓ | ✘ | ✓ | ✘ | ✘ | ✓ | ? | -| Git 驱动的静态 pages | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Git 驱动的集成化 wiki | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ (cloud only) | ✘ | -| 部署令牌 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 仓库写权限令牌 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| RSS Feeds | ✓ | ✘ | ✓ | ✘ | ✘ | ✘ | ✘ | -| 内置 CI/CD | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 子组织:组织内的组织 | [✘](https://github.com/go-gitea/gitea/issues/1872) | ✘ | ✘ | ✓ | ✓ | ✘ | ✓ | -| 多实例交互 | [/](https://github.com/go-gitea/gitea/issues/18240) | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | -| Markdown绘图 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| Markdown数学公式 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | - -#### 代码管理 - -| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | -| ------------------------------------ | --------------------------------------------------- | ---- | --------- | --------- | --------- | --------- | ------------ | -| 仓库主题描述 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 仓库内代码搜索 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 全局代码搜索 | ✓ | ✘ | ✓ | ✘ | ✓ | ✓ | ✓ | -| Git LFS 2.0 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 组织里程碑 | [✘](https://github.com/go-gitea/gitea/issues/14622) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 细粒度用户角色 | ✓ | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 提交人的身份验证 | ⁄ | ✘ | ? | ✓ | ✓ | ✓ | ✘ | -| GPG 签名的提交 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| SSH 签名的提交 | ✓ | ✘ | ✓ | ✓ | ✓ | ? | ? | -| 拒绝未通过验证的提交 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 外部仓库迁移 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 仓库活跃度页面 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 分支管理 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 建立新分支 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 在线代码编辑 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 提交的统计图表 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 模板仓库 | ✓ | ✘ | ✓ | ✘ | ✓ | ✓ | ✘ | -| Git Blame | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 可视化镜像变化 | ✓ | ✘ | ✓ | ? | ? | ? | ? | - -#### 工单管理 - -| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | -| ------------------- | -------------------------------------------------- | --------------------------------------------- | --------- | ----------------------------------------------------------------------- | --------- | -------------- | ------------ | -| 工单跟踪 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ (cloud only) | ✘ | -| 工单模板 | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 标签 | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 时间跟踪 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 支持多个负责人 | ✓ | ✘ | ✓ | ✘ | ✓ | ✘ | ✘ | -| 关联的工单 | ✘ | ✘ | ⁄ | [✓](https://docs.gitlab.com/ce/user/project/issues/related_issues.html) | ✓ | ✘ | ✘ | -| 私密工单 | [✘](https://github.com/go-gitea/gitea/issues/3217) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 评论反馈 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 锁定讨论 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 工单批处理 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 工单看板 | [✓](https://github.com/go-gitea/gitea/pull/8346) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 从工单创建分支 | ✘ | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 从评论创建工单 | ✓ | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 工单搜索 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 工单全局搜索 | [✘](https://github.com/go-gitea/gitea/issues/2434) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 工单依赖关系 | ✓ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | -| 通过 Email 创建工单 | [✘](https://github.com/go-gitea/gitea/issues/6226) | [✘](https://github.com/gogs/gogs/issues/2602) | ✘ | ✓ | ✓ | ✓ | ✘ | -| 服务台 | [✘](https://github.com/go-gitea/gitea/issues/6219) | ✘ | ✘ | [✓](https://gitlab.com/groups/gitlab-org/-/epics/3103) | ✓ | ✘ | ✘ | - -#### Pull/Merge requests - -| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | -| ------------------------------------ | -------------------------------------------------- | ---- | --------- | --------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------ | ------------ | -| Pull/Merge requests | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Squash merging | ✓ | ✘ | ✓ | [✓](https://docs.gitlab.com/ce/user/project/merge_requests/squash_and_merge.html) | ✓ | ✓ | ✓ | -| Rebase merging | ✓ | ✓ | ✓ | ✘ | ⁄ | ✘ | ✓ | -| 评论 Pull/Merge request 中的某行代码 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 指定 Pull/Merge request 的审核人 | ✓ | ✘ | ⁄ | ✓ | ✓ | ✓ | ✓ | -| 解决 Merge 冲突 | [✘](https://github.com/go-gitea/gitea/issues/5158) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 限制某些用户的 push 和 merge 权限 | ✓ | ✘ | ✓ | ⁄ | ✓ | ✓ | ✓ | -| 回退某些 commits 或 merge request | [✓](https://github.com/go-gitea/gitea/issues/5158) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| Pull/Merge requests 模板 | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 查看 Cherry-picking 的更改 | [✓](https://github.com/go-gitea/gitea/issues/5158) | ✘ | ✘ | ✓ | ✓ | ✘ | ✘ | -| 下载 Patch | ✓ | ✘ | ✓ | ✓ | ✓ | [/](https://jira.atlassian.com/plugins/servlet/mobile#issue/BCLOUD-8323) | ✘ | -| Merge queues | ✘ | ✘ | ✓ | ✘ | ✓ | ✘ | ✘ | - -#### 第三方集成 - -| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE | -| -------------------------- | -------------------------------------------------- | --------------------------------------------- | --------- | --------- | --------- | --------- | ------------ | -| 支持 Webhook | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 自定义 Git 钩子 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 集成 AD / LDAP | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| 支持多个 LDAP / AD 服务 | ✓ | ✓ | ✘ | ✘ | ✓ | ✓ | ✓ | -| LDAP 用户同步 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | -| SAML 2.0 service provider | [✘](https://github.com/go-gitea/gitea/issues/5512) | [✘](https://github.com/gogs/gogs/issues/1221) | ✓ | ✓ | ✓ | ✓ | ✘ | -| 支持 OpenId 连接 | ✓ | ✘ | ✓ | ✓ | ✓ | ? | ✘ | -| 集成 OAuth 2.0(外部授权) | ✓ | ✘ | ⁄ | ✓ | ✓ | ? | ✓ | -| 作为 OAuth 2.0 provider | [✓](https://github.com/go-gitea/gitea/pull/5378) | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 二次验证 (2FA) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 集成 Mattermost/Slack | ✓ | ✓ | ⁄ | ✓ | ✓ | ⁄ | ✓ | -| 集成 Discord | ✓ | ✓ | ✓ | ✓ | ✓ | ✘ | ✘ | -| 集成 Microsoft Teams | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✘ | -| 显示外部 CI/CD 的状态 | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | - -[gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea -[gitea-pages-server]: https://codeberg.org/Codeberg/pages-server diff --git a/docs/content/installation/database-preparation.en-us.md b/docs/content/installation/database-preparation.en-us.md deleted file mode 100644 index e6abb8a613..0000000000 --- a/docs/content/installation/database-preparation.en-us.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -date: "2020-01-16" -title: "Database Preparation" -slug: "database-prep" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /en-us/database-prep -menu: - sidebar: - parent: "installation" - name: "Database preparation" - sidebar_position: 10 - identifier: "database-prep" ---- - -# Database Preparation - -You need a database to use Gitea. Gitea supports PostgreSQL (>= 12), MySQL (>= 8.0), MariaDB (>= 10.4), SQLite (builtin), and MSSQL (>= 2012 SP4). This page will guide into preparing database. Only PostgreSQL and MySQL will be covered here since those database engines are widely-used in production. If you plan to use SQLite, you can ignore this chapter. - -If you use an unsupported database version, please [get in touch](/help/support) with us for information on our Extended Support Contracts. We can provide testing and support for older databases and integrate those fixes into the Gitea codebase. - -Database instance can be on same machine as Gitea (local database setup), or on different machine (remote database). - -Note: All steps below requires that the database engine of your choice is installed on your system. For remote database setup, install the server application on database instance and client program on your Gitea server. The client program is used to test connection to the database from Gitea server, while Gitea itself use database driver provided by Go to accomplish the same thing. In addition, make sure you use same engine version for both server and client for some engine features to work. For security reason, protect `root` (MySQL) or `postgres` (PostgreSQL) database superuser with secure password. The steps assumes that you run Linux for both database and Gitea servers. - -## MySQL/MariaDB - -1. For remote database setup, you will need to make MySQL listen to your IP address. Edit `bind-address` option on `/etc/mysql/my.cnf` on database instance to: - - ```ini - bind-address = 203.0.113.3 - ``` - -2. On database instance, login to database console as root: - - ``` - mysql -u root -p - ``` - - Enter the password as prompted. - -3. Create database user which will be used by Gitea, authenticated by password. This example uses `'gitea'` as password. Please use a secure password for your instance. - - For local database: - - ```sql - SET old_passwords=0; - CREATE USER 'gitea'@'%' IDENTIFIED BY 'gitea'; - ``` - - For remote database: - - ```sql - SET old_passwords=0; - CREATE USER 'gitea'@'192.0.2.10' IDENTIFIED BY 'gitea'; - ``` - - where `192.0.2.10` is the IP address of your Gitea instance. - - Replace username and password above as appropriate. - -4. Create database with UTF-8 charset and case-sensitive collation. - - `utf8mb4_bin` is a common collation for both MySQL/MariaDB. - When Gitea starts, it will try to find a better collation (`utf8mb4_0900_as_cs` or `uca1400_as_cs`) and alter the database if it is possible. - If you would like to use other collation, you can set `[database].CHARSET_COLLATION` in the `app.ini` file. - - ```sql - CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin'; - ``` - - Replace database name as appropriate. - -5. Grant all privileges on the database to database user created above. - - For local database: - - ```sql - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'; - FLUSH PRIVILEGES; - ``` - - For remote database: - - ```sql - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'192.0.2.10'; - FLUSH PRIVILEGES; - ``` - -6. Quit from database console by `exit`. - -7. On your Gitea server, test connection to the database: - - ``` - mysql -u gitea -h 203.0.113.3 -p giteadb - ``` - - where `gitea` is database username, `giteadb` is database name, and `203.0.113.3` is IP address of database instance. Omit `-h` option for local database. - - You should be connected to the database. - -## PostgreSQL - -1. For remote database setup, configure PostgreSQL on database instance to listen to your IP address by editing `listen_addresses` on `postgresql.conf` to: - - ```ini - listen_addresses = 'localhost, 203.0.113.3' - ``` - -2. PostgreSQL uses `md5` challenge-response encryption scheme for password authentication by default. Nowadays this scheme is not considered secure anymore. Use SCRAM-SHA-256 scheme instead by editing the `postgresql.conf` configuration file on the database server to: - - ```ini - password_encryption = scram-sha-256 - ``` - - Restart PostgreSQL to apply the setting. - -3. On the database server, login to the database console as superuser: - - ``` - su -c "psql" - postgres - ``` - -4. Create database user (role in PostgreSQL terms) with login privilege and password. Please use a secure, strong password instead of `'gitea'` below: - - ```sql - CREATE ROLE gitea WITH LOGIN PASSWORD 'gitea'; - ``` - - Replace username and password as appropriate. - -5. Create database with UTF-8 charset and owned by the database user created earlier. Any `libc` collations can be specified with `LC_COLLATE` and `LC_CTYPE` parameter, depending on expected content: - - ```sql - CREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8'; - ``` - - Replace database name as appropriate. - -6. Allow the database user to access the database created above by adding the following authentication rule to `pg_hba.conf`. - - For local database: - - ```ini - local giteadb gitea scram-sha-256 - ``` - - For remote database: - - ```ini - host giteadb gitea 192.0.2.10/32 scram-sha-256 - ``` - - Replace database name, user, and IP address of Gitea instance with your own. - - Note: rules on `pg_hba.conf` are evaluated sequentially, that is the first matching rule will be used for authentication. Your PostgreSQL installation may come with generic authentication rules that match all users and databases. You may need to place the rules presented here above such generic rules if it is the case. - - Restart PostgreSQL to apply new authentication rules. - -7. On your Gitea server, test connection to the database. - - For local database: - - ``` - psql -U gitea -d giteadb - ``` - - For remote database: - - ``` - psql "postgres://gitea@203.0.113.3/giteadb" - ``` - - where `gitea` is database user, `giteadb` is database name, and `203.0.113.3` is IP address of your database instance. - - You should be prompted to enter password for the database user, and connected to the database. - -## Database Connection over TLS - -If the communication between Gitea and your database instance is performed through a private network, or if Gitea and the database are running on the same server, this section can be omitted since the security between Gitea and the database instance is not critically exposed. If instead the database instance is on a public network, use TLS to encrypt the connection to the database, as it is possible for third-parties to intercept the traffic data. - -### Prerequisites - -- You need two valid TLS certificates, one for the database instance (database server) and one for the Gitea instance (database client). Both certificates must be signed by a trusted CA. -- The database certificate must contain `TLS Web Server Authentication` in the `X509v3 Extended Key Usage` extension attribute, while the client certificate needs `TLS Web Client Authentication` in the corresponding attribute. -- On the database server certificate, one of `Subject Alternative Name` or `Common Name` entries must be the fully-qualified domain name (FQDN) of the database instance (e.g. `db.example.com`). On the database client certificate, one of the entries mentioned above must contain the database username that Gitea will be using to connect. -- You need domain name mappings of both Gitea and database servers to their respective IP addresses. Either set up DNS records for them or add local mappings to `/etc/hosts` (`%WINDIR%\System32\drivers\etc\hosts` in Windows) on each system. This allows the database connections to be performed by domain name instead of IP address. See documentation of your system for details. - -### PostgreSQL TLS - -The PostgreSQL driver used by Gitea supports two-way TLS. In two-way TLS, both database client and server authenticate each other by sending their respective certificates to their respective opposite for validation. In other words, the server verifies client certificate, and the client verifies server certificate. - -1. On the server with the database instance, place the following credentials: - - - `/path/to/postgresql.crt`: Database instance certificate - - `/path/to/postgresql.key`: Database instance private key - - `/path/to/root.crt`: CA certificate chain to validate client certificates - -2. Add following options to `postgresql.conf`: - - ```ini - ssl = on - ssl_ca_file = '/path/to/root.crt' - ssl_cert_file = '/path/to/postgresql.crt' - ssl_key_file = '/path/to/postgresql.key' - ssl_min_protocol_version = 'TLSv1.2' - ``` - -3. Adjust credentials ownership and permission, as required by PostgreSQL: - - ``` - chown postgres:postgres /path/to/root.crt /path/to/postgresql.crt /path/to/postgresql.key - chmod 0600 /path/to/root.crt /path/to/postgresql.crt /path/to/postgresql.key - ``` - -4. Edit `pg_hba.conf` rule to only allow Gitea database user to connect over SSL, and to require client certificate verification. - - For PostgreSQL 12: - - ```ini - hostssl giteadb gitea 192.0.2.10/32 scram-sha-256 clientcert=verify-full - ``` - - For PostgreSQL 11 and earlier: - - ```ini - hostssl giteadb gitea 192.0.2.10/32 scram-sha-256 clientcert=1 - ``` - - Replace database name, user, and IP address of Gitea instance as appropriate. - -5. Restart PostgreSQL to apply configurations above. - -6. On the server running the Gitea instance, place the following credentials under the home directory of the user who runs Gitea (e.g. `git`): - - - `~/.postgresql/postgresql.crt`: Database client certificate - - `~/.postgresql/postgresql.key`: Database client private key - - `~/.postgresql/root.crt`: CA certificate chain to validate server certificate - - Note: Those file names above are hardcoded in PostgreSQL and it is not possible to change them. - -7. Adjust credentials, ownership and permission as required: - - ``` - chown git:git ~/.postgresql/postgresql.crt ~/.postgresql/postgresql.key ~/.postgresql/root.crt - chown 0600 ~/.postgresql/postgresql.crt ~/.postgresql/postgresql.key ~/.postgresql/root.crt - ``` - -8. Test the connection to the database: - - ``` - psql "postgres://gitea@example.db/giteadb?sslmode=verify-full" - ``` - - You should be prompted to enter password for the database user, and then be connected to the database. - -### MySQL/MariaDB TLS - -While the MySQL driver used by Gitea also supports two-way TLS, Gitea currently supports only one-way TLS. See issue #10828 for details. - -In one-way TLS, the database client verifies the certificate sent from server during the connection handshake, and the server assumes that the connected client is legitimate, since client certificate verification doesn't take place. - -1. On the database instance, place the following credentials: - - - `/path/to/mysql.crt`: Database instance certificate - - `/path/to/mysql.key`: Database instance key - - `/path/to/ca.crt`: CA certificate chain. This file isn't used on one-way TLS, but is used to validate client certificates on two-way TLS. - -2. Add following options to `my.cnf`: - - ```ini - [mysqld] - ssl-ca = /path/to/ca.crt - ssl-cert = /path/to/mysql.crt - ssl-key = /path/to/mysql.key - tls-version = TLSv1.2,TLSv1.3 - ``` - -3. Adjust credentials ownership and permission: - - ``` - chown mysql:mysql /path/to/ca.crt /path/to/mysql.crt /path/to/mysql.key - chmod 0600 /path/to/ca.crt /path/to/mysql.crt /path/to/mysql.key - ``` - -4. Restart MySQL to apply the setting. - -5. The database user for Gitea may have been created earlier, but it would authenticate only against the IP addresses of the server running Gitea. To authenticate against its domain name, recreate the user, and this time also set it to require TLS for connecting to the database: - - ```sql - DROP USER 'gitea'@'192.0.2.10'; - CREATE USER 'gitea'@'example.gitea' IDENTIFIED BY 'gitea' REQUIRE SSL; - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'example.gitea'; - FLUSH PRIVILEGES; - ``` - - Replace database user name, password, and Gitea instance domain as appropriate. - -6. Make sure that the CA certificate chain required to validate the database server certificate is on the system certificate store of both the database and Gitea servers. Consult your system documentation for instructions on adding a CA certificate to the certificate store. - -7. On the server running Gitea, test connection to the database: - - ``` - mysql -u gitea -h example.db -p --ssl - ``` - - You should be connected to the database. diff --git a/docs/content/installation/database-preparation.zh-cn.md b/docs/content/installation/database-preparation.zh-cn.md deleted file mode 100644 index 3fde004a8c..0000000000 --- a/docs/content/installation/database-preparation.zh-cn.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -date: "2020-01-16" -title: "数据库准备" -slug: "database-prep" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /zh-cn/database-prep -menu: - sidebar: - parent: "installation" - name: "数据库准备" - sidebar_position: 10 - identifier: "database-prep" ---- - -# 数据库准备 - -在使用 Gitea 前,您需要准备一个数据库。Gitea 支持 PostgreSQL(>= 12)、MySQL(>= 8.0)、MariaDB(>= 10.4)、SQLite(内置) 和 MSSQL(>= 2012 SP4)这几种数据库。本页将指导您准备数据库。由于 PostgreSQL 和 MySQL 在生产环境中被广泛使用,因此本文档将仅涵盖这两种数据库。如果您计划使用 SQLite,则可以忽略本章内容。 - -如果您使用不受支持的数据库版本,请通过 [联系我们](/help/support) 以获取有关我们的扩展支持的信息。我们可以为旧数据库提供测试和支持,并将这些修复集成到 Gitea 代码库中。 - -数据库实例可以与 Gitea 实例在相同机器上(本地数据库),也可以与 Gitea 实例在不同机器上(远程数据库)。 - -注意:以下所有步骤要求您的选择的数据库引擎已安装在您的系统上。对于远程数据库设置,请在数据库实例上安装服务器应用程序,在 Gitea 服务器上安装客户端程序。客户端程序用于测试 Gitea 服务器与数据库之间的连接,而 Gitea 本身使用 Go 提供的数据库驱动程序完成相同的任务。此外,请确保服务器和客户端使用相同的引擎版本,以使某些引擎功能正常工作。出于安全原因,请使用安全密码保护 `root`(MySQL)或 `postgres`(PostgreSQL)数据库超级用户。以下步骤假设您在数据库和 Gitea 服务器上都使用 Linux。 - -## MySQL/MariaDB - -1. 对于远程数据库设置,您需要让 MySQL 监听您的 IP 地址。编辑数据库实例上的 `/etc/mysql/my.cnf` 文件中的 `bind-address` 选项为: - - ```ini - bind-address = 203.0.113.3 - ``` - -2. 在数据库实例上,使用 `root` 用户登录到数据库控制台: - - ``` - mysql -u root -p - ``` - - 按提示输入密码。 - -3. 创建一个将被 Gitea 使用的数据库用户,并使用密码进行身份验证。以下示例中使用了 `'gitea'` 作为密码。请为您的实例使用一个安全密码。 - - 对于本地数据库: - - ```sql - SET old_passwords=0; - CREATE USER 'gitea' IDENTIFIED BY 'gitea'; - ``` - - 对于远程数据库: - - ```sql - SET old_passwords=0; - CREATE USER 'gitea'@'192.0.2.10' IDENTIFIED BY 'gitea'; - ``` - - 其中 `192.0.2.10` 是您的 Gitea 实例的 IP 地址。 - - 根据需要替换上述用户名和密码。 - -4. 使用 UTF-8 字符集和大小写敏感的排序规则创建数据库。 - - `utf8mb4_bin` 是 MySQL/MariaDB 的通用排序规则。 - Gitea 启动后会尝试把数据库修改为更合适的字符集 (`utf8mb4_0900_as_cs` 或者 `uca1400_as_cs`) 并在可能的情况下更改数据库。 - 如果你想指定自己的字符集规则,可以在 `app.ini` 中设置 `[database].CHARSET_COLLATION`。 - - ```sql - CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin'; - ``` - - 根据需要替换数据库名称。 - -5. 将数据库上的所有权限授予上述创建的数据库用户。 - - 对于本地数据库: - - ```sql - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'; - FLUSH PRIVILEGES; - ``` - - 对于远程数据库: - - ```sql - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'192.0.2.10'; - FLUSH PRIVILEGES; - ``` - -6. 通过 `exit` 退出数据库控制台。 - -7. 在您的 Gitea 服务器上,测试与数据库的连接: - - ``` - mysql -u gitea -h 203.0.113.3 -p giteadb - ``` - - 其中 `gitea` 是数据库用户名,`giteadb` 是数据库名称,`203.0.113.3` 是数据库实例的 IP 地址。对于本地数据库,省略 `-h` 选项。 - - 到此您应该能够连接到数据库了。 - -## PostgreSQL - -1. 对于远程数据库设置,通过编辑数据库实例上的 postgresql.conf 文件中的 `listen_addresses` 将 `PostgreSQL` 配置为监听您的 IP 地址: - - ```ini - listen_addresses = 'localhost, 203.0.113.3' - ``` - -2. PostgreSQL 默认使用 `md5` 质询-响应加密方案进行密码身份验证。现在这个方案不再被认为是安全的。改用 SCRAM-SHA-256 方案,通过编辑数据库服务器上的` postgresql.conf` 配置文件: - - ```ini - password_encryption = scram-sha-256 - ``` - - 重启 PostgreSQL 以应用该设置。 - -3. 在数据库服务器上,以超级用户身份登录到数据库控制台: - - ``` - su -c "psql" - postgres - ``` - -4. 创建具有登录权限和密码的数据库用户(在 PostgreSQL 术语中称为角色)。请使用安全的、强密码,而不是下面的 `'gitea'`: - - ```sql - CREATE ROLE gitea WITH LOGIN PASSWORD 'gitea'; - ``` - - 根据需要替换用户名和密码。 - -5. 使用 UTF-8 字符集创建数据库,并由之前创建的数据库用户拥有。可以根据预期内容使用任何 `libc` 排序规则,使用 `LC_COLLATE` 和 `LC_CTYPE` 参数指定: - - ```sql - CREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8'; - ``` - - 根据需要替换数据库名称。 - -6. 通过将以下身份验证规则添加到 `pg_hba.conf`,允许数据库用户访问上面创建的数据库。 - - 对于本地数据库: - - ```ini - local giteadb gitea scram-sha-256 - ``` - - 对于远程数据库: - - ```ini - host giteadb gitea 192.0.2.10/32 scram-sha-256 - ``` - - 根据您自己的数据库名称、用户和 Gitea 实例的 IP 地址进行替换。 - - 注意:`pg_hba.conf` 上的规则按顺序评估,也就是第一个匹配的规则将用于身份验证。您的 PostgreSQL 安装可能附带了适用于所有用户和数据库的通用身份验证规则。如果是这种情况,您可能需要将此处提供的规则放置在此类通用规则之上。 - - 重启 PostgreSQL 以应用新的身份验证规则。 - -7. 在您的 Gitea 服务器上,测试与数据库的连接。 - - 对于本地数据库: - - ``` - psql -U gitea -d giteadb - ``` - - 对于远程数据库: - - ``` - psql "postgres://gitea@203.0.113.3/giteadb" - ``` - - 其中 `gitea` 是数据库用户,`giteadb` 是数据库名称,`203.0.113.3` 是您的数据库实例的 IP 地址。 - - 您应该会被提示输入数据库用户的密码,并连接到数据库。 - -## 使用 TLS 进行数据库连接 - -如果 Gitea 和您的数据库实例之间的通信是通过私有网络进行的,或者如果 Gitea 和数据库运行在同一台服务器上,那么可以省略本节,因为 Gitea 和数据库实例之间的安全性不会受到严重威胁。但是,如果数据库实例位于公共网络上,请使用 TLS 对数据库连接进行加密,以防止第三方拦截流量数据。 - -### 先决条件 - -- 您需要两个有效的 TLS 证书,一个用于数据库实例(数据库服务器),一个用于 Gitea 实例(数据库客户端)。两个证书都必须由受信任的 CA 签名。 -- 数据库证书必须在 `X509v3 Extended Key Usage` 扩展属性中包含 `TLS Web Server Authentication`,而客户端证书则需要在相应的属性中包含 `TLS Web Client Authentication`。 -- 在数据库服务器证书中,`Subject Alternative Name` 或 `Common Name` 条目之一必须是数据库实例的完全限定域名(FQDN)(例如 `db.example.com`)。在数据库客户端证书中,上述提到的条目之一必须包含 Gitea 将用于连接的数据库用户名。 -- 您需要将 Gitea 和数据库服务器的域名映射到它们各自的 IP 地址。可以为它们设置 DNS 记录,也可以在每个系统上的 `/etc/hosts`(Windows 中的 `%WINDIR%\System32\drivers\etc\hosts`)中添加本地映射。这样可以通过域名而不是 IP 地址进行数据库连接。有关详细信息,请参阅您系统的文档。 - -### PostgreSQL TLS - -Gitea 使用的 PostgreSQL 驱动程序支持双向 TLS。在双向 TLS 中,数据库客户端和服务器通过将各自的证书发送给对方进行验证来相互认证。换句话说,服务器验证客户端证书,客户端验证服务器证书。 - -1. 在数据库实例所在的服务器上,放置以下凭据: - - - `/path/to/postgresql.crt`: 数据库实例证书 - - `/path/to/postgresql.key`: 数据库实例私钥 - - `/path/to/root.crt`: 用于验证客户端证书的CA证书链 - -2. 在 `postgresql.conf` 中添加以下选项: - - ```ini - ssl = on - ssl_ca_file = '/path/to/root.crt' - ssl_cert_file = '/path/to/postgresql.crt' - ssl_key_file = '/path/to/postgresql.key' - ssl_min_protocol_version = 'TLSv1.2' - ``` - -3. 根据 PostgreSQL 的要求,调整凭据的所有权和权限: - - ``` - chown postgres:postgres /path/to/root.crt /path/to/postgresql.crt /path/to/postgresql.key - chmod 0600 /path/to/root.crt /path/to/postgresql.crt /path/to/postgresql.key - ``` - -4. 编辑 `pg_hba.conf` 规则,仅允许 Gitea 数据库用户通过SSL连接,并要求客户端证书验证。 - - 对于PostgreSQL 12: - - ```ini - hostssl giteadb gitea 192.0.2.10/32 scram-sha-256 clientcert=verify-full - ``` - - 对于PostgreSQL 11及更早版本: - - ```ini - hostssl giteadb gitea 192.0.2.10/32 scram-sha-256 clientcert=1 - ``` - - 根据需要替换数据库名称、用户和 Gitea 实例的 IP 地址。 - -5. 重新启动 PostgreSQL 以应用上述配置。 - -6. 在运行 Gitea 实例的服务器上,将以下凭据放置在运行 Gitea 的用户的主目录下(例如 `git`): - - - `~/.postgresql/postgresql.crt`: 数据库客户端证书 - - `~/.postgresql/postgresql.key`: 数据库客户端私钥 - - `~/.postgresql/root.crt`: 用于验证服务器证书的CA证书链 - - 注意:上述文件名在 PostgreSQL 中是硬编码的,无法更改。 - -7. 根据需要调整凭据、所有权和权限: - - ``` - chown git:git ~/.postgresql/postgresql.crt ~/.postgresql/postgresql.key ~/.postgresql/root.crt - chown 0600 ~/.postgresql/postgresql.crt ~/.postgresql/postgresql.key ~/.postgresql/root.crt - ``` - -8. 测试与数据库的连接: - - ``` - psql "postgres://gitea@example.db/giteadb?sslmode=verify-full" - ``` - - 您将被提示输入数据库用户的密码,然后连接到数据库。 - -### MySQL/MariaDB TLS - -虽然 Gitea 使用的MySQL驱动程序也支持双向 TLS,但目前 Gitea 仅支持单向 TLS。有关详细信息,请参见工单#10828。 - -在单向TLS中,数据库客户端在连接握手期间验证服务器发送的证书,而服务器则假定连接的客户端是合法的,因为不进行客户端证书验证。 - -1. 在数据库实例上放置以下凭据: - - - `/path/to/mysql.crt`: 数据库实例证书 - - `/path/to/mysql.key`: 数据库实例密钥 - - `/path/to/ca.crt`: CA证书链。在单向TLS中不使用此文件,但用于验证双向TLS中的客户端证书。 - -2. 将以下选项添加到 `my.cnf`: - - ```ini - [mysqld] - ssl-ca = /path/to/ca.crt - ssl-cert = /path/to/mysql.crt - ssl-key = /path/to/mysql.key - tls-version = TLSv1.2,TLSv1.3 - ``` - -3. 调整凭据的所有权和权限: - - ``` - chown mysql:mysql /path/to/ca.crt /path/to/mysql.crt /path/to/mysql.key - chmod 0600 /path/to/ca.crt /path/to/mysql.crt /path/to/mysql.key - ``` - -4. 重新启动MySQL以应用设置。 - -5. Gitea 的数据库用户可能已经创建过,但只会对运行 Gitea 的服务器的 IP 地址进行身份验证。要对其域名进行身份验证,请重新创建用户,并设置其需要通过 TLS 连接到数据库: - - ```sql - DROP USER 'gitea'@'192.0.2.10'; - CREATE USER 'gitea'@'example.gitea' IDENTIFIED BY 'gitea' REQUIRE SSL; - GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'example.gitea'; - FLUSH PRIVILEGES; - ``` - - 根据需要替换数据库用户名、密码和 Gitea 实例域名。 - -6. 确保用于验证数据库服务器证书的CA证书链位于数据库和 Gitea 服务器的系统证书存储中。请参考系统文档中有关将 CA 证书添加到证书存储的说明。 - -7. 在运行Gitea的服务器上,测试与数据库的连接: - - ``` - mysql -u gitea -h example.db -p --ssl - ``` - - 至此应该成功连接到数据库了。 diff --git a/docs/content/installation/from-binary.en-us.md b/docs/content/installation/from-binary.en-us.md deleted file mode 100644 index 88f82be322..0000000000 --- a/docs/content/installation/from-binary.en-us.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -date: "2017-06-19T12:00:00+02:00" -title: "Installation from binary" -slug: "install-from-binary" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /en-us/install-from-binary -menu: - sidebar: - parent: "installation" - name: "From binary" - sidebar_position: 15 - identifier: "install-from-binary" ---- - -# Installation from binary - -All downloads come with SQLite, MySQL and PostgreSQL support, and are built with -embedded assets. This can be different from Gogs. - -## Download - -You can find the file matching your platform from the [downloads page](https://dl.gitea.com/gitea/) after navigating to the version you want to download. - -### Choosing the right file - -**For Linux**, you will likely want `linux-amd64`. It's for 64-bit Intel/AMD platforms, but there are other platforms available, including `arm64` (e.g. Raspberry PI 4), `386` (i.e. 32-bit), `arm-5`, and `arm-6`. - -**For Windows**, you will likely want `windows-4.0-amd64`. It's for all modern versions of Windows, but there is also a `386` platform available designed for older, 32-bit versions of Windows. - -*Note: there is also a `gogit-windows` file available that was created to help with some [performance problems](https://github.com/go-gitea/gitea/pull/15482) reported by some Windows users on older systems/versions. You should consider using this file if you're experiencing performance issues, and let us know if it improves performance.* - -**For macOS**, you should choose `darwin-arm64` if your hardware uses Apple Silicon, or `darwin-amd64` for Intel. - -**For FreeBSD**, you should choose `freebsd12-amd64` for 64-bit Intel/AMD platforms. - -### Downloading with wget - -Copy the commands below and replace the URL within the one you wish to download. - -```sh -wget -O gitea https://dl.gitea.com/gitea/@version@/gitea-@version@-linux-amd64 -chmod +x gitea -``` - -Note that the above command will download Gitea @version@ for 64-bit Linux. - -## Verify GPG signature - -Gitea signs all binaries with a [GPG key](https://keys.openpgp.org/search?q=teabot%40gitea.io) to prevent against unwanted modification of binaries. -To validate the binary, download the signature file which ends in `.asc` for the binary you downloaded and use the GPG command line tool. - -```sh -gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 -gpg --verify gitea-@version@-linux-amd64.asc gitea-@version@-linux-amd64 -``` - -Look for the text `Good signature from "Teabot <teabot@gitea.io>"` to assert a good binary, -despite warnings like `This key is not certified with a trusted signature!`. - -## Recommended server configuration - -**NOTE:** Many of the following directories can be configured using [Environment Variables](administration/environment-variables.md) as well! -Of note, configuring `GITEA_WORK_DIR` will tell Gitea where to base its working directory, as well as ease installation. - -### Prepare environment - -Check that Git is installed on the server. If it is not, install it first. Gitea requires Git version >= 2.0. - -```sh -git --version -``` - -Create a user to run Gitea (e.g. `git`) - -```sh -# On Ubuntu/Debian: -adduser \ - --system \ - --shell /bin/bash \ - --gecos 'Git Version Control' \ - --group \ - --disabled-password \ - --home /home/git \ - git - -# On Fedora/RHEL/CentOS: -groupadd --system git -adduser \ - --system \ - --shell /bin/bash \ - --comment 'Git Version Control' \ - --gid git \ - --home-dir /home/git \ - --create-home \ - git -``` - -### Create required directory structure - -```sh -mkdir -p /var/lib/gitea/{custom,data,log} -chown -R git:git /var/lib/gitea/ -chmod -R 750 /var/lib/gitea/ -mkdir /etc/gitea -chown root:git /etc/gitea -chmod 770 /etc/gitea -``` - -> **NOTE:** `/etc/gitea` is temporarily set with write permissions for user `git` so that the web installer can write the configuration file. After the installation is finished, it is recommended to set permissions to read-only using: -> -> ```sh -> chmod 750 /etc/gitea -> chmod 640 /etc/gitea/app.ini -> ``` - -If you don't want the web installer to be able to write to the config file, it is possible to make the config file read-only for the Gitea user (owner/group `root:git`, mode `0640`) however you will need to edit your config file manually to: - -* Set `INSTALL_LOCK= true`, -* Ensure all database configuration details are set correctly -* Ensure that the `SECRET_KEY` and `INTERNAL_TOKEN` values are set. (You may want to use the `gitea generate secret` to generate these secret keys.) -* Ensure that any other secret keys you need are set. - -See the [command line documentation](administration/command-line.md) for information on using `gitea generate secret`. - -### Configure Gitea's working directory - -**NOTE:** If you plan on running Gitea as a Linux service, you can skip this step, as the service file allows you to set `WorkingDirectory`. Otherwise, consider setting this environment variable (semi-)permanently so that Gitea consistently uses the correct working directory. - -```sh -export GITEA_WORK_DIR=/var/lib/gitea/ -``` - -### Copy the Gitea binary to a global location - -```sh -cp gitea /usr/local/bin/gitea -``` - -### Adding bash/zsh autocompletion (from 1.19) - -A script to enable bash-completion can be found at [`contrib/autocompletion/bash_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete). This can be copied to `/usr/share/bash-completion/completions/gitea` -or sourced within your `.bashrc`. - -Similarly a script for zsh-completion can be found at [`contrib/autocompletion/zsh_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/zsh_autocomplete). This can be copied to `/usr/share/zsh/_gitea` or sourced within your -`.zshrc`. - -YMMV and these scripts may need further improvement. - -## Running Gitea - -After you complete the above steps, you can run Gitea two ways: - -### 1. Creating a service file to start Gitea automatically (recommended) - -See how to create [Linux service](installation/run-as-service-in-ubuntu.md) - -### 2. Running from command-line/terminal - -```sh -GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini -``` - -## Updating to a new version - -You can update to a new version of Gitea by stopping Gitea, replacing the binary at `/usr/local/bin/gitea` and restarting the instance. -The binary file name should not be changed during the update to avoid problems in existing repositories. - -It is recommended that you make a [backup](administration/backup-and-restore.md) before updating your installation. - -If you have carried out the installation steps as described above, the binary should -have the generic name `gitea`. Do not change this, i.e. to include the version number. - -### 1. Restarting Gitea with systemd (recommended) - -As we explained before, we recommend to use systemd as the service manager. In this case, `systemctl restart gitea` should be fine. - -### 2. Restarting Gitea without systemd - -To restart your Gitea instance, we recommend to use SIGHUP signal. If you know your Gitea PID, use `kill -1 $GITEA_PID`, otherwise you can use `killall -1 gitea`. - -To gracefully stop the Gitea instance, a simple `kill $GITEA_PID` or `killall gitea` is enough. - -**NOTE:** We don't recommend to use the SIGKILL signal (`-9`); you may be forcefully stopping some of Gitea's internal tasks, and it will not gracefully stop (tasks in queues, indexers, etc.) - -See below for troubleshooting instructions to repair broken repositories after -an update of your Gitea version. - -## Troubleshooting - -### Old glibc versions - -Older Linux distributions (such as Debian 7 and CentOS 6) may not be able to load the -Gitea binary, usually producing an error such as `./gitea: /lib/x86_64-linux-gnu/libc.so.6: -version 'GLIBC\_2.14' not found (required by ./gitea)`. This is due to the integrated -SQLite support in the binaries provided by dl.gitea.com. In this situation, it is usually -possible to [install from source](installation/from-source.md), without including -SQLite support. - -### Running Gitea on another port - -For errors like `702 runWeb()] [E] Failed to start server: listen tcp 0.0.0.0:3000: -bind: address already in use`, Gitea needs to be started on another free port. This -is possible using `./gitea web -p $PORT`. It's possible another instance of Gitea -is already running. - -### Running Gitea on Raspbian - -As of v1.8, there is a problem with the arm7 version of Gitea, and it doesn't run on Raspberry Pis and similar devices. - -It is recommended to switch to the arm6 version, which has been tested and shown to work on Raspberry Pis and similar devices. - -<!--- -please remove after fixing the arm7 bug ----> -### Git error after updating to a new version of Gitea - -If during the update, the binary file name has been changed to a new version of Gitea, -Git Hooks in existing repositories will not work any more. In that case, a Git -error will be displayed when pushing to the repository. - -``` -remote: ./hooks/pre-receive.d/gitea: line 2: [...]: No such file or directory -``` - -The `[...]` part of the error message will contain the path to your previous Gitea -binary. - -To solve this, go to the admin options and run the task `Resynchronize pre-receive, -update and post-receive hooks of all repositories` to update all hooks to contain -the new binary path. Please note that this overwrites all Git Hooks, including ones -with customizations made. - -If you aren't using the Gitea built-in SSH server, you will also need to re-write -the authorized key file by running the `Update the '.ssh/authorized_keys' file with -Gitea SSH keys.` task in the admin options. diff --git a/docs/content/installation/from-binary.zh-cn.md b/docs/content/installation/from-binary.zh-cn.md deleted file mode 100644 index 216a6be51e..0000000000 --- a/docs/content/installation/from-binary.zh-cn.md +++ /dev/null @@ -1,214 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "使用二进制文件安装" -slug: "install-from-binary" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /zh-cn/install-from-binary -menu: - sidebar: - parent: "installation" - name: "使用二进制文件安装" - sidebar_position: 15 - identifier: "install-from-binary" ---- - -# 使用二进制文件安装 - -所有打包的二进制程序均包含 SQLite,MySQL 和 PostgreSQL 的数据库连接支持,同时网站的静态资源均已嵌入到可执行程序中,这一点和曾经的 Gogs 有所不同。 - -## 下载 - -你可以从 [下载页面](https://dl.gitea.com/gitea/) 选择对应平台的二进制文件。 - -### 选择架构 - -- **对于 Linux**,`linux-amd64` 适用于 64-bit 的 Intel/AMD 平台。更多架构包含 `arm64` (Raspberry PI 4),`386` (32-bit),`arm-5` 以及 `arm-6`。 - -- **对于 Windows**,`windows-4.0-amd64` 适用于 64-bit 的 Intel/AMD 平台,`386` 适用于 32-bit 的 Intel/AMD 平台。(提示:`gogit-windows` 版本内建了 gogit 可能缓解在旧的 Windows 平台上 Go 程序调用 git 子程序时面临的 [性能问题](https://github.com/go-gitea/gitea/pull/15482)) - -- **对于 macOS**,`darwin-arm64` 适用于 Apple Silicon 架构,`darwin-amd64` 适用于 Intel 架构. - -- **对于 FreeBSD**,`freebsd12-amd64` 适用于 64-bit 的 Intel/AMD 平台。 - -### 使用 wget 下载 - -使用以下命令下载适用于 64-bit Linux 平台的二进制文件。 - -```sh -wget -O gitea https://dl.gitea.com/gitea/@version@/gitea-@version@-linux-amd64 -chmod +x gitea -``` - -## 验证 GPG 签名 - -Gitea 对打包的二进制文件使用 [GPG密钥](https://keys.openpgp.org/search?q=teabot%40gitea.io) 签名以防止篡改。 -请根据对应文件名 `.asc` 中包含的校验码检验文件的一致性。 - -```sh -gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 -gpg --verify gitea-@version@-linux-amd64.asc gitea-@version@-linux-amd64 -``` - -校验正确时的信息为 `Good signature from "Teabot <teabot@gitea.io>"`。 -校验错误时的信息为 `This key is not certified with a trusted signature!`。 - -## 服务器设置 - -**提示:** `GITEA_WORK_DIR` 表示 Gitea 工作的路径。以下路径可以通过 [环境变量](administration/environment-variables.md) 初始化。 - -### 准备环境 - -检查是否安装 Git。要求 Git 版本 >= 2.0。 - -```sh -git --version -``` - -创建用户(推荐使用名称 `git`) - -```sh -# On Ubuntu/Debian: -adduser \ - --system \ - --shell /bin/bash \ - --gecos 'Git Version Control' \ - --group \ - --disabled-password \ - --home /home/git \ - git - -# On Fedora/RHEL/CentOS: -groupadd --system git -adduser \ - --system \ - --shell /bin/bash \ - --comment 'Git Version Control' \ - --gid git \ - --home-dir /home/git \ - --create-home \ - git -``` - -### 创建工作路径 - -```sh -mkdir -p /var/lib/gitea/{custom,data,log} -chown -R git:git /var/lib/gitea/ -chmod -R 750 /var/lib/gitea/ -mkdir /etc/gitea -chown root:git /etc/gitea -chmod 770 /etc/gitea -``` - -> **注意:** 为了让 Web 安装程序可以写入配置文件,我们临时为 `/etc/gitea` 路径授予了组外用户 `git` 写入权限。建议在安装结束后将配置文件的权限设置为只读。 -> -> ```sh -> chmod 750 /etc/gitea -> chmod 640 /etc/gitea/app.ini -> ``` - -如果您不希望通过 Web 安装程序创建配置文件,可以将配置文件设置为仅供 Gitea 用户只读(owner/group `root:git`, mode `0640`)并手工创建配置文件: - -- 设置 `INSTALL_LOCK=true` 关闭安装界面 -- 手动配置数据库连接参数 -- 使用 `gitea generate secret` 创建 `SECRET_KEY` 和 `INTERNAL_TOKEN` -- 提供所有必要的密钥 - -详情参考 [命令行文档](administration/command-line.md) 中有关 `gitea generate secret` 的内容。 - -### 配置 Gitea 工作路径 - -**提示:** 如果使用 Systemd 管理 Gitea 的 Linux 服务,你可以采用 `WorkingDirectory` 参数来配置工作路径。 否则,使用环境变量 `GITEA_WORK_DIR` 来明确指出程序工作和数据存放路径。 - -```sh -export GITEA_WORK_DIR=/var/lib/gitea/ -``` - -### 复制二进制文件到全局位置 - -```sh -cp gitea /usr/local/bin/gitea -``` - -### 添加 bash/zsh 自动补全(从 1.19 版本开始) - -可以在 [`contrib/autocompletion/bash_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete) 找到启用 bash 自动补全的脚本。可以将其复制到 `/usr/share/bash-completion/completions/gitea`,或在 `.bashrc` 中引用。 - -同样地,zsh 自动补全的脚本可以在 [`contrib/autocompletion/zsh_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/zsh_autocomplete) 找到。您可以将其复制到 `/usr/share/zsh/_gitea`,或在您的 `.zshrc` 中引用。 - -具体情况可能会有所不同,这些脚本可能需要进一步的改进。 - -## 运行 Gitea - -完成以上步骤后,可以通过两种方式运行 Gitea: - -### 1. 创建服务自动启动 Gitea(推荐) - -学习创建 [Linux 服务](installation/run-as-service-in-ubuntu.md) - -### 2. 通过命令行终端运行 - -```sh -GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini -``` - -## 升级到最新版本 - -您可以通过停止程序,替换 `/usr/local/bin/gitea` 并重启来更新到新版本。直接替换可执行程序时不要更改或使用新的文件名称,以避免数据出错。 - -建议您在更新之前进行[备份](administration/backup-and-restore.md)。 - -如果您按照上述描述执行了安装步骤,二进制文件的通用名称应为 gitea。请勿更改此名称,即不要包含版本号。 - -### 1. 使用 systemd 重新启动 Gitea(推荐) - -我们建议使用 systemd 作为服务管理器,使用 `systemctl restart gitea` 安全地重启程序。 - -### 2. 非 systemd 重启方法 - -使用 SIGHUP 信号关闭程序:查询到 Gitea 程序的 PID,使用 `kill -1 $GITEA_PID`,或者 `killall -1 gitea`。 - -更优雅的停止指令可能包括 `kill $GITEA_PID` 或者 `killall gitea`。 - -**提示:** 我们不建议使用 SIGKILL 信号(`-9`),这会强制停止 Gitea 程序,但不会正确关闭队列、索引器等任务。 - -请参阅下面的疑难解答说明,以在Gitea版本更新后修复损坏的仓库。 - -## 排查故障 - -### 旧版 glibc - -旧版 Linux 发行版(例如 Debian 7 和 CentOS 6)可能无法加载 Gitea 二进制文件,通常会产生类似于 `./gitea: /lib/x86_64-linux-gnu/libc.so.6: -version 'GLIBC\_2.14' not found (required by ./gitea)` 的错误。这是由于 dl.gitea.com 提供的二进制文件中集成了 SQLite 支持。在这种情况下,通常可以选择[从源代码安装](installation/from-source.md),而不包括 SQLite 支持。 - -### 在另一个端口上运行 Gitea - -对于出现类似于 `702 runWeb()] [E] Failed to start server: listen tcp 0.0.0.0:3000: -bind: address already in use` 的错误,需要将 Gitea 启动在另一个空闲端口上。您可以使用 `./gitea web -p $PORT` 来实现。可能已经有另一个 Gitea 实例在运行。 - -### 在 Raspbian 上运行 Gitea - -从 v1.8 版本开始,arm7 版本的 Gitea 存在问题,无法在树莓派和类似设备上运行。 - -建议切换到 arm6 版本,该版本经过测试并已被证明可以在树莓派和类似设备上运行。 - -### 更新到新版本的 Gitea 后出现的 Git 错误 - -如果在更新过程中,二进制文件的名称已更改为新版本的 Gitea,则现有仓库中的 Git 钩子将不再起作用。在这种情况下,当推送到仓库时,会显示 Git 错误。 - -``` -remote: ./hooks/pre-receive.d/gitea: line 2: [...]: No such file or directory -``` - -错误信息中的 `[...]` 部分将包含您先前 Gitea 二进制文件的路径。 - -要解决此问题,请转到管理选项,并运行任务 `Resynchronize pre-receive, update and post-receive hooks of all repositories`,以将所有钩子更新为包含新的二进制文件路径。请注意,这将覆盖所有 Git 钩子,包括自定义的钩子。 - -如果您没有使用 Gitea 内置的 SSH 服务器,您还需要通过在管理选项中运行任务 `Update the '.ssh/authorized_keys' file with Gitea SSH keys.` 来重新编写授权密钥文件。 - -> 更多经验总结,请参考英文版 [Troubleshooting](https://docs.gitea.com/installation/install-from-binary#troubleshooting) - -如果从本页中没有找到你需要的内容,请访问 [帮助页面](help/support.md) diff --git a/docs/content/installation/from-package.en-us.md b/docs/content/installation/from-package.en-us.md deleted file mode 100644 index aceb2029d2..0000000000 --- a/docs/content/installation/from-package.en-us.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Installation from package" -slug: "install-from-package" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /en-us/install-from-package -menu: - sidebar: - parent: "installation" - name: "From package" - sidebar_position: 20 - identifier: "install-from-package" ---- - -# Installation from Package - -## Official packages - -### macOS - -Currently, the only supported method of installation on MacOS is [Homebrew](http://brew.sh/). -Following the [deployment from binary](installation/from-binary.md) guide may work, -but is not supported. To install Gitea via `brew`: - -``` -brew install gitea -``` - -## Unofficial packages - -### Alpine Linux - -Alpine Linux has [Gitea](https://pkgs.alpinelinux.org/packages?name=gitea&branch=edge) in its community repository which follows the latest stable version. - -```sh -apk add gitea -``` - -### Arch Linux - -The rolling release distribution has [Gitea](https://www.archlinux.org/packages/extra/x86_64/gitea/) in their official extra repository and package updates are provided with new Gitea releases. - -```sh -pacman -S gitea -``` - -### Arch Linux ARM - -Arch Linux ARM provides packages for [aarch64](https://archlinuxarm.org/packages/aarch64/gitea), [armv7h](https://archlinuxarm.org/packages/armv7h/gitea) and [armv6h](https://archlinuxarm.org/packages/armv6h/gitea). - -```sh -pacman -S gitea -``` - -### Gentoo Linux - -The rolling release distribution has [Gitea](https://packages.gentoo.org/packages/www-apps/gitea) in their official community repository and package updates are provided with new Gitea releases. - -```sh -emerge gitea -va -``` - -### Canonical Snap - -There is a [Gitea Snap](https://snapcraft.io/gitea) package which follows the latest stable version. -*Note: The Gitea snap package is [strictly confined](https://snapcraft.io/docs/snap-confinement). Strictly confined snaps run in complete isolation, so some of the Gitea functionals may not work with the confinement* - -```sh -snap install gitea -``` - -### SUSE and openSUSE - -OpenSUSE build service provides packages for [openSUSE and SLE](https://software.opensuse.org/download/package?package=gitea&project=devel%3Atools%3Ascm) -in the Development Software Configuration Management Repository - -### Windows - -There is a [Gitea](https://chocolatey.org/packages/gitea) package for Windows by [Chocolatey](https://chocolatey.org/). - -```sh -choco install gitea -``` - -Or follow the [deployment from binary](installation/from-binary.md) guide. - -### FreeBSD - -A FreeBSD port `www/gitea` is available. To install the pre-built binary package: - -``` -pkg install gitea -``` - -For the most up to date version, or to build the port with custom options, -[install it from the port](https://www.freebsd.org/doc/handbook/ports-using.html): - -``` -su - -cd /usr/ports/www/gitea -make install clean -``` - -The port uses the standard FreeBSD file system layout: config files are in `/usr/local/etc/gitea`, -bundled templates, options, plugins and themes are in `/usr/local/share/gitea`, and a start script -is in `/usr/local/etc/rc.d/gitea`. - -To enable Gitea to run as a service, run `sysrc gitea_enable=YES` and start it with `service gitea start`. - -### Others - -Various other third-party packages of Gitea exist. -To see a curated list, head over to [awesome-gitea](https://gitea.com/gitea/awesome-gitea/src/branch/master/README.md#user-content-packages). - -Do you know of an existing package that isn't on the list? Send in a PR to get it added! diff --git a/docs/content/installation/from-package.zh-cn.md b/docs/content/installation/from-package.zh-cn.md deleted file mode 100644 index 929782f23c..0000000000 --- a/docs/content/installation/from-package.zh-cn.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "使用包管理器安装" -slug: "install-from-package" -sidebar_position: 20 -toc: false -draft: false -aliases: - - /zh-cn/install-from-package -menu: - sidebar: - parent: "installation" - name: "使用包管理器安装" - sidebar_position: 20 - identifier: "install-from-package" ---- - -# 官方包管理器 - -## macOS - -macOS 平台下当前我们仅支持通过 `brew` 来安装。如果你没有安装 [Homebrew](http://brew.sh/),你也可以查看 [从二进制安装](installation/from-binary.md)。在你安装了 `brew` 之后, 你可以执行以下命令: - -``` -brew install gitea -``` - -# 非官方包管理器 - -## Alpine Linux - -Gitea 已经包含在 Alpine Linux 的[社区存储库](https://pkgs.alpinelinux.org/packages?name=gitea&branch=edge)中,版本与 Gitea 官方保持同步。 - -```sh -apk add gitea -``` - -## Arch Linux - -Gitea 已经在滚动发布发行版的官方[社区存储库](https://www.archlinux.org/packages/community/x86_64/gitea/)中,版本与 Gitea 官方保持同步。 - -```sh -pacman -S gitea -``` - -## Arch Linux ARM - -官方支持 [aarch64](https://archlinuxarm.org/packages/aarch64/gitea), [armv7h](https://archlinuxarm.org/packages/armv7h/gitea) 和 [armv6h](https://archlinuxarm.org/packages/armv6h/gitea) 架构。 - -```sh -pacman -S gitea -``` - -## Gentoo Linux - -滚动发布的发行版在其官方社区软件仓库中提供了 [Gitea](https://packages.gentoo.org/packages/www-apps/gitea),并且会随着新的 Gitea 发布提供软件包更新。 - -```sh -emerge gitea -va -``` - -## Canonical Snap - -目前 Gitea 已在 Snap Store 中发布,名称为 [gitea](https://snapcraft.io/gitea)。 - -```sh -snap install gitea -``` - -## SUSE/openSUSE - -OpenSUSE 构建服务为 [openSUSE 和 SLE](https://software.opensuse.org/download/package?package=gitea&project=devel%3Atools%3Ascm) -提供包,你可以在开发软件配置管理存储库中找到它们。 - -## Windows - -目前你可以通过 [Chocolatey](https://chocolatey.org/) 来安装 [Gitea](https://chocolatey.org/packages/gitea)。 - -```sh -choco install gitea -``` - -你也可以 [从二进制安装](installation/from-binary.md) 。 - -## FreeBSD - -可以使用 Gitea 的 FreeBSD port `www/gitea`。 请安装预构建的二进制包: - -``` -pkg install gitea -``` - -对于最新版本,或使用自定义选项构建 port,请 -[从 port 安装](https://www.freebsd.org/doc/handbook/ports-using.html): - -``` -su - -cd /usr/ports/www/gitea -make install clean -``` - -该 port 使用标准的 FreeBSD 文件系统布局:配置文件在 `/usr/local/etc/gitea` 目录中, -模板、选项、插件和主题在 `/usr/local/share/gitea` 目录中,启动脚本在 `/usr/local/etc/rc.d/gitea` 目录中。 - -要使 Gitea 作为服务运行,请运行 `sysrc gitea_enable=YES` 并使用 `service gitea start` 命令启动它。 - -## 第三方 - -如果这里没有找到你喜欢的包管理器,可以使用 Gitea 第三方软件包。这里有一个完整的列表: [awesome-gitea](https://gitea.com/gitea/awesome-gitea/src/branch/master/README.md#user-content-packages)。 - -如果你知道其他 Gitea 第三方软件包,请发送 PR 来添加它。 diff --git a/docs/content/installation/from-source.en-us.md b/docs/content/installation/from-source.en-us.md deleted file mode 100644 index cd9fd56511..0000000000 --- a/docs/content/installation/from-source.en-us.md +++ /dev/null @@ -1,262 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Installation from source" -slug: "install-from-source" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /en-us/install-from-source -menu: - sidebar: - parent: "installation" - name: "From source" - sidebar_position: 30 - identifier: "install-from-source" ---- - -# Installation from source - -You should [install go](https://go.dev/doc/install) and set up your go -environment correctly. In particular, it is recommended to set the `$GOPATH` -environment variable and to add the go bin directory or directories -`${GOPATH//://bin:}/bin` to the `$PATH`. See the Go wiki entry for -[GOPATH](https://github.com/golang/go/wiki/GOPATH). - -Next, [install Node.js with npm](https://nodejs.org/en/download/) which is -required to build the JavaScript and CSS files. The minimum supported Node.js -version is @minNodeVersion@ and the latest LTS version is recommended. - -**Note**: Go version @minGoVersion@ or higher is required. However, it is recommended to -obtain the same version as our continuous integration, see the advice given in -[Hacking on Gitea](development/hacking-on-gitea.md) - -## Download - -First, we must retrieve the source code. Since, the advent of go modules, the -simplest way of doing this is to use Git directly as we no longer have to have -Gitea built from within the GOPATH. - -```bash -git clone https://github.com/go-gitea/gitea -``` - -(Previous versions of this document recommended using `go get`. This is -no longer necessary.) - -Decide which version of Gitea to build and install. Currently, there are -multiple options to choose from. The `main` branch represents the current -development version. To build with main, skip to the [build section](#build). - -To work with tagged releases, the following commands can be used: - -```bash -git branch -a -git checkout v@version@ -``` - -To validate a Pull Request, first enable the new branch (`xyz` is the PR id; -for example `2663` for [#2663](https://github.com/go-gitea/gitea/pull/2663)): - -```bash -git fetch origin pull/xyz/head:pr-xyz -``` - -To build Gitea from source at a specific tagged release (like v@version@), list the -available tags and check out the specific tag. - -List available tags with the following. - -```bash -git tag -l -git checkout v@version@ # or git checkout pr-xyz -``` - -## Build - -To build from source, the following programs must be present on the system: - -- `go` @minGoVersion@ or higher, see [here](https://go.dev/dl/) -- `node` @minNodeVersion@ or higher with `npm`, see [here](https://nodejs.org/en/download/) -- `make`, see [here](development/hacking-on-gitea.md#installing-make) - -Various [make tasks](https://github.com/go-gitea/gitea/blob/main/Makefile) -are provided to keep the build process as simple as possible. - -Depending on requirements, the following build tags can be included. - -- `bindata`: Build a single monolithic binary, with all assets included. Required for production build. -- `sqlite sqlite_unlock_notify`: Enable support for a - [SQLite3](https://sqlite.org/) database. Suggested only for tiny - installations. -- `pam`: Enable support for PAM (Linux Pluggable Authentication Modules). Can - be used to authenticate local users or extend authentication to methods - available to PAM. -- `gogit`: (EXPERIMENTAL) Use go-git variants of Git commands. - -Bundling all assets (JS/CSS/templates, etc) into the binary. Using the `bindata` build tag is required for -production deployments. You could exclude `bindata` when you are developing/testing Gitea or able to separate the assets correctly. - -To include all assets, use the `bindata` tag: - -```bash -TAGS="bindata" make build -``` - -In the default release build of our continuous integration system, the build -tags are: `TAGS="bindata sqlite sqlite_unlock_notify"`. The simplest -recommended way to build from source is therefore: - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -The `build` target is split into two sub-targets: - -- `make backend` which requires [Go @minGoVersion@](https://go.dev/dl/) or greater. -- `make frontend` which requires [Node.js @minNodeVersion@](https://nodejs.org/en/download/) or greater. - -If pre-built frontend files are present it is possible to only build the backend: - -```bash -TAGS="bindata" make backend -``` - -## Test - -After following the steps above, a `gitea` binary will be available in the working directory. -It can be tested from this directory or moved to a directory with test data. When Gitea is -launched manually from command line, it can be killed by pressing `Ctrl + C`. - -```bash -./gitea web -``` - -## Changing default paths - -Gitea will search for a number of things from the _`CustomPath`_. By default this is -the `custom/` directory in the current working directory when running Gitea. It will also -look for its configuration file _`CustomConf`_ in `$(CustomPath)/conf/app.ini`, and will use the -current working directory as the relative base path _`AppWorkPath`_ for a number configurable -values. Finally the static files will be served from _`StaticRootPath`_ which defaults to the _`AppWorkPath`_. - -These values, although useful when developing, may conflict with downstream users preferences. - -One option is to use a script file to shadow the `gitea` binary and create an appropriate -environment before running Gitea. However, when building you can change these defaults -using the `LDFLAGS` environment variable for `make`. The appropriate settings are as follows - -- To set the _`CustomPath`_ use `LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""` -- For _`CustomConf`_ you should use `-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"` -- For _`AppWorkPath`_ you should use `-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=working-path\"` -- For _`StaticRootPath`_ you should use `-X \"code.gitea.io/gitea/modules/setting.StaticRootPath=static-root-path\"` -- To change the default PID file location use `-X \"code.gitea.io/gitea/cmd.PIDFile=/run/gitea.pid\"` - -Add as many of the strings with their preceding `-X` to the `LDFLAGS` variable and run `make build` -with the appropriate `TAGS` as above. - -Running `gitea help` will allow you to review what the computed settings will be for your `gitea`. - -## Cross Build - -The `go` compiler toolchain supports cross-compiling to different architecture targets that are supported by the toolchain. See [`GOOS` and `GOARCH` environment variable](https://go.dev/doc/install/source#environment) for the list of supported targets. Cross compilation is helpful if you want to build Gitea for less-powerful systems (such as Raspberry Pi). - -To cross build Gitea with build tags (`TAGS`), you also need a C cross compiler which targets the same architecture as selected by the `GOOS` and `GOARCH` variables. For example, to cross build for Linux ARM64 (`GOOS=linux` and `GOARCH=arm64`), you need the `aarch64-unknown-linux-gnu-gcc` cross compiler. This is required because Gitea build tags uses `cgo`'s foreign-function interface (FFI). - -Cross-build Gitea for Linux ARM64, without any tags: - -``` -GOOS=linux GOARCH=arm64 make build -``` - -Cross-build Gitea for Linux ARM64, with recommended build tags: - -``` -CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -Replace `CC`, `GOOS`, and `GOARCH` as appropriate for your architecture target. - -You will sometimes need to build a static compiled image. To do this you will need to add: - -``` -LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="netgo osusergo $TAGS" make build -``` - -This can be combined with `CC`, `GOOS`, and `GOARCH` as above. - -### Adding bash/zsh autocompletion (from 1.19) - -A script to enable bash-completion can be found at [`contrib/autocompletion/bash_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete). This should be altered as appropriate and can be `source` in your `.bashrc` -or copied as `/usr/share/bash-completion/completions/gitea`. - -Similarly, a script for zsh-completion can be found at [`contrib/autocompletion/zsh_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/zsh_autocomplete). This can be copied to `/usr/share/zsh/_gitea` or sourced within your -`.zshrc`. - -YMMV and these scripts may need further improvement. - -## Compile or cross-compile using Linux with Zig - -Follow [Getting Started of Zig](https://ziglang.org/learn/getting-started/#installing-zig) to install zig. - -- Compile (Linux ➝ Linux) - -```sh -CC="zig cc -target x86_64-linux-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -CGO_LDFLAGS="-linkmode=external -v" -GOOS=linux \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -- Cross-compile (Linux ➝ Windows) - -```sh -CC="zig cc -target x86_64-windows-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -GOOS=windows \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -## Compile or cross-compile with Zig using Windows - -Compile with `GIT BASH`. - -- Compile (Windows ➝ Windows) - -```sh -CC="zig cc -target x86_64-windows-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -GOOS=windows \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -- Cross-compile (Windows ➝ Linux) - -```sh -CC="zig cc -target x86_64-linux-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -CGO_LDFLAGS="-linkmode=external -v" -GOOS=linux \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -## Source Maps - -By default, gitea generates reduced source maps for frontend files to conserve space. This can be controlled with the `ENABLE_SOURCEMAP` environment variable: - -- `ENABLE_SOURCEMAP=true` generates all source maps, the default for development builds -- `ENABLE_SOURCEMAP=reduced` generates limited source maps, the default for production builds -- `ENABLE_SOURCEMAP=false` generates no source maps diff --git a/docs/content/installation/from-source.zh-cn.md b/docs/content/installation/from-source.zh-cn.md deleted file mode 100644 index 3ff7efb4ed..0000000000 --- a/docs/content/installation/from-source.zh-cn.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "使用源代码安装" -slug: "install-from-source" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /zh-cn/install-from-source -menu: - sidebar: - parent: "installation" - name: "使用源代码安装" - sidebar_position: 30 - identifier: "install-from-source" ---- - -# 使用源代码安装 - -你需要 [安装Go](https://golang.google.cn/doc/install) 并正确设置Go环境。特别的,建议设置`$GOPATH`环境变量,并将 Go 的二进制目录或目录`${GOPATH//://bin:}/bin`添加到`$PATH`中。请参阅 Go 百科上关于 [GOPATH](https://github.com/golang/go/wiki/GOPATH) 的词条。 - -接下来,[安装 Node.js 和 npm](https://nodejs.org/zh-cn/download/), 这是构建 JavaScript 和 CSS 文件所需的。最低支持的 Node.js 版本是 @minNodeVersion@,建议使用最新的 LTS 版本。 - -**注意**:需要 Go 版本 @minGoVersion@ 或更高版本。不过,建议获取与我们的持续集成(continuous integration, CI)相同的版本,请参阅在 [Hacking on Gitea](development/hacking-on-gitea.md) 中给出的建议。 - -## 下载 - -首先,我们需要获取源码。由于引入了 Go 模块,最简单的方法是直接使用 Git,因为我们不再需要在 GOPATH 内构建 Gitea。 - -```bash -git clone https://github.com/go-gitea/gitea -``` - -(之前的版本中建议使用 `go get`,但现在不再需要。) - -你可以选择编译和安装的版本,当前有多个选择。`main` 分支代表当前的开发版本。如果你想编译 `main` 版本,你可以直接跳到 [构建](#构建) 部分。 - -如果你想编译带有标签的发行版本,可以使用以下命令签出: - -```bash -git branch -a -git checkout v@version@ -``` - -要验证一个拉取请求(Pull Request, PR),要先启用新的分支(其中 `xyz` 是 PR 的 ID;例如,对于 [#2663](https://github.com/go-gitea/gitea/pull/2663),ID是 `2663 `): - -```bash -git fetch origin pull/xyz/head:pr-xyz -``` - -要以指定发行版本(如 v@version@ )的源代码来构建 Gitea,可执行以下命令列出可用的版本并选择某个版本签出。 -使用以下命令列出可用的版本: - -```bash -git tag -l -git checkout v@version@ # or git checkout pr-xyz -``` - -## 构建 - -要从源代码进行构建,系统必须预先安装以下程序: - -- `go` @minGoVersion@ 或更高版本,请参阅 [这里](https://go.dev/dl/) -- `node` @minNodeVersion@ 或更高版本,并且安装 `npm`, 请参阅 [这里](https://nodejs.org/zh-cn/download/) -- `make`, 请参阅 [这里](development/hacking-on-gitea.md) - -为了尽可能简化编译过程,提供了各种 [make任务](https://github.com/go-gitea/gitea/blob/main/Makefile)。 - -根据你的构建需求,以下 tags 可以使用: - -- `bindata`: 构建一个单一的整体二进制文件,包含所有资源。适用于构建生产环境版本。 -- `sqlite sqlite_unlock_notify`: 启用对 [SQLite3](https://sqlite.org/) 数据库的支持。仅建议在少数人使用时使用这个模式。 -- `pam`: 启用对 PAM( Linux 可插拔认证模块)的支持。可用于对本地用户进行身份验证或扩展身份验证到 PAM 可用的方法。 -- `gogit`:(实验性功能)使用 go-git 变体的 Git 命令。 - -将所有资源(JS/CSS/模板等)打包到二进制文件中。在生产环境部署时,使用`bindata`构建标签是必需的。在开发/测试 Gitea 或能够明确分离资源时,可以不用`bindata`。 - -要包含所有资源,请使用 `bindata` 标签: - -```bash -TAGS="bindata" make build -``` - -在我们的持续集成系统的默认发行版中,构建标签为:`TAGS="bindata sqlite sqlite_unlock_notify"`。因此,从源码构建的最简单、推荐方式是: - -```bash -TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -`build`目标分为两个子目标: - -- `make backend` 需要 [Go @minGoVersion@](https://golang.google.cn/doc/install) 或更高版本。 -- `make frontend` 需要 [Node.js @minNodeVersion@](https://nodejs.org/zh-cn/download/) 或更高版本。 - -如果存在预构建的前端文件,可以仅构建后端: - -```bash -TAGS="bindata" make backend -``` - -## 测试 - -按照上述步骤完成后,工作目录中将会有一个`gitea`二进制文件。可以从该目录进行测试,或将其移动到带有测试数据的目录中。当手动从命令行启动 Gitea 时,可以通过按下`Ctrl + C`来停止程序。 - -```bash -./gitea web -``` - -## 更改默认路径 - -Gitea 将从`CustomPath`中查找许多信息。默认的,这会在运行 Gitea 时当前工作目录下的`custom/`目录中(译者案:即`$PATH_TO_YOUR_GITEA$/custom/`)。它还将在`$(CustomPath)/conf/app.ini`中查找其配置文件`CustomConf`,并将当前工作目录用作一些可配置值的相对基本路径`AppWorkPath`。最后,静态文件将从默认为 `AppWorkPath`的`StaticRootPath`提供。 - -尽管在开发时这些值很有用,但可能与下游用户的偏好冲突。 - -一种选择是使用脚本文件来隐藏`gitea`二进制文件,并在运行Gitea之前创建适当的环境。然而,在构建时,可以使用`make`的`LDFLAGS`环境变量来更改这些默认值。适当的设置如下: - -- 要设置`CustomPath`,请使用`LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""` -- 对于`CustomConf`,应该使用`-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"` -- 对于`AppWorkPath`,应该使用`-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=working-path\"` -- 对于`StaticRootPath`,应该使用`-X \"code.gitea.io/gitea/modules/setting.StaticRootPath=static-root-path\"` -- 要更改默认的 PID 文件位置,请使用`-X \"code.gitea.io/gitea/cmd.PIDFile=/run/gitea.pid\"` - -将这些字符串与其前导的`-X`添加到`LDFLAGS`变量中,并像上面那样使用适当的`TAGS`运行`make build`。 - -运行`gitea help`将允许您查看配置的`gitea`设置。 - -## 交叉编译 - -`go`编译器工具链支持将代码交叉编译到不同的目标架构上。请参考[`GOOS`和`GOARCH`环境变量](https://go.dev/doc/install/source#environment) 以获取支持的目标列表。如果您想为性能较弱的系统(如树莓派)构建 Gitea,交叉编译非常有用。 - -要使用构建标签(`TAGS`)进行交叉编译Gitea,您还需要一个 C 交叉编译器,该编译器的目标架构与`GOOS`和`GOARCH`变量选择的架构相同。例如,要为 Linux ARM64(`GOOS=linux`和`GOARCH=arm64`)进行交叉编译,您需要`aarch64-unknown-linux-gnu-gcc`交叉编译器。这是因为 Gitea 构建标签使用了`cgo`的外部函数接口(FFI)。 - -在没有任何标签的情况下,交叉编译的 Gitea 为 Linux ARM64 版本: - -``` -GOOS=linux GOARCH=arm64 make build -``` - -要交叉编译 Linux ARM64 下的Gitea,这是推荐的构建标签: - -``` -CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sqlite_unlock_notify" make build -``` - -根据您的目标架构,适当替换`CC`、`GOOS`和`GOARCH`。 - -有时您需要构建一个静态编译的镜像。为此,您需要添加以下内容: - -``` -LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="netgo osusergo $TAGS" make build -``` - -这可以与上述的`CC`、`GOOS`和`GOARCH`结合使用。 - -### 添加 bash/zsh 自动补全(从 1.19 版本起) - -在[`contrib/autocompletion/bash_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete)中可以找到一个启用 bash 自动补全的脚本。您可以根据需要进行修改,并在您的 `.bashrc` 中使用 `source` 命令加载该脚本,或者将其复制到 `/usr/share/bash-completion/completions/gitea`。 - -类似地,可以在[`contrib/autocompletion/zsh_autocomplete`](https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/zsh_autocomplete)中找到一个用于 zsh 自动补全的脚本。您可以将其复制到 `/usr/share/zsh/_gitea`,或者在您的 `.zshrc` 中使用 `source` 命令加载该脚本。 - -可能需要你根据具体情况进一步改进这些脚本。 - -## 在 Linux 上使用 Zig 进行编译或交叉编译 - -请按照 [Zig 的入门指南](https://ziglang.org/learn/getting-started/#installing-zig) 安装 Zig。 - -- 编译 (Linux ➝ Linux) - -```sh -CC="zig cc -target x86_64-linux-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -CGO_LDFLAGS="-linkmode=external -v" -GOOS=linux \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -- 交叉编译 (Linux ➝ Windows) - -```sh -CC="zig cc -target x86_64-windows-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -GOOS=windows \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -## 在 Windows 上使用 Zig 进行编译或交叉编译 - -使用`GIT BASH`编译。 - -- 编译 (Windows ➝ Windows) - -```sh -CC="zig cc -target x86_64-windows-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -GOOS=windows \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -- 交叉编译 (Windows ➝ Linux) - -```sh -CC="zig cc -target x86_64-linux-gnu" \ -CGO_ENABLED=1 \ -CGO_CFLAGS="-O2 -g -pthread" \ -CGO_LDFLAGS="-linkmode=external -v" -GOOS=linux \ -GOARCH=amd64 \ -TAGS="bindata sqlite sqlite_unlock_notify" \ -make build -``` - -## Source Map - -默认情况下,gitea 会为前端文件生成精简的 Source Map 以节省空间。 这可以通过“ENABLE_SOURCEMAP”环境变量进行控制: - -- `ENABLE_SOURCEMAP=true` 生成所有Source Map,这是开发版本的默认设置 -- `ENABLE_SOURCEMAP=reduced` 生成有限的Source Map,这是生产版本的默认设置 -- `ENABLE_SOURCEMAP=false` 不生成Source Map diff --git a/docs/content/installation/on-cloud-provider.en-us.md b/docs/content/installation/on-cloud-provider.en-us.md deleted file mode 100644 index d5baece8ca..0000000000 --- a/docs/content/installation/on-cloud-provider.en-us.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Install on Cloud Provider" -slug: "install-on-cloud-provider" -sidebar_position: 90 -toc: false -draft: false -aliases: - - /en-us/install-on-cloud-provider -menu: - sidebar: - parent: "installation" - name: "On cloud provider" - sidebar_position: 90 - identifier: "install-on-cloud-provider" ---- - -# Installation on Cloud Provider - -## Cloudron - -Gitea is available as a 1-click install on [Cloudron](https://cloudron.io). -Cloudron makes it easy to run apps like Gitea on your server and keep them up-to-date and secure. - -[![Install](/cloudron.svg)](https://cloudron.io/button.html?app=io.gitea.cloudronapp) - -The Gitea package is maintained [here](https://git.cloudron.io/cloudron/gitea-app). - -There is a [demo instance](https://my.demo.cloudron.io) (username: cloudron password: cloudron) where -you can experiment with running Gitea. - -## Vultr - -Gitea can be found in [Vultr](https://www.vultr.com)'s marketplace. - -To deploy Gitea to Vultr, have a look at the [Vultr Marketplace](https://www.vultr.com/marketplace/apps/gitea). - -## DigitalOcean - -[DigitalOcean](https://www.digitalocean.com) has Gitea as droplet in their marketplace. - -To deploy Gitea to DigitalOcean, have a look at the [DigitalOcean Marketplace](https://marketplace.digitalocean.com/apps/gitea). - -## Linode - -[Linode](https://www.linode.com/) has Gitea as an app in their marketplace. - -To deploy Gitea to Linode, have a look at the [Linode Marketplace](https://www.linode.com/marketplace/apps/linode/gitea/). - -## alwaysdata - -[alwaysdata](https://www.alwaysdata.com/) has Gitea as an app in their marketplace. - -To deploy Gitea to alwaysdata, have a look at the [alwaysdata Marketplace](https://www.alwaysdata.com/en/marketplace/gitea/). - -## Exoscale - -[Exoscale](https://www.exoscale.com/) provides Gitea managed by [Glasskube](https://glasskube.eu/) in their marketplace. - -Exoscale is a European cloud service provider. - -The package is maintained and update via the open source [Glasskube Kubernetes Operator](https://github.com/glasskube/operator). - -To deploy Gitea to Exoscale, have a look at the [Exoscale Marketplace](https://www.exoscale.com/marketplace/listing/glasskube-gitea/). diff --git a/docs/content/installation/on-cloud-provider.zh-cn.md b/docs/content/installation/on-cloud-provider.zh-cn.md deleted file mode 100644 index 7b9a7bdf40..0000000000 --- a/docs/content/installation/on-cloud-provider.zh-cn.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "在云服务器中安装 Gitea" -slug: "install-on-cloud-provider" -sidebar_position: 90 -toc: false -draft: false -aliases: - - /zh-cn/install-on-cloud-provider -menu: - sidebar: - parent: "installation" - name: "在云服务器中安装 Gitea" - sidebar_position: 90 - identifier: "install-on-cloud-provider" ---- - -# 在云服务器上安装 Gitea - -## Cloudron - -Gitea 可以在 [Cloudron](https://cloudron.io) 上进行一键安装。 -Cloudron 使得在您的服务器上运行 Gitea,并保持其更新和安全变得简单。 - -[![Install](/cloudron.svg)](https://cloudron.io/button.html?app=io.gitea.cloudronapp) - -Gitea软件包的维护地址在[这里](https://git.cloudron.io/cloudron/gitea-app). - -这里有一个[demo 实例](https://my.demo.cloudron.io) (用户名: cloudron 密码: cloudron) 您可以在其中尝试运行Gitea。 - -## Vultr - -Gitea 可以在 [Vultr](https://www.vultr.com) 的市场中被找到。 - -要将 Gitea 部署到 Vultr,请参考 [Vultr Marketplace](https://www.vultr.com/marketplace/apps/gitea). - -## DigitalOcean - -[DigitalOcean](https://www.digitalocean.com) 将 Gitea 作为其市场中的一个 droplet。 - -要将 Gitea 部署到 DigitalOcean, 请参考 [DigitalOcean Marketplace](https://marketplace.digitalocean.com/apps/gitea). - -## Linode - -[Linode](https://www.linode.com/) 将 Gitea 作为其市场中的一个应用程序. - -要将 Gitea 部署到 Linode, 请参考 [Linode Marketplace](https://www.linode.com/marketplace/apps/linode/gitea/). - -## alwaysdata - -[alwaysdata](https://www.alwaysdata.com/) 将 Gitea 作为其市场中的一个 droplet. - -要将 Gitea 部署到 alwaysdata, 请参考 [alwaysdata Marketplace](https://www.alwaysdata.com/en/marketplace/gitea/). - -## Exoscale - -[Exoscale](https://www.exoscale.com/) 在其市场中提供由 [Glasskube](https://glasskube.eu/) 管理的 Gitea。 - -Exoscale 是一家欧洲的云服务提供商。 - -该软件包通过开源的 [Glasskube Kubernetes Operator](https://github.com/glasskube/operator) 进行维护和更新。 - -要在 Exoscale 上部署 Gitea,请参考 [Exoscale Marketplace](https://www.exoscale.com/marketplace/listing/glasskube-gitea/)。 diff --git a/docs/content/installation/on-kubernetes.en-us.md b/docs/content/installation/on-kubernetes.en-us.md deleted file mode 100644 index 00f2aab28d..0000000000 --- a/docs/content/installation/on-kubernetes.en-us.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -date: "2020-03-19T19:27:00+02:00" -title: "Install on Kubernetes" -slug: "install-on-kubernetes" -sidebar_position: 80 -toc: false -draft: false -aliases: - - /en-us/install-on-kubernetes -menu: - sidebar: - parent: "installation" - name: "Kubernetes" - sidebar_position: 80 - identifier: "install-on-kubernetes" ---- - -# Installation with Helm (on Kubernetes) - -Gitea provides a Helm Chart to allow for installation on kubernetes. - -A non-customized install can be done with: - -``` -helm repo add gitea-charts https://dl.gitea.com/charts/ -helm install gitea gitea-charts/gitea -``` - -If you would like to customize your install, which includes kubernetes ingress, please refer to the complete [Gitea helm chart configuration details](https://gitea.com/gitea/helm-chart/) - -## Health check endpoint - -Gitea comes with a health check endpoint `/api/healthz`, you can configure it in kubernetes like this: - -```yaml - livenessProbe: - httpGet: - path: /api/healthz - port: http - initialDelaySeconds: 200 - timeoutSeconds: 5 - periodSeconds: 10 - successThreshold: 1 - failureThreshold: 10 -``` - -a successful health check response will respond with http code `200`, here's example: - -``` -HTTP/1.1 200 OK - -{ - "status": "pass", - "description": "Gitea: Git with a cup of tea", - "checks": { - "cache:ping": [ - { - "status": "pass", - "time": "2022-02-19T09:16:08Z" - } - ], - "database:ping": [ - { - "status": "pass", - "time": "2022-02-19T09:16:08Z" - } - ] - } -} -``` - -for more information, please reference to kubernetes documentation [Define a liveness HTTP request](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request) diff --git a/docs/content/installation/on-kubernetes.zh-cn.md b/docs/content/installation/on-kubernetes.zh-cn.md deleted file mode 100644 index 1af55d874b..0000000000 --- a/docs/content/installation/on-kubernetes.zh-cn.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -date: "2020-03-19T19:27:00+02:00" -title: "在 Kubernetes 中安装 Gitea" -slug: "install-on-kubernetes" -sidebar_position: 80 -toc: false -draft: false -aliases: - - /zh-cn/install-on-kubernetes -menu: - sidebar: - parent: "installation" - name: "在 Kubernetes 中安装 Gitea" - sidebar_position: 80 - identifier: "install-on-kubernetes" ---- - -# 使用 Helm 在 Kubernetes 云原生环境中安装 Gitea - -Gitea 已经提供了便于在 Kubernetes 云原生环境中安装所需的 Helm Chart - -默认安装指令为: - -```bash -helm repo add gitea https://dl.gitea.com/charts -helm repo update -helm install gitea gitea/gitea -``` - -如果采用默认安装指令,Helm 会部署单实例的 Gitea, PostgreSQL, Memcached。若您想实现自定义安装(包括配置 Gitea 集群、NGINX Ingress、MySQL、MariaDB、持久存储等),请前往阅读:[Gitea Helm Chart](https://gitea.com/gitea/helm-chart/) - -您也可以通过 `helm show` 命令导出 `README.md` 和配置文件 `values.yaml` 进行学习和编辑,例如: - -```bash -helm show values gitea/gitea > values.yaml -helm show readme gitea/gitea > README.md - -# 使用自定义的配置文件 values.yaml -helm install gitea -f values.yaml gitea/gitea -``` - -## 运行状况检查接口 - -Gitea 附带了一个运行状况检查接口 `/api/healthz`,你可以像这样在 Kubernetes 中配置它: - -```yaml - livenessProbe: - httpGet: - path: /api/healthz - port: http - initialDelaySeconds: 200 - timeoutSeconds: 5 - periodSeconds: 10 - successThreshold: 1 - failureThreshold: 10 -``` - -成功的运行状况检查响应代码为 HTTP `200`,下面是示例: - -``` -HTTP/1.1 200 OK - -{ - "status": "pass", - "description": "Gitea: Git with a cup of tea", - "checks": { - "cache:ping": [ - { - "status": "pass", - "time": "2022-02-19T09:16:08Z" - } - ], - "database:ping": [ - { - "status": "pass", - "time": "2022-02-19T09:16:08Z" - } - ] - } -} -``` - -有关更多信息,请参考 Kubernetes 文档 [配置存活、就绪和启动探测器](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) diff --git a/docs/content/installation/run-as-service-in-ubuntu.en-us.md b/docs/content/installation/run-as-service-in-ubuntu.en-us.md deleted file mode 100644 index 4e169d6bcc..0000000000 --- a/docs/content/installation/run-as-service-in-ubuntu.en-us.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -date: "2017-07-21T12:00:00+02:00" -title: "Run as a Linux service" -slug: "linux-service" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /en-us/linux-service -menu: - sidebar: - parent: "installation" - name: "Linux service" - sidebar_position: 40 - identifier: "linux-service" ---- - -# Run as a Linux service - -You can run Gitea as a Linux service, using either systemd or supervisor. The steps below tested on Ubuntu 16.04, but those should work on any Linux distributions (with little modification). - -## Using systemd - -Copy the sample [gitea.service](https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service) to `/etc/systemd/system/gitea.service`, then edit the file with your favorite editor. - -Uncomment any service that needs to be enabled on this host, such as MySQL. - -Change the user, home directory, and other required startup values. Change the -PORT or remove the -p flag if default port is used. - -Enable and start Gitea at boot: - -``` -sudo systemctl enable gitea -sudo systemctl start gitea -``` - -If you have systemd version 220 or later, you can enable and immediately start Gitea at once by: - -``` -sudo systemctl enable gitea --now -``` - -## Using supervisor - -Install supervisor by running below command in terminal: - -``` -sudo apt install supervisor -``` - -Create a log dir for the supervisor logs: - -``` -# assuming Gitea is installed in /home/git/gitea/ -mkdir /home/git/gitea/log/supervisor -``` - -Append the configuration from the sample -[supervisord config](https://github.com/go-gitea/gitea/blob/main/contrib/supervisor/gitea) to `/etc/supervisor/supervisord.conf`. - -Using your favorite editor, change the user (`git`) and home -(`/home/git`) settings to match the deployment environment. Change the PORT -or remove the -p flag if default port is used. - -Lastly enable and start supervisor at boot: - -``` -sudo systemctl enable supervisor -sudo systemctl start supervisor -``` - -If you have systemd version 220 or later, you can enable and immediately start supervisor by: - -``` -sudo systemctl enable supervisor --now -``` diff --git a/docs/content/installation/run-as-service-in-ubuntu.zh-cn.md b/docs/content/installation/run-as-service-in-ubuntu.zh-cn.md deleted file mode 100644 index 6ec127c312..0000000000 --- a/docs/content/installation/run-as-service-in-ubuntu.zh-cn.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -date: "2017-07-21T12:00:00+02:00" -title: "在 Linux 中以 service 方式运行" -slug: "linux-service" -sidebar_position: 40 -toc: false -draft: false -aliases: - - /zh-cn/linux-service -menu: - sidebar: - parent: "installation" - name: "在Linux中以service方式运行" - sidebar_position: 40 - identifier: "linux-service" ---- - -### 在 Ubuntu 16.04 LTS 中以 service 方式运行 - -#### systemd 方式 - -在 terminal 中执行以下命令: - -``` -sudo vim /etc/systemd/system/gitea.service -``` - -接着拷贝示例代码 [gitea.service](https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service) 并取消对任何需要运行在主机上的服务部分的注释,譬如 MySQL。 - -修改 user,home 目录以及其他必须的初始化参数,如果使用自定义端口,则需修改 PORT 参数,反之如果使用默认端口则需删除 -p 标记。 - -激活 gitea 并将它作为系统自启动服务: - -``` -sudo systemctl enable gitea -sudo systemctl start gitea -``` - -#### 使用 supervisor - -在 terminal 中执行以下命令安装 supervisor: - -``` -sudo apt install supervisor -``` - -为 supervisor 配置日志路径: - -``` -# assuming gitea is installed in /home/git/gitea/ -mkdir /home/git/gitea/log/supervisor -``` - -在文件编辑器中打开 supervisor 的配置文件: - -``` -sudo vim /etc/supervisor/supervisord.conf -``` - -增加如下示例配置 -[supervisord config](https://github.com/go-gitea/gitea/blob/main/contrib/supervisor/gitea)。 - -将 user(git) 和 home(/home/git) 设置为与上文部署中匹配的值。如果使用自定义端口,则需修改 PORT 参数,反之如果使用默认端口则需删除 -p 标记。 - -最后激活 supervisor 并将它作为系统自启动服务: - -``` -sudo systemctl enable supervisor -sudo systemctl start supervisor -``` diff --git a/docs/content/installation/upgrade-from-gitea.en-us.md b/docs/content/installation/upgrade-from-gitea.en-us.md deleted file mode 100644 index 4a5f21778a..0000000000 --- a/docs/content/installation/upgrade-from-gitea.en-us.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -date: "2021-09-02T16:00:00+08:00" -title: "Upgrade from an old Gitea" -slug: "upgrade-from-gitea" -sidebar_position: 100 -toc: false -draft: false -aliases: - - /en-us/upgrade-from-gitea -menu: - sidebar: - parent: "installation" - name: "Upgrade From Old Gitea" - sidebar_position: 100 - identifier: "upgrade-from-gitea" ---- - -# Upgrade from an old Gitea - -Follow below steps to ensure a smooth upgrade to a new Gitea version. - -## Check the Changelog for breaking changes - -To make Gitea better, some breaking changes are unavoidable, especially for big milestone releases. -Before upgrading, please read the [Changelog on Gitea blog](https://blog.gitea.com/) -and check whether the breaking changes affect your Gitea instance. - -## Verify there are no deprecated configuration options - -New versions of Gitea often come with changed configuration syntax or options which are usually displayed for -at least one release cycle inside at the top of the Site Administration panel. If these warnings are not -resolved, Gitea may refuse to start in the following version. - -## Backup for downgrade - -Gitea keeps compatibility for patch versions whose first two fields are the same (`a.b.x` -> `a.b.y`), -these patch versions can be upgraded and downgraded with the same database structure. -Otherwise (`a.b.?` -> `a.c.?`), a newer Gitea version will upgrade the old database -to a new structure that may differ from the old version. - -For example: - -| From | To | Result | -| --- | --- | --- | -| 1.4.0 | 1.4.1 | ✅ | -| 1.4.1 | 1.4.0 | ⚠️ Not recommended, take your own risk! Although it may work if the database structure doesn't change, it's highly recommended to use a backup to downgrade. | -| 1.4.x | 1.5.y | ✅ Database gets upgraded. You can upgrade from 1.4.x to the latest 1.5.y directly. | -| 1.5.y | 1.4.x | ❌ Database already got upgraded and can not be used for an old Gitea, use a backup to downgrade. | - -**Since you can not run an old Gitea with an upgraded database, -a backup should always be made before a database upgrade.** - -If you use Gitea in production, it's always highly recommended to make a backup before upgrade, -even if the upgrade is between patch versions. - -Backup steps: - -* Stop Gitea instance -* Backup database -* Backup Gitea config -* Backup Gitea data files in `APP_DATA_PATH` -* Backup Gitea external storage (eg: S3/MinIO or other storages if used) - -If you are using cloud services or filesystems with snapshot feature, -a snapshot for the Gitea data volume and related object storage is more convenient. - -After all of steps have been prepared, download the new version, stop the application, perform a backup and -then start the new application. On each startup, Gitea verifies that the database is up to date and will automatically -perform any necessary migrations. Depending on the size of the database, this can take some additional time on the -first launch during which the application will be unavailable. - -## Upgrade with Docker - -* `docker pull` the latest Gitea release. -* Stop the running instance, backup data. -* Use `docker` or `docker-compose` to start the newer Gitea Docker container. - -## Upgrade from package - -* Stop the running instance, backup data. -* Use your package manager to upgrade Gitea to the latest version. -* Start the Gitea instance. - -## Upgrade from binary - -* Download the latest Gitea binary to a temporary directory. -* Stop the running instance, backup data. -* Replace the installed Gitea binary with the downloaded one. -* Start the Gitea instance. - -A script automating these steps for a deployment on Linux can be found at [`contrib/upgrade.sh` in Gitea's source tree](https://github.com/go-gitea/gitea/blob/main/contrib/upgrade.sh). - -## Take care about customized templates - -Gitea's template structure and variables may change between releases, if you are using customized templates, -do pay attention if your templates are compatible with the Gitea you are using. - -If the customized templates don't match Gitea version, you may experience: -`50x` server error, page components missing or malfunctioning, strange page layout, ... -Remove or update the incompatible templates and Gitea web will work again. diff --git a/docs/content/installation/upgrade-from-gitea.zh-cn.md b/docs/content/installation/upgrade-from-gitea.zh-cn.md deleted file mode 100644 index 6300917e2d..0000000000 --- a/docs/content/installation/upgrade-from-gitea.zh-cn.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -date: "2021-09-02T16:00:00+08:00" -title: "从旧版 Gitea 升级" -slug: "upgrade-from-gitea" -sidebar_position: 100 -toc: false -draft: false -menu: - sidebar: - parent: "installation" - name: "从旧版 Gitea 升级" - sidebar_position: 100 - identifier: "upgrade-from-gitea" ---- - -# 从旧版 Gitea 升级 - -在升级之前,您需要做如下的准备工作。 - -## 为重大变更检查更新日志 - -为了让 Gitea 变得更好,进行重大变更是不可避免的,尤其是一些里程碑更新的发布。 -在更新前,请 [在 Gitea 博客上阅读更新日志](https://blog.gitea.com/) -并检查重大变更是否会影响你的 Gitea 实例。 - -## 在控制面板中检查过期的配置项 - -一些配置项可能会在后续版本中过期,你需要在控制面板中检查他们。如果不解决过期的配置项, -Gitea也许会在升级后无法重启。你可以访问 https://docs.gitea.com 获得要升级的版本 -对应的文档来修改你的配置文件。 - -## 降级前的备份 - -Gitea 会保留首二位版本号相同的版本的兼容性 (`a.b.x` -> `a.b.y`), -这些版本拥有相同的数据库结构,可以自由升级或降级。 -其他情况 (`a.b.?` -> `a.c.?`)下, -新版 Gitea 可能将会将数据库升级到与旧版数据库不同的结构。 - -举个例子: - -| 当前 | 目标 | 结果 | -| --- | --- | --- | -| 1.4.0 | 1.4.1 | ✅ | -| 1.4.1 | 1.4.0 | ⚠️ 不建议,后果自负!尽管数据库结构可能不会变更,让它可以正常工作。我们强烈建议降级前进行完全的备份。 | -| 1.4.x | 1.5.y | ✅ 数据库会被自动升级。你可以直接从 1.4.x 升级到最新的 1.5.y。 | -| 1.5.y | 1.4.x | ❌ 数据库已被升级且无法用于旧版本Gitea,使用备份来进行降级。 | - -**因为你不能基于升级后的数据库运行旧版 Gitea,所以你应该在数据库升级前完成数据备份。** - -如果你在生产环境下使用 Gitea,你应该在升级前做好备份,哪怕只是小版本的补丁更新。 - -备份步骤: - -* 停止 Gitea 实例 -* 备份数据库 -* 备份 Gitea 配置文件 -* 备份 Gitea 在 `APP_DATA_PATH` 中的数据文件 -* 备份 Gitea 的外部存储 (例如: S3/MinIO 或被使用的其他存储) - -如果你在使用云服务或拥有快照功能的文件系统, -最好对 Gitea 的数据盘及相关资料存储进行一次快照。 - -在所有上述步骤准备妥当之后,要升级 Gitea,只需要下载新版,停止运行旧版,进行数据备份,然后运行新版就好。 -每次 Gitea 实例启动时,它都会检查是否要进行数据库迁移。 -如果需要进行数据库迁移,Gitea 会花一些时间完成升级然后继续服务。 - -## 从 Docker 升级 - -* `docker pull` 拉取 Gitea 的最新发布版。 -* 停止运行中的实例,备份数据。 -* 使用 `docker` 或 `docker-compose` 启动较新的 Gitea Docker 容器. - -## 从包升级 - -* 停止运行中的实例,备份数据。 -* 使用你的包管理器更新 Gitea 到最新版本。 -* 启动 Gitea 实例。 - -## 从二进制升级 - -* 下载最新的 Gitea 二进制文件到临时文件夹中。 -* 停止运行中的实例,备份数据。 -* 将旧的 Gitea 二进制文件覆盖成新的。 -* 启动 Gitea 实例。 - -在 Linux 系统上自动执行以上步骤的脚本可在 [Gitea 的 source tree 中找到 `contrib/upgrade.sh` 来获取](https://github.com/go-gitea/gitea/blob/main/contrib/upgrade.sh). - -## 小心你的自定义模板 - -Gitea 的模板结构与变量可能会随着各个版本的发布发生变化,如果你使用了自定义模板, -你得注意你的模板与你使用的 Gitea 版本的兼容性。 - -如果自定义模板与 Gitea 版本不兼容,你可能会遇到: -`50x` 服务器错误,页面元素丢失或故障,莫名其妙的页面布局,等等… -移除或更新不兼容的模板,Gitea Web 才可以正常工作。 diff --git a/docs/content/installation/windows-service.en-us.md b/docs/content/installation/windows-service.en-us.md deleted file mode 100644 index 6c7d372549..0000000000 --- a/docs/content/installation/windows-service.en-us.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -date: "2016-12-21T15:00:00-02:00" -title: "Register as a Windows service" -slug: "windows-service" -sidebar_position: 50 -toc: false -draft: false -aliases: - - /en-us/windows-service -menu: - sidebar: - parent: "installation" - name: "Windows Service" - sidebar_position: 50 - identifier: "windows-service" ---- -# Register as a Windows service - -## Prerequisites - -The following changes are made in C:\gitea\custom\conf\app.ini: - -``` -RUN_USER = COMPUTERNAME$ -``` - -Sets Gitea to run as the local system user. - -COMPUTERNAME is whatever the response is from `echo %COMPUTERNAME%` on the command line. If the response is `USER-PC` then `RUN_USER = USER-PC$` - -### Use absolute paths - -If you use SQLite3, change the `PATH` to include the full path: - -``` -[database] -PATH = c:/gitea/data/gitea.db -``` - -## Register Gitea - -To register Gitea as a Windows service, open a command prompt (cmd) as an Administrator, -then run the following command: - -``` -sc.exe create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\"" -``` - -Do not forget to replace `C:\gitea` with the correct Gitea directory. - -Open "Windows Services", search for the service named "gitea", right-click it and click on -"Run". If everything is OK, Gitea will be reachable on `http://localhost:3000` (or the port -that was configured). - -### Service startup type - -It was observed that on loaded systems during boot Gitea service may fail to start with timeout records in Windows Event Log. -In that case change startup type to `Automatic-Delayed`. This can be done during service creation, or by running config command - -``` -sc.exe config gitea start= delayed-auto -``` - -### Adding startup dependencies - -To add a startup dependency to the Gitea Windows service (eg Mysql, Mariadb), as an Administrator, then run the following command: - -``` -sc.exe config gitea depend= mariadb -``` - -This will ensure that when the Windows machine restarts, the automatic starting of Gitea is postponed until the database is ready and thus mitigate failed startups. - -## Unregister Gitea - -To unregister Gitea as a Windows service, open a command prompt (cmd) as an Administrator and run: - -``` -sc.exe delete gitea -``` diff --git a/docs/content/installation/windows-service.zh-cn.md b/docs/content/installation/windows-service.zh-cn.md deleted file mode 100644 index d5761d2c19..0000000000 --- a/docs/content/installation/windows-service.zh-cn.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -date: "2016-12-21T15:00:00-02:00" -title: "注册为Windows服务" -slug: "windows-service" -sidebar_position: 50 -toc: false -draft: false -aliases: - - /zh-cn/windows-service -menu: - sidebar: - parent: "installation" - name: "Windows服务" - sidebar_position: 50 - identifier: "windows-service" ---- - -## 准备工作 - -在 C:\gitea\custom\conf\app.ini 中进行了以下更改: - -``` -RUN_USER = COMPUTERNAME$ -``` - -将 Gitea 设置为以本地系统用户运行。 - -COMPUTERNAME 是从命令行中运行 `echo %COMPUTERNAME%` 后得到的响应。如果响应是 `USER-PC`,那么 `RUN_USER = USER-PC$`。 - -### 使用绝对路径 - -如果您使用 SQLite3,请将 `PATH` 更改为包含完整路径: - -``` -[database] -PATH = c:/gitea/data/gitea.db -``` - -## 注册为Windows服务 - -要注册为Windows服务,首先以Administrator身份运行 `cmd`,然后执行以下命令: - -``` -sc.exe create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\"" -``` - -别忘了将 `C:\gitea` 替换成你的 Gitea 安装目录。 - -之后在控制面板打开 "Windows Services",搜索 "gitea",右键选择 "Run"。在浏览器打开 `http://localhost:3000` 就可以访问了。(如果你修改了端口,请访问对应的端口,3000是默认端口)。 - -### 服务启动类型 - -据观察,在启动期间加载的系统上,Gitea 服务可能无法启动,并在 Windows 事件日志中记录超时。 -在这种情况下,将启动类型更改为`Automatic-Delayed`。这可以在服务创建期间完成,或者通过运行配置命令来完成。 - -``` -sc.exe config gitea start= delayed-auto -``` - -### 添加启动依赖项 - -要将启动依赖项添加到 Gitea Windows 服务(例如 Mysql、Mariadb),作为管理员,然后运行以下命令: - -``` -sc.exe config gitea depend= mariadb -``` - -这将确保在 Windows 计算机重新启动时,将延迟自动启动 Gitea,直到数据库准备就绪,从而减少启动失败的情况。 - -## 从Windows服务中删除 - -以Administrator身份运行 `cmd`,然后执行以下命令: - -``` -sc.exe delete gitea -``` diff --git a/docs/content/installation/with-docker-rootless.en-us.md b/docs/content/installation/with-docker-rootless.en-us.md deleted file mode 100644 index 10f1212217..0000000000 --- a/docs/content/installation/with-docker-rootless.en-us.md +++ /dev/null @@ -1,364 +0,0 @@ ---- -date: "2020-02-09T20:00:00+02:00" -title: "Installation with Docker (rootless)" -slug: "install-with-docker-rootless" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /en-us/install-with-docker-rootless -menu: - sidebar: - parent: "installation" - name: "With Docker Rootless" - sidebar_position: 60 - identifier: "install-with-docker-rootless" ---- - -# Installation with Docker - -Gitea provides automatically updated Docker images within its Docker Hub organization. It is -possible to always use the latest stable tag or to use another service that handles updating -Docker images. - -The rootless image uses Gitea internal SSH to provide Git protocol and doesn't support OpenSSH. - -This reference setup guides users through the setup based on `docker-compose`, but the installation -of `docker-compose` is out of scope of this documentation. To install `docker-compose` itself, follow -the official [install instructions](https://docs.docker.com/compose/install/). - -## Basics - -The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest-rootless` -image as a service. Since there is no database available, one can be initialized using SQLite3. - -Create a directory for `data` and `config`: - -```sh -mkdir -p gitea/{data,config} -cd gitea -touch docker-compose.yml -``` - -Then paste the following content into a file named `docker-compose.yml`: - -```yaml -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -Note that the volume should be owned by the user/group with the UID/GID specified in the config file. By default Gitea in docker will use uid:1000 gid:1000. If needed you can set ownership on those folders with the command: - -```sh -sudo chown 1000:1000 config/ data/ -``` - -> If you don't give the volume correct permissions, the container may not start. - -For a stable release you could use `:latest-rootless`, `:1-rootless` or specify a certain release like `:@version@-rootless`, but if you'd like to use the latest development version then `:nightly-rootless` would be an appropriate tag. If you'd like to run the latest commit from a release branch you can use the `:1.x-nightly-rootless` tag, where x is the minor version of Gitea. (e.g. `:1.16-nightly-rootless`) - -## Custom port - -To bind the integrated ssh and the webserver on a different port, adjust -the port section. It's common to just change the host port and keep the ports within -the container like they are. - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: -- - "3000:3000" -- - "2222:2222" -+ - "80:3000" -+ - "22:2222" -``` - -## MySQL database - -To start Gitea in combination with a MySQL database, apply these changes to the -`docker-compose.yml` file created above. - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless -+ environment: -+ - GITEA__database__DB_TYPE=mysql -+ - GITEA__database__HOST=db:3306 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -+ depends_on: -+ - db -+ -+ db: -+ image: mysql:8 -+ restart: always -+ environment: -+ - MYSQL_ROOT_PASSWORD=gitea -+ - MYSQL_USER=gitea -+ - MYSQL_PASSWORD=gitea -+ - MYSQL_DATABASE=gitea -+ volumes: -+ - ./mysql:/var/lib/mysql -``` - -## PostgreSQL database - -To start Gitea in combination with a PostgreSQL database, apply these changes to -the `docker-compose.yml` file created above. - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - environment: -+ - GITEA__database__DB_TYPE=postgres -+ - GITEA__database__HOST=db:5432 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -+ depends_on: -+ - db -+ -+ db: -+ image: postgres:14 -+ restart: always -+ environment: -+ - POSTGRES_USER=gitea -+ - POSTGRES_PASSWORD=gitea -+ - POSTGRES_DB=gitea -+ volumes: -+ - ./postgres:/var/lib/postgresql/data -``` - -## Named volumes - -To use named volumes instead of host volumes, define and use the named volume -within the `docker-compose.yml` configuration. This change will automatically -create the required volume. You don't need to worry about permissions with -named volumes; Docker will deal with that automatically. - -```diff -version: "2" - -+volumes: -+ gitea-data: -+ driver: local -+ gitea-config: -+ driver: local -+ -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: -- - ./data:/var/lib/gitea -+ - gitea-data:/var/lib/gitea -- - ./config:/etc/gitea -+ - gitea-config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -MySQL or PostgreSQL containers will need to be created separately. - -## Custom user - -You can choose to use a custom user (following --user flag definition https://docs.docker.com/engine/reference/run/#user). -As an example to clone the host user `git` definition use the command `id -u git` and add it to `docker-compose.yml` file: -Please make sure that the mounted folders are writable by the user. - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always -+ user: 1001 - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -## Start - -To start this setup based on `docker-compose`, execute `docker-compose up -d`, -to launch Gitea in the background. Using `docker-compose ps` will show if Gitea -started properly. Logs can be viewed with `docker-compose logs`. - -To shut down the setup, execute `docker-compose down`. This will stop -and kill the containers. The volumes will still exist. - -Notice: if using a non-3000 port on http, change app.ini to match -`LOCAL_ROOT_URL = http://localhost:3000/`. - -## Install - -After starting the Docker setup via `docker-compose`, Gitea should be available using a -favorite browser to finalize the installation. Visit http://server-ip:3000 and follow the -installation wizard. If the database was started with the `docker-compose` setup as -documented above, please note that `db` must be used as the database hostname. - -# Customization - -Customization files described [here](administration/customizing-gitea.md) should -be placed in `/var/lib/gitea/custom` directory. If using host volumes, it's quite easy to access these -files; for named volumes, this is done through another container or by direct access at -`/var/lib/docker/volumes/gitea_gitea/_/var_lib_gitea`. The configuration file will be saved at -`/etc/gitea/app.ini` after the installation. - -# Upgrading - -:exclamation::exclamation: **Make sure you have volumed data to somewhere outside Docker container** :exclamation::exclamation: - -To upgrade your installation to the latest release: - -``` -# Edit `docker-compose.yml` to update the version, if you have one specified -# Pull new images -docker-compose pull -# Start a new container, automatically removes old one -docker-compose up -d -``` - -# Upgrading from standard image - -- Backup your setup -- Change volume mountpoint from /data to /var/lib/gitea -- If you used a custom app.ini move it to a new volume mounted to /etc/gitea -- Rename folder (inside volume) gitea to custom -- Edit app.ini if needed - - Set START_SSH_SERVER = true -- Use image gitea/gitea:@version@-rootless - -## Managing Deployments With Environment Variables - -In addition to the environment variables above, any settings in `app.ini` can be set -or overridden with an environment variable of the form: `GITEA__SECTION_NAME__KEY_NAME`. -These settings are applied each time the docker container starts, and won't be passed into Gitea's sub-processes. -Full information [here](https://github.com/go-gitea/gitea/tree/main/contrib/environment-to-ini). - -These environment variables can be passed to the docker container in `docker-compose.yml`. -The following example will enable a smtp mail server if the required env variables -`GITEA__mailer__FROM`, `GITEA__mailer__HOST`, `GITEA__mailer__PASSWD` are set on the host -or in a `.env` file in the same directory as `docker-compose.yml`. - -The settings can be also set or overridden with the content of a file by defining an environment variable of the form: -`GITEA__section_name__KEY_NAME__FILE` that points to a file. - -```bash -... -services: - server: - environment: - - GITEA__mailer__ENABLED=true - - GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set} - - GITEA__mailer__PROTOCOL=smtp - - GITEA__mailer__HOST=${GITEA__mailer__HOST:?GITEA__mailer__HOST not set} - - GITEA__mailer__IS_TLS_ENABLED=true - - GITEA__mailer__USER=${GITEA__mailer__USER:-apikey} - - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}""" -``` - -To set required TOKEN and SECRET values, consider using Gitea's built-in [generate utility functions](administration/command-line.md#generate). - -# SSH Container Passthrough - -Since SSH is running inside the container, SSH needs to be passed through from the host to the container if SSH support is desired. One option would be to run the container SSH on a non-standard port (or moving the host port to a non-standard port). Another option which might be more straightforward is to forward SSH commands from the host to the container. This setup is explained in the following. - -This guide assumes that you have created a user on the host called `git` with permission to run `docker exec`, and that the Gitea container is called `gitea`. You will need to modify that user's shell to forward the commands to the `sh` executable inside the container, using `docker exec`. - -First, create the file `/usr/local/bin/gitea-shell` on the host, with the following contents: - -```bash -#!/bin/sh -/usr/bin/docker exec -i --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@" -``` - -Note that `gitea` in the docker command above is the name of the container. If you named yours differently, don't forget to change that. - -You should also make sure that you’ve set the permissions of the shell wrapper correctly: - -```bash -sudo chmod +x /usr/local/bin/gitea-shell -``` - -Once the wrapper is in place, you can make it the shell for the `git` user: - -```bash -sudo usermod -s /usr/local/bin/gitea-shell git -``` - -Now that all the SSH commands are forwarded to the container, you need to set up the SSH authentication on the host. This is done by leveraging the [SSH AuthorizedKeysCommand](administration/command-line.md#keys) to match the keys against those accepted by Gitea. Add the following block to `/etc/ssh/sshd_config`, on the host: - -```bash -Match User git - AuthorizedKeysCommandUser git - AuthorizedKeysCommand /usr/bin/docker exec -i gitea /usr/local/bin/gitea keys -c /etc/gitea/app.ini -e git -u %u -t %t -k %k -``` - -(From 1.16.0 you will not need to set the `-c /etc/gitea/app.ini` option.) - -All that is left to do is restart the SSH server: - -```bash -sudo systemctl restart sshd -``` - -**Notes** - -This isn't actually using the docker SSH - it is simply using the commands around it. -You could theoretically not run the internal SSH server. diff --git a/docs/content/installation/with-docker-rootless.zh-cn.md b/docs/content/installation/with-docker-rootless.zh-cn.md deleted file mode 100644 index 70bc32dc12..0000000000 --- a/docs/content/installation/with-docker-rootless.zh-cn.md +++ /dev/null @@ -1,332 +0,0 @@ ---- -date: "2020-02-09T20:00:00+02:00" -title: "使用 Docker 安装 (rootless)" -slug: "install-with-docker-rootless" -sidebar_position: 60 -toc: false -draft: false -aliases: - - /zh-cn/install-with-docker-rootless -menu: - sidebar: - parent: "installation" - name: "使用 Docker 安装 (rootless)" - sidebar_position: 60 - identifier: "install-with-docker-rootless" ---- - -# 使用 Docker 安装 - -Gitea 在其 Docker Hub 组织中提供自动更新的 Docker 镜像。您可以始终使用最新的稳定标签,或使用其他处理 Docker 镜像更新的服务。 - -rootless 镜像使用 Gitea 内部 SSH 功能来提供 Git 协议,但不支持 OpenSSH。 - -本参考设置指南将用户引导通过基于 `docker-compose` 的设置。但是,`docker-compose` 的安装超出了本文档的范围。要安装`docker-compose` 本身, 请按照官方的 [安装说明](https://docs.docker.com/compose/install/)进行操作。 - -## 基础设置 - -最简单的设置只需创建一个卷和一个网络,并将 `gitea/gitea:latest-rootless` 镜像作为服务启动。由于没有可用的数据库,可以使用 SQLite3 来初始化一个。 - -创建一个名为 `data` 和 `config`: - -```sh -mkdir -p gitea/{data,config} -cd gitea -touch docker-compose.yml -``` - -然后将以下内容粘贴到名为 `docker-compose.yml` 的文件中: - -```yaml -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -请注意,卷应由在配置文件中指定的UID/GID的用户/组所有。默认情况下,Docker中的Gitea将使用uid:1000 gid:1000。如果需要,您可以使用以下命令设置这些文件夹的所有权: - -```sh -sudo chown 1000:1000 config/ data/ -``` - -> 如果未为卷设置正确的权限,容器可能无法启动。 - -对于稳定版本,您可以使用 `:latest-rootless`、`:1-rootless`,或指定特定的版本,如: `@version@-rootless`。如果您想使用最新的开发版本,则可以使用 `:dev-rootless` 标签。如果您想运行发布分支的最新提交,可以使用 `:1.x-dev-rootless` 标签,其中 x是 Gitea 的次要版本号(例如:`1.16-dev-rootless`)。 - -## 自定义端口 - -要将集成的SSH和Web服务器绑定到不同的端口,请调整端口部分。通常只需更改主机端口并保持容器内的端口不变。 - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: -- - "3000:3000" -- - "2222:2222" -+ - "80:3000" -+ - "22:2222" -``` - -## MySQL 数据库 - -要将 Gitea 与 MySQL 数据库结合使用,请对上面创建的 `docker-compose.yml` 文件进行以下更改。 - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless -+ environment: -+ - GITEA__database__DB_TYPE=mysql -+ - GITEA__database__HOST=db:3306 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -+ depends_on: -+ - db -+ -+ db: -+ image: mysql:8 -+ restart: always -+ environment: -+ - MYSQL_ROOT_PASSWORD=gitea -+ - MYSQL_USER=gitea -+ - MYSQL_PASSWORD=gitea -+ - MYSQL_DATABASE=gitea -+ volumes: -+ - ./mysql:/var/lib/mysql -``` - -## PostgreSQL 数据库 - -要将 Gitea 与 PostgreSQL 数据库结合使用,请对上面创建的 `docker-compose.yml` 文件进行以下更改。 - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - environment: -+ - GITEA__database__DB_TYPE=postgres -+ - GITEA__database__HOST=db:5432 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -+ depends_on: -+ - db -+ -+ db: -+ image: postgres:14 -+ restart: always -+ environment: -+ - POSTGRES_USER=gitea -+ - POSTGRES_PASSWORD=gitea -+ - POSTGRES_DB=gitea -+ volumes: -+ - ./postgres:/var/lib/postgresql/data -``` - -## 命名卷 (Named Volumes) - -要使用命名卷 (Named Volumes) 而不是主机卷 (Host Volumes),请在 `docker-compose.yml` 配置中定义和使用命名卷。这样的更改将自动创建所需的卷。您不需要担心权限问题,Docker 会自动处理。 - -```diff -version: "2" - -+volumes: -+ gitea-data: -+ driver: local -+ gitea-config: -+ driver: local -+ -services: - server: - image: gitea/gitea:@version@-rootless - restart: always - volumes: -- - ./data:/var/lib/gitea -+ - gitea-data:/var/lib/gitea -- - ./config:/etc/gitea -+ - gitea-config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -MySQL 或 PostgreSQL 容器需要单独创建。 - -## 自定义用户 - -你可以选择使用自定义用户 (遵循 --user 标志定义 https://docs.docker.com/engine/reference/run/#user)。 -例如,要克隆主机用户 `git` 的定义,请使用命令 `id -u git` 并将其添加到 `docker-compose.yml` 文件中: -请确用户对保挂载的文件夹具有写权限。 - -```diff -version: "2" - -services: - server: - image: gitea/gitea:@version@-rootless - restart: always -+ user: 1001 - volumes: - - ./data:/var/lib/gitea - - ./config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "2222:2222" -``` - -## 启动 - -要启动基于 `docker-compose` 的这个设置,请执行 `docker-compose up -d`,以在后台启动 Gitea。使用 `docker-compose ps` 命令可以查看 Gitea 是否正确启动。可以使用 `docker-compose logs` 命令查看日志。 - -要关闭设置,请执行 `docker-compose down` 命令。这将停止和终止容器,但卷仍将存在。 - -注意:如果在 HTTP 上使用的是非 3000 端口,请将 app.ini 更改为匹配 `LOCAL_ROOT_URL = http://localhost:3000/`。 - -## 安装 - -在通过 `docker-compose` 启动 Docker 设置后,可以使用喜爱的浏览器访问 Gitea,完成安装过程。访问 `http://<服务器-IP>:3000` 并按照安装向导进行操作。如果数据库是使用上述文档中的 `docker-compose` 设置启动的,请注意必须使用 `db` 作为数据库主机名。 - -# 自定义 - -自定义文件的位置位于 `/var/lib/gitea/custom` 目录中,可以在这里找到有关自定义的文件说明。如果使用主机卷(host volumes),很容易访问这些文件;如果使用命名卷(named volumes),则可以通过另一个容器或直接访问 `/var/lib/docker/volumes/gitea_gitea/_/var_lib_gitea` 来进行访问。在安装后,配置文件将保存在 `/etc/gitea/app.ini` 中。 - -# 升级 - -:exclamation::exclamation: **确保您已将数据卷迁移到 Docker 容器之外的其他位置** :exclamation::exclamation: - -要将安装升级到最新版本,请按照以下步骤操作: - -``` -# 如果在 docker-compose.yml 中指定了版本,请编辑该文件以更新版本 -# 拉取新的镜像 -docker-compose pull -# 启动一个新的容器,自动移除旧的容器 -docker-compose up -d -``` - -# 从标准镜像升级 - -- 备份您的设置 -- 将卷挂载点从 `/data` 更改为 `/var/lib/gitea` -- 如果使用了自定义的 `app.ini`,请将其移动到新的挂载到 `/etc/gitea` 的卷中 -- 将卷中的文件夹(gitea)重命名为 custom -- 如果需要,编辑 `app.ini` - - 设置 `START_SSH_SERVER = true` -- 使用镜像 `gitea/gitea:@version@-rootless` - -## 使用环境变量管理部署 - -除了上述的环境变量外,`app.ini` 中的任何设置都可以通过形式为 `GITEA__SECTION_NAME__KEY_NAME` 的环境变量进行设置或覆盖。这些设置在每次 Docker 容器启动时都会生效。完整信息请参考[这里](https://github.com/go-gitea/gitea/tree/main/contrib/environment-to-ini). - -这些环境变量可以在 `docker-compose.yml` 中传递给 Docker 容器。以下示例将启用 SMTP 邮件服务器,如果主机上设置了所需的环境变量 GITEA__mailer__FROM、GITEA__mailer__HOST、GITEA__mailer__PASSWD,或者在与 `docker-compose.yml` 相同目录中的 `.env` 文件中设置了这些环境变量: - -```bash -... -services: - server: - environment: - - GITEA__mailer__ENABLED=true - - GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set} - - GITEA__mailer__PROTOCOL=smtp - - GITEA__mailer__HOST=${GITEA__mailer__HOST:?GITEA__mailer__HOST not set} - - GITEA__mailer__IS_TLS_ENABLED=true - - GITEA__mailer__USER=${GITEA__mailer__USER:-apikey} - - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}""" -``` - -要设置所需的 TOKEN 和 SECRET 值,可以使用 Gitea 的内置[生成使用函数](administration/command-line.md#generate). - -# SSH 容器透传 - -由于 SSH 在容器内运行,如果需要 SSH 支持,需要将 SSH 从主机透传到容器。一种选择是在容器内运行 SSH,并使用非标准端口(或将主机端口移动到非标准端口)。另一种可能更直接的选择是将主机上的 SSH 命令转发到容器。下面解释了这种设置。 - -本指南假设您已在主机上创建了一个名为 `git` 的用户,并具有运行 `docker exec` 的权限,并且 Gitea 容器的名称为 `gitea`。您需要修改该用户的 shell,以将命令转发到容器内的 `sh` 可执行文件,使用 `docker exec`。 - -首先,在主机上创建文件 `/usr/local/bin/gitea-shell`,并填入以下内容: - -```bash -#!/bin/sh -/usr/bin/docker exec -i --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@" -``` - -注意上述 docker 命令中的 `gitea` 是容器的名称。如果您的容器名称不同,请记得更改。 - -还应确保正确设置了 shell 包装器的权限: - -```bash -sudo chmod +x /usr/local/bin/gitea-shell -``` - -一旦包装器就位,您可以将其设置为 `git` 用户的 shell: - -```bash -sudo usermod -s /usr/local/bin/gitea-shell git -``` - -现在,所有的 SSH 命令都会被转发到容器,您需要在主机上设置 SSH 认证。这可以通过利用 [SSH AuthorizedKeysCommand](administration/command-line.md#keys) 来匹配 Gitea 接受的密钥。在主机的 `/etc/ssh/sshd_config` 文件中添加以下代码块: - -```bash -Match User git - AuthorizedKeysCommandUser git - AuthorizedKeysCommand /usr/bin/docker exec -i gitea /usr/local/bin/gitea keys -c /etc/gitea/app.ini -e git -u %u -t %t -k %k -``` - -(从 1.16.0 开始,您将不需要设置 `-c /etc/gitea/app.ini` 选项。) - -剩下的就是重新启动 SSH 服务器: - -```bash -sudo systemctl restart sshd -``` - -**注意** - -这实际上并没有使用 Docker 的 SSH,而是仅仅使用了围绕它的命令。 -从理论上讲,您可以不运行内部的 SSH 服务器。 diff --git a/docs/content/installation/with-docker.en-us.md b/docs/content/installation/with-docker.en-us.md deleted file mode 100644 index a16d4a8d60..0000000000 --- a/docs/content/installation/with-docker.en-us.md +++ /dev/null @@ -1,643 +0,0 @@ ---- -date: "2020-03-19T19:27:00+02:00" -title: "Installation with Docker" -slug: "install-with-docker" -sidebar_position: 70 -toc: false -draft: false -aliases: - - /en-us/install-with-docker -menu: - sidebar: - parent: "installation" - name: "With Docker" - sidebar_position: 70 - identifier: "install-with-docker" ---- - -# Installation with Docker - -Gitea provides automatically updated Docker images within its Docker Hub organization. It is -possible to always use the latest stable tag or to use another service that handles updating -Docker images. - -This reference setup guides users through the setup based on `docker-compose`, but the installation -of `docker-compose` is out of scope of this documentation. To install `docker-compose` itself, follow -the official [install instructions](https://docs.docker.com/compose/install/). - -## Basics - -The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest` -image as a service. Since there is no database available, one can be initialized using SQLite3. -Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`. -Note that the volume should be owned by the user/group with the UID/GID specified in the config file. -If you don't give the volume correct permissions, the container may not start. -For a stable release you can use `:latest`, `:1` or specify a certain release like `:@version@`, but if you'd like to use the latest development version of Gitea then you could use the `:nightly` tag. If you'd like to run the latest commit from a release branch you can use the `:1.x-nightly` tag, where x is the minor version of Gitea. (e.g. `:1.16-nightly`) - -```yaml -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -``` - -## Ports - -To bind the integrated OpenSSH daemon and the webserver on a different port, adjust -the port section. It's common to just change the host port and keep the ports within -the container like they are. - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: -- - "3000:3000" -- - "222:22" -+ - "8080:3000" -+ - "2221:22" -``` - -## Databases - -### MySQL database - -To start Gitea in combination with a MySQL database, apply these changes to the -`docker-compose.yml` file created above. - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 -+ - GITEA__database__DB_TYPE=mysql -+ - GITEA__database__HOST=db:3306 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -+ depends_on: -+ - db -+ -+ db: -+ image: mysql:8 -+ restart: always -+ environment: -+ - MYSQL_ROOT_PASSWORD=gitea -+ - MYSQL_USER=gitea -+ - MYSQL_PASSWORD=gitea -+ - MYSQL_DATABASE=gitea -+ networks: -+ - gitea -+ volumes: -+ - ./mysql:/var/lib/mysql -``` - -### PostgreSQL database - -To start Gitea in combination with a PostgreSQL database, apply these changes to -the `docker-compose.yml` file created above. - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 -+ - GITEA__database__DB_TYPE=postgres -+ - GITEA__database__HOST=db:5432 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -+ depends_on: -+ - db -+ -+ db: -+ image: postgres:14 -+ restart: always -+ environment: -+ - POSTGRES_USER=gitea -+ - POSTGRES_PASSWORD=gitea -+ - POSTGRES_DB=gitea -+ networks: -+ - gitea -+ volumes: -+ - ./postgres:/var/lib/postgresql/data -``` - -## Named volumes - -To use named volumes instead of host volumes, define and use the named volume -within the `docker-compose.yml` configuration. This change will automatically -create the required volume. You don't need to worry about permissions with -named volumes; Docker will deal with that automatically. - -```diff -version: "3" - -networks: - gitea: - external: false - -+volumes: -+ gitea: -+ driver: local -+ -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - restart: always - networks: - - gitea - volumes: -- - ./gitea:/data -+ - gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -``` - -MySQL or PostgreSQL containers will need to be created separately. - -## Startup - -To start this setup based on `docker-compose`, execute `docker-compose up -d`, -to launch Gitea in the background. Using `docker-compose ps` will show if Gitea -started properly. Logs can be viewed with `docker-compose logs`. - -To shut down the setup, execute `docker-compose down`. This will stop -and kill the containers. The volumes will still exist. - -Notice: if using a non-3000 port on http, change app.ini to match -`LOCAL_ROOT_URL = http://localhost:3000/`. - -## Installation - -After starting the Docker setup via `docker-compose`, Gitea should be available using a -favorite browser to finalize the installation. Visit http://server-ip:3000 and follow the -installation wizard. If the database was started with the `docker-compose` setup as -documented above, please note that `db` must be used as the database hostname. - -## Configure the user inside Gitea using environment variables - -- `USER`: **git**: The username of the user that runs Gitea within the container. -- `USER_UID`: **1000**: The UID (Unix user ID) of the user that runs Gitea within the container. Match this to the UID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). -- `USER_GID`: **1000**: The GID (Unix group ID) of the user that runs Gitea within the container. Match this to the GID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). - -## Customization - -Customization files described [here](administration/customizing-gitea.md) should -be placed in `/data/gitea` directory. If using host volumes, it's quite easy to access these -files; for named volumes, this is done through another container or by direct access at -`/var/lib/docker/volumes/gitea_gitea/_data`. The configuration file will be saved at -`/data/gitea/conf/app.ini` after the installation. - -## Upgrading - -:exclamation::exclamation: **Make sure you have volumed data to somewhere outside Docker container** :exclamation::exclamation: - -To upgrade your installation to the latest release: - -```bash -# Edit `docker-compose.yml` to update the version, if you have one specified -# Pull new images -docker-compose pull -# Start a new container, automatically removes old one -docker-compose up -d -``` - -## Managing Deployments With Environment Variables - -In addition to the environment variables above, any settings in `app.ini` can be set -or overridden with an environment variable of the form: `GITEA__SECTION_NAME__KEY_NAME`. -These settings are applied each time the docker container starts, and won't be passed into Gitea's sub-processes. -Full information [here](https://github.com/go-gitea/gitea/tree/master/contrib/environment-to-ini). - -These environment variables can be passed to the docker container in `docker-compose.yml`. -The following example will enable an smtp mail server if the required env variables -`GITEA__mailer__FROM`, `GITEA__mailer__HOST`, `GITEA__mailer__PASSWD` are set on the host -or in a `.env` file in the same directory as `docker-compose.yml`. - -The settings can be also set or overridden with the content of a file by defining an environment variable of the form: -`GITEA__section_name__KEY_NAME__FILE` that points to a file. - -```bash -... -services: - server: - environment: - - GITEA__mailer__ENABLED=true - - GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set} - - GITEA__mailer__PROTOCOL=smtps - - GITEA__mailer__SMTP_ADDR=${GITEA__mailer__SMTP_ADDR:?GITEA__mailer__SMTP_ADDR not set} - - GITEA__mailer__SMTP_PORT=${GITEA__mailer__SMTP_PORT:?GITEA__mailer__SMTP_PORT not set} - - GITEA__mailer__USER=${GITEA__mailer__USER:-apikey} - - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}""" -``` - -Gitea will generate new secrets/tokens for every new installation automatically and write them into the app.ini. If you want to set the secrets/tokens manually, you can use the following docker commands to use of Gitea's built-in [generate utility functions](administration/command-line.md#generate). Do not lose/change your SECRET_KEY after the installation, otherwise the encrypted data can not be decrypted anymore. - -The following commands will output a new `SECRET_KEY` and `INTERNAL_TOKEN` to `stdout`, which you can then place in your environment variables. - -```bash -docker run -it --rm gitea/gitea:1 gitea generate secret SECRET_KEY -docker run -it --rm gitea/gitea:1 gitea generate secret INTERNAL_TOKEN -``` - -```yaml -... -services: - server: - environment: - - GITEA__security__SECRET_KEY=[value returned by generate secret SECRET_KEY] - - GITEA__security__INTERNAL_TOKEN=[value returned by generate secret INTERNAL_TOKEN] -``` - -## SSH Container Passthrough - -Since SSH is running inside the container, SSH needs to be passed through from the host to the container if SSH support is desired. One option would be to run the container SSH on a non-standard port (or moving the host port to a non-standard port). Another option which might be more straightforward is for Gitea users to ssh to a Gitea user on the host which will then relay those connections to the docker. - -### Understanding SSH access to Gitea (without passthrough) - -To understand what needs to happen, you first need to understand what happens without passthrough. So we will try to explain this: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea will add an entry for this key to the `.ssh/authorized_keys` file of its running user, `git`. -3. This entry has the public key, but also has a `command=` option. It is this command that Gitea uses to match this key to the client user and manages authentication. -4. The client then makes an SSH request to the SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -5. The client will attempt to authenticate with the server, passing one or more public keys one at a time to the server. -6. For each key the client provides, the SSH server will first check its configuration for an `AuthorizedKeysCommand` to see if the public key matches, and then the `git` user's `authorized_keys` file. -7. The first entry that matches will be selected, and assuming this is a Gitea entry, the `command=` will now be executed. -8. The SSH server creates a user session for the `git` user, and using the shell for the `git` user runs the `command=` -9. This runs `gitea serv` which takes over control of the rest of the SSH session and manages gitea authentication & authorization of the git commands. - -Now, for the SSH passthrough to work, we need the host SSH to match the public keys and then run the `gitea serv` on the docker. There are multiple ways of doing this. However, all of these require some information about the docker being passed to the host. - -### SSHing Shim (with authorized_keys) - -In this option, the idea is that the host simply uses the `authorized_keys` that gitea creates but at step 9 the `gitea` command that the host runs is a shim that actually runs ssh to go into the docker and then run the real docker `gitea` itself. - -- To make the forwarding work, the SSH port of the container (22) needs to be mapped to the host port 2222 in `docker-compose.yml` . Since this port does not need to be exposed to the outside world, it can be mapped to the `localhost` of the host machine: - - ```yaml - ports: - # [...] - - "127.0.0.1:2222:22" - ``` - -- Next on the host create the `git` user which shares the same `UID`/ `GID` as the container values `USER_UID`/ `USER_GID`. These values can be set as environment variables in the `docker-compose.yml`: - - ```yaml - environment: - - USER_UID=1000 - - USER_GID=1000 - ``` - -- Mount `/home/git/.ssh` of the host into the container. This ensures that the `authorized_keys` file is shared between the host `git` user and the container `git` user otherwise the SSH authentication cannot work inside the container. - - ```yaml - volumes: - - /home/git/.ssh/:/data/git/.ssh - ``` - -- Now a SSH key pair needs to be created on the host. This key pair will be used to authenticate the `git` user on the host to the container. As an administrative user on the host run: (by administrative user we mean a user that can sudo to root) - - ```bash - sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" - ``` - -- Please note depending on the local version of ssh you may want to consider using `-t ecdsa` here. - -- `/home/git/.ssh/authorized_keys` on the host now needs to be modified. It needs to act in the same way as `authorized_keys` within the Gitea container. Therefore add the public key of the key you created above ("Gitea Host Key") to `~/git/.ssh/authorized_keys`. As an administrative user on the host run: - - ```bash - sudo -u git cat /home/git/.ssh/id_rsa.pub | sudo -u git tee -a /home/git/.ssh/authorized_keys - sudo -u git chmod 600 /home/git/.ssh/authorized_keys - ``` - - Important: The pubkey from the `git` user needs to be added "as is" while all other pubkeys added via the Gitea web interface will be prefixed with `command="/usr [...]`. - - `/home/git/.ssh/authorized_keys` should then look somewhat like - - ```bash - # SSH pubkey from git user - ssh-rsa <Gitea Host Key> - - # other keys from users - command="/usr/local/bin/gitea --config=/data/gitea/conf/app.ini serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty <user pubkey> - ``` - -- The next step is to create the fake host `gitea` command that will forward commands from the host to the container. The name of this file depends on your version of Gitea: - - - For Gitea v1.16.0+. As an administrative user on the host run: - - ```bash - cat <<"EOF" | sudo tee /usr/local/bin/gitea - #!/bin/sh - ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@" - EOF - sudo chmod +x /usr/local/bin/gitea - ``` - -Here is a detailed explanation what is happening when a SSH request is made: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea in the container will add an entry for this key to the `.ssh/authorized_keys` file of its running user, `git`. - - However, because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key has been added to the host `git` user's `authorized_keys` file too. -3. This entry has the public key, but also has a `command=` option. - - This command matches the location of the Gitea binary on the container, but also the location of the shim on the host. -4. The client then makes an SSH request to the host SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -5. The client will attempt to authenticate with the server, passing one or more public keys in turn to the host. -6. For each key the client provides, the host SSH server will first check its configuration for an `AuthorizedKeysCommand` to see if the public key matches, and then the host `git` user's `authorized_keys` file. - - Because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key they added to the Gitea web will be found -7. The first entry that matches will be selected, and assuming this is a Gitea entry, the `command=` will now be executed. -8. The host SSH server creates a user session for the `git` user, and using the shell for the host `git` user runs the `command=` -9. This means that the host runs the host `/usr/local/bin/gitea` shim that opens an SSH from the host to container passing the rest of the command arguments directly to `/usr/local/bin/gitea` on the container. -10. Meaning that the container `gitea serv` is run, taking over control of the rest of the SSH session and managing gitea authentication & authorization of the git commands. - -**Notes** - -SSH container passthrough using `authorized_keys` will work only if - -- `opensshd` is used in the container -- if `AuthorizedKeysCommand` is _not used_ in combination with `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` to disable authorized files key generation -- `LOCAL_ROOT_URL` is not changed (depending on the changes) - -If you try to run `gitea` on the host, you will attempt to ssh to the container and thence run the `gitea` command there. - -Never add the `Gitea Host Key` as a SSH key to a user on the Gitea interface. - -### SSHing Shell (with authorized_keys) - -In this option, the idea is that the host simply uses the `authorized_keys` that gitea creates but at step 8 above we change the shell that the host runs to ssh directly into the docker and then run the shell there. This means that the `gitea` that is then run is the real docker `gitea`. - -- In this case we setup as per SSHing Shim except instead of creating `/usr/local/bin/gitea` -we create a new shell for the git user. As an administrative user on the host run: - - ```bash - cat <<"EOF" | sudo tee /home/git/ssh-shell - #!/bin/sh - shift - ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $@" - EOF - sudo chmod +x /home/git/ssh-shell - sudo usermod -s /home/git/ssh-shell git - ``` - - Be careful here - if you try to login as the git user in future you will ssh directly to the docker. - -Here is a detailed explanation what is happening when a SSH request is made: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea in the container will add an entry for this key to the `.ssh/authorized_keys` file of its running user, `git`. - - However, because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key has been added to the host `git` user's `authorized_keys` file too. -3. This entry has the public key, but also has a `command=` option. - - This command matches the location of the Gitea binary on the container. -4. The client then makes an SSH request to the host SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -5. The client will attempt to authenticate with the server, passing one or more public keys in turn to the host. -6. For each key the client provides, the host SSH server will first check its configuration for an `AuthorizedKeysCommand` to see if the public key matches, and then the host `git` user's `authorized_keys` file. - - Because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key they added to the Gitea web will be found -7. The first entry that matches will be selected, and assuming this is a Gitea entry, the `command=` will now be executed. -8. The host SSH server creates a user session for the `git` user, and using the shell for the host `git` user runs the `command=` -9. The shell of the host `git` user is now our `ssh-shell` which opens an SSH connection from the host to container, (which opens a shell on the container for the container `git`). -10. The container shell now runs the `command=` option meaning that the container `gitea serv` is run, taking over control of the rest of the SSH session and managing gitea authentication & authorization of the git commands. - -**Notes** - -SSH container passthrough using `authorized_keys` will work only if - -- `opensshd` is used in the container -- if `AuthorizedKeysCommand` is _not used_ in combination with `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` to disable authorized files key generation -- `LOCAL_ROOT_URL` is not changed (depending on the changes) - -If you try to login as the `git` user on the host in future you will ssh directly to the docker. - -Never add the `Gitea Host Key` as a SSH key to a user on the Gitea interface. - -### Docker Shell (with authorized_keys) - -Similar to the above ssh shell technique we can use a shell which simply uses `docker exec`. As an administrative user on the host run: - -```bash -cat <<"EOF" | sudo tee /home/git/docker-shell -#!/bin/sh -/usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@" -EOF -sudo chmod +x /home/git/docker-shell -sudo usermod -s /home/git/docker-shell git -``` - -Here is a detailed explanation what is happening when a SSH request is made: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea in the container will add an entry for this key to the `.ssh/authorized_keys` file of its running user, `git`. - - However, because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key has been added to the host `git` user's `authorized_keys` file too. -3. This entry has the public key, but also has a `command=` option. - - This command matches the location of the Gitea binary on the container. -4. The client then makes an SSH request to the host SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -5. The client will attempt to authenticate with the server, passing one or more public keys in turn to the host. -6. For each key the client provides, the host SSH server will first check its configuration for an `AuthorizedKeysCommand` to see if the public key matches, and then the host `git` user's `authorized_keys` file. - - Because `/home/git/.ssh/` on the host is mounted as `/data/git/.ssh` this means that the key they added to the Gitea web will be found -7. The first entry that matches will be selected, and assuming this is a Gitea entry, the `command=` will now be executed. -8. The host SSH server creates a user session for the `git` user, and using the shell for the host `git` user runs the `command=` -9. The shell of the host `git` user is now our `docker-shell` which uses `docker exec` to open a shell for the `git` user on the container. -10. The container shell now runs the `command=` option meaning that the container `gitea serv` is run, taking over control of the rest of the SSH session and managing gitea authentication & authorization of the git commands. - -Note that `gitea` in the docker command above is the name of the container. If you named yours differently, don't forget to change that. The host `git` user also has to have -permission to run `docker exec`. - -**Notes** - -Docker shell passthrough using `authorized_keys` will work only if - -- `opensshd` is used in the container -- if `AuthorizedKeysCommand` is _not used_ in combination with `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` to disable authorized files key generation -- `LOCAL_ROOT_URL` is not changed (depending on the changes) - -If you try to login as the `git` user on the host in future you will `docker exec` directly to the docker. - -A Docker execing shim could be created similarly to above. - -### Docker Shell with AuthorizedKeysCommand - -The AuthorizedKeysCommand route provides another option that does not require many changes to the compose file or the `authorized_keys` - but does require changes to the host `/etc/sshd_config`. - -In this option, the idea is that the host SSH uses an `AuthorizedKeysCommand` instead of relying on sharing the `authorized_keys` file that gitea creates. We continue to use a special shell at step 8 above to exec into the docker and then run the shell there. This means that the `gitea` that is then run is the real docker `gitea`. - -- On the host create a `git` user with permission to run `docker exec`. -- We will again assume that the Gitea container is called `gitea`. -- Modify the `git` user's shell to forward commands to the `sh` executable inside the container using `docker exec`. As an administrative user on the host run: - - ```bash - cat <<"EOF" | sudo tee /home/git/docker-shell - #!/bin/sh - /usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@" - EOF - sudo chmod +x /home/git/docker-shell - sudo usermod -s /home/git/docker-shell git - ``` - -Now all attempts to login as the `git` user on the host will be forwarded to the docker - including the `SSH_ORIGINAL_COMMAND`. We now need to set-up SSH authentication on the host. - -We will do this by leveraging the [SSH AuthorizedKeysCommand](administration/command-line.md#keys) to match the keys against those accepted by Gitea. - -Add the following block to `/etc/ssh/sshd_config`, on the host: - -```bash -Match User git - AuthorizedKeysCommandUser git - AuthorizedKeysCommand /usr/bin/docker exec -i -u git gitea /usr/local/bin/gitea keys -c /data/gitea/conf/app.ini -e git -u %u -t %t -k %k -``` - -(From 1.16.0 you will not need to set the `-c /data/gitea/conf/app.ini` option.) - -Finally restart the SSH server. As an administrative user on the host run: - -```bash -sudo systemctl restart sshd -``` - -Here is a detailed explanation what is happening when a SSH request is made: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea in the container will add an entry for this key to its database. -3. The client then makes an SSH request to the host SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -4. The client will attempt to authenticate with the server, passing one or more public keys in turn to the host. -5. For each key the client provides, the host SSH server will checks its configuration for an `AuthorizedKeysCommand`. -6. The host runs the above `AuthorizedKeysCommand`, which execs in to the docker and then runs the `gitea keys` command. -7. Gitea on the docker will look in it's database to see if the public key matches and will return an entry like that of an `authorized_keys` command. -8. This entry has the public key, but also has a `command=` option which matches the location of the Gitea binary on the container. -9. The host SSH server creates a user session for the `git` user, and using the shell for the host `git` user runs the `command=`. -10. The shell of the host `git` user is now our `docker-shell` which uses `docker exec` to open a shell for the `git` user on the container. -11. The container shell now runs the `command=` option meaning that the container `gitea serv` is run, taking over control of the rest of the SSH session and managing gitea authentication & authorization of the git commands. - -**Notes** - -Docker shell passthrough using `AuthorizedKeysCommand` will work only if - -- The host `git` user is allowed to run the `docker exec` command. - -If you try to login as the `git` user on the host in future you will `docker exec` directly to the docker. - -A Docker execing shim could be created similarly to above. - -### SSH Shell with AuthorizedKeysCommand - -Create a key for the host `git` user as above, add it to the docker `/data/git/.ssh/authorized_keys` then finally create and set the `ssh-shell` as above. - -Add the following block to `/etc/ssh/sshd_config`, on the host: - -```bash -Match User git - AuthorizedKeysCommandUser git - AuthorizedKeysCommand /usr/bin/ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 /usr/local/bin/gitea keys -c /data/gitea/conf/app.ini -e git -u %u -t %t -k %k -``` - -(From 1.16.0 you will not need to set the `-c /data/gitea/conf/app.ini` option.) - -Finally restart the SSH server. As an administrative user on the host run: - -```bash -sudo systemctl restart sshd -``` - -Here is a detailed explanation what is happening when a SSH request is made: - -1. The client adds their SSH public key to Gitea using the webpage. -2. Gitea in the container will add an entry for this key to its database. -3. The client then makes an SSH request to the host SSH server using the `git` user, e.g. `git clone git@domain:user/repo.git`. -4. The client will attempt to authenticate with the server, passing one or more public keys in turn to the host. -5. For each key the client provides, the host SSH server will checks its configuration for an `AuthorizedKeysCommand`. -6. The host runs the above `AuthorizedKeysCommand`, which will SSH in to the docker and then run the `gitea keys` command. -7. Gitea on the docker will look in it's database to see if the public key matches and will return an entry like that of an `authorized_keys` command. -8. This entry has the public key, but also has a `command=` option which matches the location of the Gitea binary on the container. -9. The host SSH server creates a user session for the `git` user, and using the shell for the host `git` user runs the `command=`. -10. The shell of the host `git` user is now our `git-shell` which uses SSH to open a shell for the `git` user on the container. -11. The container shell now runs the `command=` option meaning that the container `gitea serv` is run, taking over control of the rest of the SSH session and managing gitea authentication & authorization of the git commands. - -**Notes** - -SSH container passthrough using `AuthorizedKeysCommand` will work only if - -- `opensshd` is running on the container - -If you try to login as the `git` user on the host in future you will `ssh` directly to the docker. - -Never add the `Gitea Host Key` as a SSH key to a user on the Gitea interface. - -SSHing shims could be created similarly to above. diff --git a/docs/content/installation/with-docker.zh-cn.md b/docs/content/installation/with-docker.zh-cn.md deleted file mode 100644 index fcaff1c119..0000000000 --- a/docs/content/installation/with-docker.zh-cn.md +++ /dev/null @@ -1,380 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "使用 Docker 安装" -slug: "install-with-docker" -sidebar_position: 70 -toc: false -draft: false -aliases: - - /zh-cn/install-with-docker -menu: - sidebar: - parent: "installation" - name: "使用 Docker 安装" - sidebar_position: 70 - identifier: "install-with-docker" ---- - -# 使用 Docker 安装 - -Gitea 在其 Docker Hub 组织内提供自动更新的 Docker 镜像。可以始终使用最新的稳定标签或使用其他服务来更新 Docker 镜像。 - -该参考设置指导用户完成基于 `docker-compose` 的设置,但是 `docker-compose` 的安装不在本文档的范围之内。要安装 `docker-compose` 本身,请遵循官方[安装说明](https://docs.docker.com/compose/install/)。 - -## 基本 - -最简单的设置只是创建一个卷和一个网络,然后将 `gitea/gitea:latest` 镜像作为服务启动。由于没有可用的数据库,因此可以使用 SQLite3 初始化数据库。创建一个类似 `gitea` 的目录,并将以下内容粘贴到名为 `docker-compose.yml` 的文件中。请注意,该卷应由配置文件中指定的 UID/GID 的用户/组拥有。如果您不授予卷正确的权限,则容器可能无法启动。另请注意,标签 `:latest` 将安装当前的开发版本。对于稳定的发行版,您可以使用 `:1` 或指定某个发行版,例如 `@version@`。 - -```yaml -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -``` - -## 端口 - -要将集成的 openSSH 守护进程和 Web 服务器绑定到其他端口,请调整端口部分。通常,只需更改主机端口,容器内的端口保持原样即可。 - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: -- - "3000:3000" -- - "222:22" -+ - "8080:3000" -+ - "2221:22" -``` - -## 数据库 - -### MySQL 数据库 - -要将 Gitea 与 MySQL 数据库结合使用,请将这些更改应用于上面创建的 `docker-compose.yml` 文件。 - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 -+ - GITEA__database__DB_TYPE=mysql -+ - GITEA__database__HOST=db:3306 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -+ depends_on: -+ - db -+ -+ db: -+ image: mysql:8 -+ restart: always -+ environment: -+ - MYSQL_ROOT_PASSWORD=gitea -+ - MYSQL_USER=gitea -+ - MYSQL_PASSWORD=gitea -+ - MYSQL_DATABASE=gitea -+ networks: -+ - gitea -+ volumes: -+ - ./mysql:/var/lib/mysql -``` - -### PostgreSQL 数据库 - -要将 Gitea 与 PostgreSQL 数据库结合使用,请将这些更改应用于上面创建的 `docker-compose.yml` 文件。 - -```diff -version: "3" - -networks: - gitea: - external: false - -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 -+ - GITEA__database__DB_TYPE=postgres -+ - GITEA__database__HOST=db:5432 -+ - GITEA__database__NAME=gitea -+ - GITEA__database__USER=gitea -+ - GITEA__database__PASSWD=gitea - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -+ depends_on: -+ - db -+ -+ db: -+ image: postgres:14 -+ restart: always -+ environment: -+ - POSTGRES_USER=gitea -+ - POSTGRES_PASSWORD=gitea -+ - POSTGRES_DB=gitea -+ networks: -+ - gitea -+ volumes: -+ - ./postgres:/var/lib/postgresql/data -``` - -## 命名卷 - -要使用命名卷而不是主机卷,请在 `docker-compose.yml` 配置中定义并使用命名卷。此更改将自动创建所需的卷。您无需担心命名卷的权限;Docker 将自动处理该问题。 - -```diff -version: "3" - -networks: - gitea: - external: false - -+volumes: -+ gitea: -+ driver: local -+ -services: - server: - image: gitea/gitea:@version@ - container_name: gitea - restart: always - networks: - - gitea - volumes: -- - ./gitea:/data -+ - gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" -``` - -MySQL 或 PostgreSQL 容器将需要分别创建。 - -## 启动 - -要基于 `docker-compose` 启动此设置,请执行 `docker-compose up -d`,以在后台启动 Gitea。使用 `docker-compose ps` 将显示 Gitea 是否正确启动。可以使用 `docker-compose logs` 查看日志。 - -要关闭设置,请执行 `docker-compose down`。这将停止并杀死容器。这些卷将仍然存在。 - -注意:如果在 http 上使用非 3000 端口,请更改 app.ini 以匹配 `LOCAL_ROOT_URL = http://localhost:3000/`。 - -## 安装 - -通过 `docker-compose` 启动 Docker 安装后,应该可以使用喜欢的浏览器访问 Gitea,以完成安装。访问 http://server-ip:3000 并遵循安装向导。如果数据库是通过上述 `docker-compose` 设置启动的,请注意,必须将 `db` 用作数据库主机名。 - -## 环境变量 - -您可以通过环境变量配置 Gitea 的一些设置: - -(默认值以**粗体**显示) - -- `APP_NAME`:**“Gitea: Git with a cup of tea”**:应用程序名称,在页面标题中使用。 -- `RUN_MODE`:**prod**:应用程序运行模式,会影响性能和调试。"dev","prod"或"test"。 -- `DOMAIN`:**localhost**:此服务器的域名,用于 Gitea UI 中显示的 http 克隆 URL。 -- `SSH_DOMAIN`:**localhost**:该服务器的域名,用于 Gitea UI 中显示的 ssh 克隆 URL。如果启用了安装页面,则 SSH 域服务器将采用以下形式的 DOMAIN 值(保存时将覆盖此设置)。 -- `SSH_PORT`:**22**:克隆 URL 中显示的 SSH 端口。 -- `SSH_LISTEN_PORT`:**%(SSH_PORT)s**:内置 SSH 服务器的端口。 -- `DISABLE_SSH`:**false**:如果不可用,请禁用 SSH 功能。如果要禁用 SSH 功能,则在安装 Gitea 时应将 SSH 端口设置为 `0`。 -- `HTTP_PORT`:**3000**:HTTP 监听端口。 -- `ROOT_URL`:**""**:覆盖自动生成的公共 URL。如果内部 URL 和外部 URL 不匹配(例如在 Docker 中),这很有用。 -- `LFS_START_SERVER`:**false**:启用 git-lfs 支持。 -- `DB_TYPE`:**sqlite3**:正在使用的数据库类型[mysql,postgres,mssql,sqlite3]。 -- `DB_HOST`:**localhost:3306**:数据库主机地址和端口。 -- `DB_NAME`:**gitea**:数据库名称。 -- `DB_USER`:**root**:数据库用户名。 -- `DB_PASSWD`:**"_empty_"** :数据库用户密码。如果您在密码中使用特殊字符,请使用“您的密码”进行引用。 -- `INSTALL_LOCK`:**false**:禁止访问安装页面。 -- `SECRET_KEY`:**""** :全局密钥。这应该更改。如果它具有一个值并且 `INSTALL_LOCK` 为空,则 `INSTALL_LOCK` 将自动设置为 `true`。 -- `DISABLE_REGISTRATION`:**false**:禁用注册,之后只有管理员才能为用户创建帐户。 -- `REQUIRE_SIGNIN_VIEW`:**false**:启用此选项可强制用户登录以查看任何页面。 -- `USER_UID`:**1000**:在容器内运行 Gitea 的用户的 UID(Unix 用户 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 UID 匹配(对于命名卷,则不需要这样做)。 -- `USER_GID`:**1000**:在容器内运行 Gitea 的用户的 GID(Unix 组 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 GID 匹配(对于命名卷,则不需要这样做)。 - -## 自定义 - -[此处](administration/customizing-gitea.md)描述的定制文件应放在 `/data/gitea` 目录中。如果使用主机卷,则访问这些文件非常容易;对于命名卷,可以通过另一个容器或通过直接访问 `/var/lib/docker/volumes/gitea_gitea/_data` 来完成。安装后,配置文件将保存在 `/data/gitea/conf/app.ini` 中。 - -## 升级 - -:exclamation::exclamation: **确保已将数据卷到 Docker 容器外部的某个位置** :exclamation::exclamation: - -要将安装升级到最新版本: - -```bash -# Edit `docker-compose.yml` to update the version, if you have one specified -# Pull new images -docker-compose pull -# Start a new container, automatically removes old one -docker-compose up -d -``` - -## 使用环境变量管理部署 - -除了上面的环境变量之外,`app.ini` 中的任何设置都可以使用以下形式的环境变量进行设置或覆盖:`GITEA__SECTION_NAME__KEY_NAME`。 每次 docker 容器启动时都会应用这些设置。 完整信息在[这里](https://github.com/go-gitea/gitea/tree/master/contrib/environment-to-ini)。 - -```bash -... -services: - server: - environment: - - GITEA__mailer__ENABLED=true - - GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set} - - GITEA__mailer__PROTOCOL=smtps - - GITEA__mailer__HOST=${GITEA__mailer__HOST:?GITEA__mailer__HOST not set} - - GITEA__mailer__USER=${GITEA__mailer__USER:-apikey} - - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}""" -``` - -Gitea 将为每次新安装自动生成新的 `SECRET_KEY` 并将它们写入 `app.ini`。 如果您想手动设置 `SECRET_KEY`,您可以使用以下 docker 命令来使用 Gitea 内置的[方法](administration/command-line.md#generate)生成 `SECRET_KEY`。 安装后请妥善保管您的 `SECRET_KEY`,如若丢失则无法解密已加密的数据。 - -以下命令将向 `stdout` 输出一个新的 `SECRET_KEY` 和 `INTERNAL_TOKEN`,然后您可以将其放入环境变量中。 - -```bash -docker run -it --rm gitea/gitea:1 gitea generate secret SECRET_KEY -docker run -it --rm gitea/gitea:1 gitea generate secret INTERNAL_TOKEN -``` - -```yaml -... -services: - server: - environment: - - GITEA__security__SECRET_KEY=[value returned by generate secret SECRET_KEY] - - GITEA__security__INTERNAL_TOKEN=[value returned by generate secret INTERNAL_TOKEN] -``` - -## SSH 容器直通 - -由于 SSH 在容器内运行,因此,如果需要 SSH 支持,则需要将 SSH 从主机传递到容器。一种选择是在非标准端口上运行容器 SSH(或将主机端口移至非标准端口)。另一个可能更直接的选择是将 SSH 连接从主机转发到容器。下面将说明此设置。 - -本指南假定您已经在名为 `git` 的主机上创建了一个用户,该用户与容器值 `USER_UID`/`USER_GID` 共享相同的 `UID`/`GID`。这些值可以在 `docker-compose.yml` 中设置为环境变量: - -```bash -environment: - - USER_UID=1000 - - USER_GID=1000 -``` - -接下来将主机的 `/home/git/.ssh` 装入容器。否则,SSH 身份验证将无法在容器内运行。 - -```bash -volumes: - - /home/git/.ssh/:/data/git/.ssh -``` - -现在,需要在主机上创建 SSH 密钥对。该密钥对将用于向主机验证主机上的 `git` 用户。 - -```bash -sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" -``` - -在下一步中,需要在主机上创建一个名为 `/usr/local/bin/gitea` 的文件(具有可执行权限)。该文件将发出从主机到容器的 SSH 转发。将以下内容添加到 `/usr/local/bin/gitea`: - -```bash -ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@" -``` - -为了使转发正常工作,需要将容器(22)的 SSH 端口映射到 `docker-compose.yml` 中的主机端口 2222。由于此端口不需要暴露给外界,因此可以将其映射到主机的 `localhost`: - -```bash -ports: - # [...] - - "127.0.0.1:2222:22" -``` - -另外,主机上的 `/home/git/.ssh/authorized_keys` 需要修改。它需要以与 Gitea 容器内的 `authorized_keys` 相同的方式进行操作。因此,将您在上面创建的密钥(“Gitea 主机密钥”)的公共密钥添加到 `~/git/.ssh/authorized_keys`。这可以通过 `echo "$(cat /home/git/.ssh/id_rsa.pub)" >> /home/git/.ssh/authorized_keys` 完成。重要提示:来自 `git` 用户的公钥需要“按原样”添加,而通过 Gitea 网络界面添加的所有其他公钥将以 `command="/app [...]` 作为前缀。 - -该文件应该看起来像: - -```bash -# SSH pubkey from git user -ssh-rsa <Gitea Host Key> - -# other keys from users -command="/usr/local/bin/gitea --config=/data/gitea/conf/app.ini serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty <user pubkey> -``` - -这是详细的说明,当发出 SSH 请求时会发生什么: - -1. 使用 `git` 用户向主机发出 SSH 请求,例如 `git clone git@domain:user/repo.git`。 -2. 在 `/home/git/.ssh/authorized_keys` 中,该命令执行 `/usr/local/bin/gitea` 脚本。 -3. `/usr/local/bin/gitea` 将 SSH 请求转发到端口 2222,该端口已映射到容器的 SSH 端口(22)。 -4. 由于 `/home/git/.ssh/authorized_keys` 中存在 `git` 用户的公钥,因此身份验证主机 → 容器成功,并且 SSH 请求转发到在 docker 容器中运行的 Gitea。 - -如果在 Gitea Web 界面中添加了新的 SSH 密钥,它将以与现有密钥相同的方式附加到 `.ssh/authorized_keys` 中。 - -**注意** - -SSH 容器直通仅在以下情况下有效 - -- 在容器中使用 `opensshd` -- 如果未将 `AuthorizedKeysCommand` 与 `SSH_CREATE_AUTHORIZED_KEYS_FILE = false` 结合使用以禁用授权文件密钥生成 -- `LOCAL_ROOT_URL` 不变 diff --git a/docs/content/packages.en-us.md b/docs/content/packages.en-us.md deleted file mode 100644 index 75c29033ee..0000000000 --- a/docs/content/packages.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-27T16:00:00+02:00" -title: "Packages" -slug: "packages" -sidebar_position: 35 -toc: false -draft: false -menu: - sidebar: - name: "Usage - Packages" - sidebar_position: 30 - identifier: "packages" ---- diff --git a/docs/content/search.en-us.md b/docs/content/search.en-us.md deleted file mode 100644 index 226d9fe3bc..0000000000 --- a/docs/content/search.en-us.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -date: "2019-11-12T16:00:00+02:00" -title: "Search" -slug: "search" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /en-us/help/search -sitemap: - priority : 1 -layout: "search" ---- - -This file exists solely to respond to /search URL with the related `search` layout template. - -No content shown here is rendered, all content is based in the template layouts/doc/search.html - -Setting a very low sitemap priority will tell search engines this is not important content. diff --git a/docs/content/search.nl-nl.md b/docs/content/search.nl-nl.md deleted file mode 100644 index 7ebcf28dbf..0000000000 --- a/docs/content/search.nl-nl.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -date: "2019-11-12T16:00:00+02:00" -title: "Search" -slug: "search" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /nl-nl/help/search -sitemap: - priority : 1 -layout: "search" ---- - -This file exists solely to respond to /search URL with the related `search` layout template. - -No content shown here is rendered, all content is based in the template layouts/doc/search.html - -Setting a very low sitemap priority will tell search engines this is not important content. diff --git a/docs/content/search.pt-br.md b/docs/content/search.pt-br.md deleted file mode 100644 index 06b215c689..0000000000 --- a/docs/content/search.pt-br.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -date: "2019-11-12T16:00:00+02:00" -title: "Search" -slug: "search" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /pt-br/help/search -sitemap: - priority : 1 -layout: "search" ---- - -This file exists solely to respond to /search URL with the related `search` layout template. - -No content shown here is rendered, all content is based in the template layouts/doc/search.html - -Setting a very low sitemap priority will tell search engines this is not important content. diff --git a/docs/content/search.zh-cn.md b/docs/content/search.zh-cn.md deleted file mode 100644 index 6ab5ad0814..0000000000 --- a/docs/content/search.zh-cn.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -date: "2019-11-12T16:00:00+02:00" -title: "搜索" -slug: "search" -sidebar_position: 1 -toc: false -draft: false -aliases: - - /zh-cn/help/search -sitemap: - priority : 1 -layout: "search" ---- - -This file exists solely to respond to /search URL with the related `search` layout template. - -No content shown here is rendered, all content is based in the template layouts/doc/search.html - -Setting a very low sitemap priority will tell search engines this is not important content. diff --git a/docs/content/usage.en-us.md b/docs/content/usage.en-us.md deleted file mode 100644 index 436d031b4a..0000000000 --- a/docs/content/usage.en-us.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-27T16:00:00+02:00" -title: "Usage" -slug: "usage" -sidebar_position: 35 -toc: false -draft: false -menu: - sidebar: - name: "Usage" - sidebar_position: 30 - identifier: "usage" ---- diff --git a/docs/content/usage.zh-cn.md b/docs/content/usage.zh-cn.md deleted file mode 100644 index 91e40ced9f..0000000000 --- a/docs/content/usage.zh-cn.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -date: "2016-12-27T16:00:00+02:00" -title: "使用指南" -slug: "usage" -sidebar_position: 35 -toc: false -draft: false -menu: - sidebar: - name: "使用指南" - sidebar_position: 30 - identifier: "usage" ---- diff --git a/docs/content/usage/_index.en-us.md b/docs/content/usage/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/usage/_index.en-us.md +++ /dev/null diff --git a/docs/content/usage/_index.zh-cn.md b/docs/content/usage/_index.zh-cn.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/usage/_index.zh-cn.md +++ /dev/null diff --git a/docs/content/usage/actions/act-runner.en-us.md b/docs/content/usage/actions/act-runner.en-us.md deleted file mode 100644 index 942d126919..0000000000 --- a/docs/content/usage/actions/act-runner.en-us.md +++ /dev/null @@ -1,305 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Act Runner" -slug: "act-runner" -sidebar_position: 20 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Act Runner" - sidebar_position: 20 - identifier: "actions-runner" ---- - -# Act Runner - -This page will introduce the [act runner](https://gitea.com/gitea/act_runner) in detail, which is the runner of Gitea Actions. - -## Requirements - -It is recommended to run jobs in a docker container, so you need to install docker first. -And make sure that the docker daemon is running. - -Other OCI container engines which are compatible with Docker's API should also work, but are untested. - -However, if you are sure that you want to run jobs directly on the host only, then docker is not required. - -## Installation - -There are multiple ways to install the act runner. - -### Download the binary - -You can download the binary from the [release page](https://gitea.com/gitea/act_runner/releases). -However, if you want to use the latest nightly build, you can download it from the [download page](https://dl.gitea.com/act_runner/). - -When you download the binary, please make sure that you have downloaded the correct one for your platform. -You can check it by running the following command: - -```bash -chmod +x act_runner -./act_runner --version -``` - -If you see the version information, it means that you have downloaded the correct binary. - -### Use the docker image - -You can use the docker image from the [docker hub](https://hub.docker.com/r/gitea/act_runner/tags). -Just like the binary, you can use the latest nightly build by using the `nightly` tag, while the `latest` tag is the latest stable release. - -```bash -docker pull gitea/act_runner:latest # for the latest stable release -docker pull gitea/act_runner:nightly # for the latest nightly build -``` - -## Configuration - -Configuration is done via a configuration file. It is optional, and the default configuration will be used when no configuration file is specified. - -You can generate a configuration file by running the following command: - -```bash -./act_runner generate-config -``` - -The default configuration is safe to use without any modification, so you can just use it directly. - -```bash -./act_runner generate-config > config.yaml -./act_runner --config config.yaml [command] -``` - -You could also generate config file with docker: - -```bash -docker run --entrypoint="" --rm -it gitea/act_runner:latest act_runner generate-config > config.yaml -``` - -When you are using the docker image, you can specify the configuration file by using the `CONFIG_FILE` environment variable. Make sure that the file is mounted into the container as a volume: - -```bash -docker run -v $PWD/config.yaml:/config.yaml -e CONFIG_FILE=/config.yaml ... -``` - -You may notice the commands above are both incomplete, because it is not the time to run the act runner yet. -Before running the act runner, we need to register it to your Gitea instance first. - -## Registration - -Registration is required before running the act runner, because the runner needs to know where to get jobs from. -And it is also important to Gitea instance to identify the runner. - -### Runner levels - -You can register a runner in different levels, it can be: - -- Instance level: The runner will run jobs for all repositories in the instance. -- Organization level: The runner will run jobs for all repositories in the organization. -- Repository level: The runner will run jobs for the repository it belongs to. - -Note that the repository may still use instance-level or organization-level runners even if it has its own repository-level runners. A future release may provide an option to allow more control over this. - -### Obtain a registration token - -The level of the runner determines where to obtain the registration token. - -- Instance level: The admin settings page, like `<your_gitea.com>/admin/actions/runners`. -- Organization level: The organization settings page, like `<your_gitea.com>/<org>/settings/actions/runners`. -- Repository level: The repository settings page, like `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`. - -If you cannot see the settings page, please make sure that you have the right permissions and that Actions have been enabled. - -The format of the registration token is a random string `D0gvfu2iHfUjNqCYVljVyRV14fISpJxxxxxxxxxx`. - -A registration token can also be obtained from the gitea [command-line interface](administration/command-line.md#actions-generate-runner-token): - -``` -gitea --config /etc/gitea/app.ini actions generate-runner-token -``` - -Tokens are valid for registering multiple runners, until they are revoked and replaced by a new token using the token reset link in the web interface. - -### Register the runner - -The act runner can be registered by running the following command: - -```bash -./act_runner register -``` - -Alternatively, you can use the `--config` option to specify the configuration file mentioned in the previous section. - -```bash -./act_runner --config config.yaml register -``` - -You will be asked to input the registration information step by step. Includes: - -- The Gitea instance URL, like `https://gitea.com/` or `http://192.168.8.8:3000/`. -- The registration token. -- The runner name, which is optional. If you leave it blank, the hostname will be used. -- The runner labels, which is optional. If you leave it blank, the default labels will be used. - -You may be confused about the runner labels, which will be explained later. - -If you want to register the runner in a non-interactive way, you can use arguments to do it. - -```bash -./act_runner register --no-interactive --instance <instance_url> --token <registration_token> --name <runner_name> --labels <runner_labels> -``` - -When you have registered the runner, you can find a new file named `.runner` in the current directory. -This file stores the registration information. -Please do not edit it manually. -If this file is missing or corrupted, you can simply remove it and register again. - -If you want to store the registration information in another place, you can specify it in the configuration file, -and don't forget to specify the `--config` option. - -### Register the runner with docker - -If you are using the docker image, behaviour will be slightly different. Registration and running are combined into one step in this case, so you need to specify the registration information when running the act runner. - -```bash -docker run \ - -v $PWD/config.yaml:/config.yaml \ - -v $PWD/data:/data \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -e CONFIG_FILE=/config.yaml \ - -e GITEA_INSTANCE_URL=<instance_url> \ - -e GITEA_RUNNER_REGISTRATION_TOKEN=<registration_token> \ - -e GITEA_RUNNER_NAME=<runner_name> \ - -e GITEA_RUNNER_LABELS=<runner_labels> \ - --name my_runner \ - -d gitea/act_runner:nightly -``` - -You may notice that we have mounted the `/var/run/docker.sock` into the container. -It is because the act runner will run jobs in docker containers, so it needs to communicate with the docker daemon. -As mentioned, you can remove it if you want to run jobs in the host directly. -To be clear, the "host" actually means the container which is running the act runner now, instead of the host machine. - -### Set up the runner using docker compose - -You could also set up the runner using the following `docker-compose.yml`: - -```yml -version: "3.8" -services: - runner: - image: gitea/act_runner:nightly - environment: - CONFIG_FILE: /config.yaml - GITEA_INSTANCE_URL: "${INSTANCE_URL}" - GITEA_RUNNER_REGISTRATION_TOKEN: "${REGISTRATION_TOKEN}" - GITEA_RUNNER_NAME: "${RUNNER_NAME}" - GITEA_RUNNER_LABELS: "${RUNNER_LABELS}" - volumes: - - ./config.yaml:/config.yaml - - ./data:/data - - /var/run/docker.sock:/var/run/docker.sock -``` - -### Configuring cache when starting a Runner using docker image - -If you do not intend to use `actions/cache` in workflow, you can ignore this section. - -If you use `actions/cache` without any additional configuration, it will return the following error: -> Failed to restore: getCacheEntry failed: connect ETIMEDOUT IP:PORT - -The error occurs because the runner container and job container are on different networks, so the job container cannot access the runner container. - -Therefore, it is essential to configure the cache action to ensure its proper functioning. Follow these steps: - -- 1.Obtain the LAN IP address of the host machine where the runner container is running. -- 2.Find an available port number on the host machine where the runner container is running. -- 3.Configure the following settings in the configuration file: - -```yaml -cache: - enabled: true - dir: "" - # Use the LAN IP obtained in step 1 - host: "192.168.8.17" - # Use the port number obtained in step 2 - port: 8088 -``` - -- 4.When starting the container, map the cache port to the host machine: - -```bash -docker run \ - --name gitea-docker-runner \ - -p 8088:8088 \ - -d gitea/act_runner:nightly -``` - -### Labels - -The labels of a runner are used to determine which jobs the runner can run, and how to run them. - -The default labels are `ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster`. -It is a comma-separated list, and each item is a label. - -Let's take `ubuntu-22.04:docker://node:16-bullseye` as an example. -It means that the runner can run jobs with `runs-on: ubuntu-22.04`, and the job will be run in a docker container with the image `node:16-bullseye`. - -If the default image is insufficient for your needs, and you have enough disk space to use a better and bigger one, you can change it to `ubuntu-22.04:docker://<the image you like>`. -You can find more useful images on [act images](https://github.com/nektos/act/blob/master/IMAGES.md). - -If you want to run jobs in the host directly, you can change it to `ubuntu-22.04:host` or just `ubuntu-22.04`, the `:host` is optional. -However, we suggest you to use a special name like `linux_amd64:host` or `windows:host` to avoid misusing it. - -Starting with Gitea 1.21, you can change labels by modifying `container.labels` in the runner configuration file (if you don't have a configuration file, please refer to [configuration tutorials](#configuration)). -The runner will use these new labels as soon as you restart it, i.e., by calling `./act_runner daemon --config config.yaml`. - -## Running - -After you have registered the runner, you can run it by running the following command: - -```bash -./act_runner daemon -# or -./act_runner daemon --config config.yaml -``` - -The runner will fetch jobs from the Gitea instance and run them automatically. - -Since act runner is still in development, it is recommended to check the latest version and upgrade it regularly. - -## Systemd service - -It is also possible to run act-runner as a [systemd](https://en.wikipedia.org/wiki/Systemd) service. Create an unprivileged `act_runner` user on your system, and the following file in `/etc/systemd/system/act_runner.service`. The paths in `ExecStart` and `WorkingDirectory` may need to be adjusted depending on where you installed the `act_runner` binary, its configuration file, and the home directory of the `act_runner` user. - -```ini -[Unit] -Description=Gitea Actions runner -Documentation=https://gitea.com/gitea/act_runner -After=docker.service - -[Service] -ExecStart=/usr/local/bin/act_runner daemon --config /etc/act_runner/config.yaml -ExecReload=/bin/kill -s HUP $MAINPID -WorkingDirectory=/var/lib/act_runner -TimeoutSec=0 -RestartSec=10 -Restart=always -User=act_runner - -[Install] -WantedBy=multi-user.target -``` - -Then: - -```bash -# load the new systemd unit file -sudo systemctl daemon-reload -# start the service and enable it at boot -sudo systemctl enable act_runner --now -``` - -If using Docker, the `act_runner` user should also be added to the `docker` group before starting the service. Keep in mind that this effectively gives `act_runner` root access to the system [[1]](https://docs.docker.com/engine/security/#docker-daemon-attack-surface). diff --git a/docs/content/usage/actions/act-runner.zh-cn.md b/docs/content/usage/actions/act-runner.zh-cn.md deleted file mode 100644 index e5ebff976d..0000000000 --- a/docs/content/usage/actions/act-runner.zh-cn.md +++ /dev/null @@ -1,260 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "Act Runner" -slug: "act-runner" -sidebar_position: 20 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Act Runner" - sidebar_position: 20 - identifier: "actions-runner" ---- - -# Act Runner - -本页面将详细介绍[Act Runner](https://gitea.com/gitea/act_runner),这是Gitea Actions的Runner。 - -## 要求 - -建议在Docker容器中运行Job,因此您需要首先安装Docker。 -并确保Docker守护进程正在运行。 - -其他与Docker API兼容的OCI容器引擎也应该可以正常工作,但尚未经过测试。 - -但是,如果您确定要直接在主机上运行Job,则不需要Docker。 - -## 安装 - -有多种安装Act Runner的方法。 - -### 下载二进制文件 - -您可以从[发布页面](https://gitea.com/gitea/act_runner/releases)下载二进制文件。 -然而,如果您想使用最新的夜间构建版本,可以从[下载页面](https://dl.gitea.com/act_runner/)下载。 - -下载二进制文件时,请确保您已经下载了适用于您的平台的正确版本。 -您可以通过运行以下命令进行检查: - -```bash -chmod +x act_runner -./act_runner --version -``` - -如果看到版本信息,则表示您已经下载了正确的二进制文件。 - -### 使用 Docker 镜像 - -您可以使用[docker hub](https://hub.docker.com/r/gitea/act_runner/tags)上的Docker镜像。 -与二进制文件类似,您可以使用`nightly`标签使用最新的夜间构建版本,而`latest`标签是最新的稳定版本。 - -```bash -docker pull gitea/act_runner:latest # for the latest stable release -docker pull gitea/act_runner:nightly # for the latest nightly build -``` - -## 配置 - -配置通过配置文件进行。它是可选的,当没有指定配置文件时,将使用默认配置。 - -您可以通过运行以下命令生成配置文件: - -```bash -./act_runner generate-config -``` - -默认配置是安全的,可以直接使用。 - -```bash -./act_runner generate-config > config.yaml -./act_runner --config config.yaml [command] -``` - -您亦可以如下使用 docker 创建配置文件: - -```bash -docker run --entrypoint="" --rm -it gitea/act_runner:latest act_runner generate-config > config.yaml -``` - -当使用Docker镜像时,可以使用`CONFIG_FILE`环境变量指定配置文件。确保将文件作为卷挂载到容器中: - -```bash -docker run -v $(pwd)/config.yaml:/config.yaml -e CONFIG_FILE=/config.yaml ... -``` - -您可能注意到上面的命令都是不完整的,因为现在还不是运行Act Runner的时候。 -在运行Act Runner之前,我们需要首先将其注册到您的Gitea实例中。 - -## 注册 - -在运行Act Runner之前,需要进行注册,因为Runner需要知道从哪里获取Job,并且对于Gitea实例来说,识别Runner也很重要。 - -### Runner级别 - -您可以在不同级别上注册Runner,它可以是: - -- 实例级别:Runner将为实例中的所有存储库运行Job。 -- 组织级别:Runner将为组织中的所有存储库运行Job。 -- 存储库级别:Runner将为其所属的存储库运行Job。 - -请注意,即使存储库具有自己的存储库级别Runner,它仍然可以使用实例级别或组织级别Runner。未来的版本可能提供更多对此进行更好控制的选项。 - -### 获取注册令牌 - -Runner级别决定了从哪里获取注册令牌。 - -- 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/actions/runners`。 -- 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/actions/runners`。 -- 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`。 - -如果您无法看到设置页面,请确保您具有正确的权限并且已启用 Actions。 - -注册令牌的格式是一个随机字符串 `D0gvfu2iHfUjNqCYVljVyRV14fISpJxxxxxxxxxx`。 - -注册令牌也可以通过 Gitea 的 [命令行](administration/command-line.md#actions-generate-runner-token) 获得: - -### 注册Runner - -可以通过运行以下命令来注册Act Runner: - -```bash -./act_runner register -``` - -或者,您可以使用 `--config` 选项来指定前面部分提到的配置文件。 - -```bash -./act_runner --config config.yaml register -``` - -您将逐步输入注册信息,包括: - -- Gitea 实例的 URL,例如 `https://gitea.com/` 或 `http://192.168.8.8:3000/`。 -- 注册令牌。 -- Runner名称(可选)。如果留空,将使用主机名。 -- Runner标签(可选)。如果留空,将使用默认标签。 - -您可能对Runner标签感到困惑,稍后将对其进行解释。 - -如果您想以非交互方式注册Runner,可以使用参数执行以下操作。 - -```bash -./act_runner register --no-interactive --instance <instance_url> --token <registration_token> --name <runner_name> --labels <runner_labels> -``` - -注册Runner后,您可以在当前目录中找到一个名为 `.runner` 的新文件。该文件存储注册信息。 -请不要手动编辑该文件。 -如果此文件丢失或损坏,可以直接删除它并重新注册。 - -如果您想将注册信息存储在其他位置,请在配置文件中指定,并不要忘记指定 `--config` 选项。 - -### 使用Docker注册Runner - -如果您使用的是Docker镜像,注册行为会略有不同。在这种情况下,注册和运行合并为一步,因此您需要在运行Act Runner时指定注册信息。 - -```bash -docker run \ - -v $(pwd)/config.yaml:/config.yaml \ - -v $(pwd)/data:/data \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -e CONFIG_FILE=/config.yaml \ - -e GITEA_INSTANCE_URL=<instance_url> \ - -e GITEA_RUNNER_REGISTRATION_TOKEN=<registration_token> \ - -e GITEA_RUNNER_NAME=<runner_name> \ - -e GITEA_RUNNER_LABELS=<runner_labels> \ - --name my_runner \ - -d gitea/act_runner:nightly -``` - -您可能注意到我们已将`/var/run/docker.sock`挂载到容器中。 -这是因为Act Runner将在Docker容器中运行Job,因此它需要与Docker守护进程进行通信。 -如前所述,如果要在主机上直接运行Job,可以将其移除。 -需要明确的是,这里的 "主机" 实际上指的是当前运行 Act Runner的容器,而不是主机机器本身。 - -### 使用 Docker compose 运行 Runner - -您亦可使用如下的 `docker-compose.yml`: - -```yml -version: "3.8" -services: - runner: - image: gitea/act_runner:nightly - environment: - CONFIG_FILE: /config.yaml - GITEA_INSTANCE_URL: "${INSTANCE_URL}" - GITEA_RUNNER_REGISTRATION_TOKEN: "${REGISTRATION_TOKEN}" - GITEA_RUNNER_NAME: "${RUNNER_NAME}" - GITEA_RUNNER_LABELS: "${RUNNER_LABELS}" - volumes: - - ./config.yaml:/config.yaml - - ./data:/data - - /var/run/docker.sock:/var/run/docker.sock -``` - -### 当您使用 Docker 镜像启动 Runner,如何配置 Cache - -如果你不打算在工作流中使用 `actions/cache`,你可以忽略本段。 - -如果您在使用 `actions/cache` 时没有进行额外的配置,将会返回以下错误信息: -> Failed to restore: getCacheEntry failed: connect ETIMEDOUT IP:PORT - -这个错误的原因是 runner 容器和作业容器位于不同的网络中,因此作业容器无法访问 runner 容器。 -因此,配置 cache 动作以确保其正常运行是非常重要的。请按照以下步骤操作: - -- 1.获取 Runner 容器所在主机的 LAN(本地局域网) IP 地址。 -- 2.获取一个 Runner 容器所在主机的空闲端口号。 -- 3.在配置文件中如下配置: - -```yaml -cache: - enabled: true - dir: "" - # 使用步骤 1. 获取的 LAN IP - host: "192.168.8.17" - # 使用步骤 2. 获取的端口号 - port: 8088 -``` - -- 4.启动容器时, 将 Cache 端口映射至主机。 - -```bash -docker run \ - --name gitea-docker-runner \ - -p 8088:8088 \ - -d gitea/act_runner:nightly -``` - -### 标签 - -Runner的标签用于确定Runner可以运行哪些Job以及如何运行它们。 - -默认标签为`ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster`。 -它们是逗号分隔的列表,每个项目都是一个标签。 - -让我们以 `ubuntu-22.04:docker://node:16-bullseye` 为例。 -它意味着Runner可以运行带有`runs-on: ubuntu-22.04`的Job,并且该Job将在使用`node:16-bullseye`镜像的Docker容器中运行。 - -如果默认镜像无法满足您的需求,并且您有足够的磁盘空间可以使用更好、更大的镜像,您可以将其更改为`ubuntu-22.04:docker://<您喜欢的镜像>`。 -您可以在[act 镜像](https://github.com/nektos/act/blob/master/IMAGES.md)上找到更多有用的镜像。 - -如果您想直接在主机上运行Job,您可以将其更改为`ubuntu-22.04:host`或仅`ubuntu-22.04`,`:host`是可选的。 -然而,我们建议您使用类似`linux_amd64:host`或`windows:host`的特殊名称,以避免误用。 - -从 Gitea 1.21 开始,您可以通过修改 runner 的配置文件中的 `container.labels` 来更改标签(如果没有配置文件,请参考 [配置教程](#配置)),通过执行 `./act_runner daemon --config config.yaml` 命令重启 runner 之后,这些新定义的标签就会生效。 - -## 运行 - -注册完Runner后,您可以通过运行以下命令来运行它: - -```bash -./act_runner daemon -# or -./act_runner daemon --config config.yaml -``` - -Runner将从Gitea实例获取Job并自动运行它们。 - -由于Act Runner仍处于开发中,建议定期检查最新版本并进行升级。 diff --git a/docs/content/usage/actions/badge.en-us.md b/docs/content/usage/actions/badge.en-us.md deleted file mode 100644 index 57e5d9d3a1..0000000000 --- a/docs/content/usage/actions/badge.en-us.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -date: "2023-02-25T00:00:00+00:00" -title: "Badge" -slug: "badge" -sidebar_position: 11 -toc: false -draft: false -menu: - sidebar: - parent: "actions" - name: "Badge" - sidebar_position: 11 - identifier: "Badge" ---- - -# Badge - -Gitea has its builtin Badge system which allows you to display the status of your repository in other places. You can use the following badges: - -## Workflow Badge - -The Gitea Actions workflow badge is a badge that shows the status of the latest workflow run. -It is designed to be compatible with [GitHub Actions workflow badge](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge). - -You can use the following URL to get the badge: - -``` -https://your-gitea-instance.com/{owner}/{repo}/actions/workflows/{workflow_file}/badge.svg?branch={branch}&event={event} -``` - -- `{owner}`: The owner of the repository. -- `{repo}`: The name of the repository. -- `{workflow_file}`: The name of the workflow file. -- `{branch}`: Optional. The branch of the workflow. Default to your repository's default branch. -- `{event}`: Optional. The event of the workflow. Default to none. diff --git a/docs/content/usage/actions/comparison.en-us.md b/docs/content/usage/actions/comparison.en-us.md deleted file mode 100644 index 5b084e09c4..0000000000 --- a/docs/content/usage/actions/comparison.en-us.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Compared to GitHub Actions" -slug: "comparison" -sidebar_position: 30 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Comparison" - sidebar_position: 30 - identifier: "actions-comparison" ---- - -# Compared to GitHub Actions - -Even though Gitea Actions is designed to be compatible with GitHub Actions, there are some differences between them. - -## Additional features - -### Absolute action URLs - -Gitea Actions supports defining actions via absolute URL, which means that you can use actions from any git repository. -Like `uses: https://github.com/actions/checkout@v4` or `uses: http://your_gitea.com/owner/repo@branch`. - -### Actions written in Go - -Gitea Actions supports writing actions in Go. -See [Creating Go Actions](https://blog.gitea.com/creating-go-actions/). - -### Support the non-standard syntax @yearly, @monthly, @weekly, @daily, @hourly on schedule - -Github Actions doesn't support that. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule - -## Unsupported workflows syntax - -### `concurrency` - -It's used to run a single job at a time. -See [Using concurrency](https://docs.github.com/en/actions/using-jobs/using-concurrency). - -It's ignored by Gitea Actions now. - -### `run-name` - -The name for workflow runs generated from the workflow. -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#run-name). - -It's ignored by Gitea Actions now. - -### `permissions` and `jobs.<job_id>.permissions` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions). - -It's ignored by Gitea Actions now. - -### `jobs.<job_id>.timeout-minutes` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes). - -It's ignored by Gitea Actions now. - -### `jobs.<job_id>.continue-on-error` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error). - -It's ignored by Gitea Actions now. - -### `jobs.<job_id>.environment` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenvironment). - -It's ignored by Gitea Actions now. - -### Complex `runs-on` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on). - -Gitea Actions only supports `runs-on: xyz` or `runs-on: [xyz]` now. - -### `workflow_dispatch` - -See [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch). - -It's ignored by Gitea Actions now. - -### `hashFiles` expression - -See [Expressions](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) - -Gitea Actions doesn't support it now, if you use it, the result will always be empty string. - -As a workaround, you can use [go-hashfiles](https://gitea.com/actions/go-hashfiles) instead. - -## Missing features - -### Problem Matchers - -Problem Matchers are a way to scan the output of actions for a specified regex pattern and surface that information prominently in the UI. -See [Problem matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md). - -It's ignored by Gitea Actions now. - -### Create an error annotation - -See [Creating an annotation for an error](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-creating-an-annotation-for-an-error) - -It's ignored by Gitea Actions now. - -### Expressions - -For [expressions](https://docs.github.com/en/actions/learn-github-actions/expressions), only [`always()`](https://docs.github.com/en/actions/learn-github-actions/expressions#always) is supported. - -## Missing UI features - -### Pre and Post steps - -Pre and Post steps don't have their own section in the job log user interface. - -### Services steps - -Services steps don't have their own section in the job log user interface. - -## Different behavior - -### Downloading actions - -Previously (Pre 1.21.0), `[actions].DEFAULT_ACTIONS_URL` defaulted to `https://gitea.com`. -We have since restricted this option to only allow two values (`github` and `self`). -When set to `github`, the new default, Gitea will download non-fully-qualified actions from `https://github.com`. -For example, if you use `uses: actions/checkout@v4`, it will download the checkout repository from `https://github.com/actions/checkout.git`. - -If you want to download an action from another git hoster, you can use an absolute URL, e.g. `uses: https://gitea.com/actions/checkout@v4`. - -If your Gitea instance is in an intranet or a restricted area, you can set the URL to `self` to only download actions from your own instance by default. -Of course, you can still use absolute URLs in workflows. - -More details about the `[actions].DEFAULT_ACTIONS_URL` configuration can be found in the [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions)。 - -### Context availability - -Context availability is not checked, so you can use the env context on more places. -See [Context availability](https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability). diff --git a/docs/content/usage/actions/comparison.zh-cn.md b/docs/content/usage/actions/comparison.zh-cn.md deleted file mode 100644 index 79450e8eab..0000000000 --- a/docs/content/usage/actions/comparison.zh-cn.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "与GitHub Actions的对比" -slug: "comparison" -sidebar_position: 30 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "对比" - sidebar_position: 30 - identifier: "actions-comparison" ---- - -# 与GitHub Actions的对比 - -尽管Gitea Actions旨在与GitHub Actions兼容,但它们之间存在一些差异。 - -## 额外功能 - -### Action URL绝对路径 - -Gitea Actions支持通过URL绝对路径定义actions,这意味着您可以使用来自任何Git存储库的Actions。 -例如,`uses: https://github.com/actions/checkout@v4`或`uses: http://your_gitea.com/owner/repo@branch`。 - -### 使用Go编写Actions - -Gitea Actions支持使用Go编写Actions。 -请参阅[创建Go Actions](https://blog.gitea.com/creating-go-actions/)。 - -### 支持非标准的调度语法 @yearly, @monthly, @weekly, @daily, @hourly - -Github Actions 不支持这些语法,详见: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule - -## 不支持的工作流语法 - -### `concurrency` - -这是用于一次运行一个Job。 -请参阅[使用并发](https://docs.github.com/zh/actions/using-jobs/using-concurrency)。 - -Gitea Actions目前不支持此功能。 - -### `run-name` - -这是工作流生成的工作流运行的名称。 -请参阅[GitHub Actions 的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#run-name)。 - -Gitea Actions目前不支持此功能。 - -### `permissions`和`jobs.<job_id>.permissions` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#permissions)。 - -Gitea Actions目前不支持此功能。 - -### `jobs.<job_id>.timeout-minutes` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes)。 - -Gitea Actions目前不支持此功能。 - -### `jobs.<job_id>.continue-on-error` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error)。 - -Gitea Actions目前不支持此功能。 - -### `jobs.<job_id>.environment` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenvironment)。 - -Gitea Actions 目前不支持此功能。 - -### 复杂的`runs-on` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)。 - -Gitea Actions目前只支持`runs-on: xyz`或`runs-on: [xyz]`。 - -### `workflow_dispatch` - -请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch)。 - -Gitea Actions目前不支持此功能。 - -### `hashFiles`表达式 - -请参阅[表达式](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles)。 - -Gitea Actions目前不支持此功能,如果使用它,结果将始终为空字符串。 - -作为解决方法,您可以使用[go-hashfiles](https://gitea.com/actions/go-hashfiles)。 - -## 缺失的功能 - -### 问题匹配器 - -问题匹配器是一种扫描Actions输出以查找指定正则表达式模式并在用户界面中突出显示该信息的方法。 -请参阅[问题匹配器](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md)。 - -Gitea Actions目前不支持此功能。 - -### 为错误创建注释 - -请参阅[为错误创建注释](https://docs.github.com/zh/actions/using-workflows/workflow-commands-for-github-actions#example-creating-an-annotation-for-an-error)。 - -Gitea Actions目前不支持此功能。 - -### 表达式 - -对于 [表达式](https://docs.github.com/en/actions/learn-github-actions/expressions), 当前仅 [`always()`](https://docs.github.com/en/actions/learn-github-actions/expressions#always) 被支持。 - -## 缺失的UI功能 - -### 预处理和后处理步骤 - -预处理和后处理步骤在Job日志用户界面中没有自己的用户界面。 - -### 服务步骤 - -服务步骤在Job日志用户界面中没有自己的用户界面。 - -## 不一样的行为 - -### 下载Actions - -当 `[actions].DEFAULT_ACTIONS_URL` 保持默认值为 `github` 时,Gitea将会从 https://github.com 下载相对路径的actions。比如: -如果你使用 `uses: actions/checkout@v4`,Gitea将会从 https://github.com/actions/checkout.git 下载这个 actions 项目。 -如果你想要从另外一个 Git服务下载actions,你只需要使用绝对URL `uses: https://gitea.com/actions/checkout@v4` 来下载。 - -如果你的 Gitea 实例是部署在一个互联网限制的网络中,也可以使用绝对地址来下载 actions。你也可以将配置项修改为 `[actions].DEFAULT_ACTIONS_URL = self`。这样所有的相对路径的actions引用,将不再会从 github.com 去下载,而会从这个 Gitea 实例自己的仓库中去下载。例如: `uses: actions/checkout@v4` 将会从 `[server].ROOT_URL`/actions/checkout.git 这个地址去下载 actions。 - -设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单](administration/config-cheat-sheet.md#actions-actions)。 - -### 上下文可用性 - -不检查上下文可用性,因此您可以在更多地方使用env上下文。 -请参阅[上下文可用性](https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability)。 diff --git a/docs/content/usage/actions/design.en-us.md b/docs/content/usage/actions/design.en-us.md deleted file mode 100644 index 0d72c19dce..0000000000 --- a/docs/content/usage/actions/design.en-us.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Design of Gitea Actions" -slug: "design" -sidebar_position: 40 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Design" - sidebar_position: 40 - identifier: "actions-design" ---- - -# Design of Gitea Actions - -Gitea Actions has multiple components. This document describes them individually. - -## Act - -The [nektos/act](https://github.com/nektos/act) project is an excellent tool that allows you to run your GitHub Actions locally. -We were inspired by this and wondered if it would be possible to run actions for Gitea. - -However, while [nektos/act](https://github.com/nektos/act) is designed as a command line tool, what we actually needed was a Go library with modifications specifically for Gitea. -So we forked it as [gitea/act](https://gitea.com/gitea/act). - -This is a soft fork that will periodically follow the upstream. -Although some custom commits have been added, we will try our best to avoid changing too much of the original code. - -The forked act is just a shim or adapter for Gitea's specific usage. -There are some additional commits that have been made, such as: - -- Outputting execution logs to logger hook so they can be reported to Gitea -- Disabling the GraphQL URL, since Gitea doesn't support it -- Starting a new container for every job instead of reusing to ensure isolation. - -These modifications have no reason to be merged into the upstream. -They don't make sense if the user just wants to run trusted actions locally. - -However, there may be overlaps in the future, such as a required bug fix or new feature needed by both projects. -In these cases, we will contribute the changes back to the upstream repository. - -## Act runner - -Gitea's runner is called act runner because it's based on act. - -Like other CI runners, we designed it as an external part of Gitea, which means it should run on a different server than Gitea. - -To ensure that the runner connects to the correct Gitea instance, we need to register it with a token. -Additionally, the runner will introduce itself to Gitea and declare what kind of jobs it can run by reporting its labels. - -Earlier, we mentioned that `runs-on: ubuntu-latest` in a workflow file means that the job will be run on a runner with the `ubuntu-latest` label. -But how does the runner know to run `ubuntu-latest`? The answer lies in mapping the label to an environment. -That's why when you add custom labels during registration, you will need to input some complex content like `my_custom_label:docker://centos:7`. -This means that the runner can take the job which needs to run on `my_custom_label`, and it will run it via a docker container with the image `centos:7`. - -Docker isn't the only option, though. -The act also supports running jobs directly on the host. -This is achieved through labels like `linux_arm:host`. -This label indicates that the runner can take a job that needs to run on `linux_arm` and run it directly on the host. - -The label's design follows the format `label[:schema[:args]]`. -If the schema is omitted, it defaults to `host`. -So, - -- `my_custom_label:docker://node:18`: Run jobs labeled with `my_custom_label` using the `node:18` Docker image. -- `my_custom_label:host`: Run jobs labeled with `my_custom_label` directly on the host. -- `my_custom_label`: Same as `my_custom_label:host`. -- `my_custom_label:vm:ubuntu-latest`: (Example only, not implemented) Run jobs labeled with `my_custom_label` using a virtual machine with the `ubuntu-latest` ISO. - -## Communication protocol - -As act runner is an independent part of Gitea, we needed a protocol for runners to communicate with the Gitea instance. -However, we did not think it was a good idea to have Gitea listen on a new port. -Instead, we wanted to reuse the HTTP port, which means we needed a protocol that is compatible with HTTP. -We chose to use gRPC over HTTP. - -We use [actions-proto-def](https://gitea.com/gitea/actions-proto-def) and [actions-proto-go](https://gitea.com/gitea/actions-proto-go) to wire them up. -More information about gRPC can be found on [its website](https://grpc.io/). - -## Network architecture - -Let's examine the overall network architecture. -This will help you troubleshoot some problems and explain why it's a bad idea to register a runner with a loopback address of the Gitea instance. - -![network](/images/usage/actions/network.png) - -There are four network connections marked in the picture, and the direction of the arrows indicates the direction of establishing the connections. - -### Connection 1, act runner to Gitea instance - -The act runner must be able to connect to Gitea to receive tasks and send back the execution results. - -### Connection 2, job containers to Gitea instance - -The job containers have different network namespaces than the runner, even if they are on the same machine. -They need to connect to Gitea to fetch codes if there is `actions/checkout@v4` in the workflow, for example. -Fetching code is not always necessary to run some jobs, but it is required in most cases. - -If you use a loopback address to register a runner, the runner can connect to Gitea when it is on the same machine. -However, if a job container tries to fetch code from localhost, it will fail because Gitea is not in the same container. - -### Connection 3, act runner to internet - -When you use some actions like `actions/checkout@v4`, the act runner downloads the scripts, not the job containers. -By default, it downloads from [github.com](http://github.com/), so it requires access to the internet. If you configure the `DEFAULT_ACTIONS_URL` to `self`, then it will download from your Gitea instance by default. Then it will not connect to internet when downloading the action itself. -It also downloads some docker images from Docker Hub by default, which also requires internet access. - -However, internet access is not strictly necessary. -You can configure your Gitea instance to fetch actions or images from your intranet facilities. - -In fact, your Gitea instance can serve as both the actions marketplace and the image registry. -You can mirror actions repositories from GitHub to your Gitea instance, and use them as normal. -And [Gitea Container Registry](usage/packages/container.md) can be used as a Docker image registry. - -### Connection 4, job containers to internet - -When using actions such as `actions/setup-go@v5`, it may be necessary to download resources from the internet to set up the Go language environment in job containers. -Therefore, access to the internet is required for the successful completion of these actions. - -However, it is optional as well. -You can use your own custom actions to avoid relying on internet access, or you can use your packaged Docker image to run jobs with all dependencies installed. - -## Summary - -Using Gitea Actions only requires ensuring that the runner can connect to the Gitea instance. -Internet access is optional, but not having it will require some additional work. -In other words: The runner works best when it can query the internet itself, but you don't need to expose it to the internet (in either direction). - -If you encounter any network issues while using Gitea Actions, hopefully the image above can help you troubleshoot them. diff --git a/docs/content/usage/actions/design.zh-cn.md b/docs/content/usage/actions/design.zh-cn.md deleted file mode 100644 index f48576477f..0000000000 --- a/docs/content/usage/actions/design.zh-cn.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "Gitea Actions设计" -slug: "design" -sidebar_position: 40 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "设计" - sidebar_position: 40 - identifier: "actions-design" ---- - -# Gitea Actions设计 - -Gitea Actions由多个组件组成。本文档将对它们进行逐个描述。 - -## Act - -[nektos/act](https://github.com/nektos/act) 项目是一个优秀的工具,允许你在本地运行GitHub Actions。 -我们受到了它的启发,并思考它是否可能为Gitea运行Actions。 - -然而,尽管[nektos/act](https://github.com/nektos/act)被设计为一个命令行工具,但我们实际上需要的是一个专为Gitea修改的Go库。 -因此,我们在[gitea/act](https://gitea.com/gitea/act)基础上进行了分叉。 - -这是一个软分叉,将定期跟进上游。 -虽然添加了一些自定义提交,但我们会尽力避免对原始代码进行太多更改。 - -分叉的 act 只是Gitea特定用途的桥接或适配器。 -还添加了一些额外的提交,例如: - -- 将执行日志输出到日志记录器钩子,以便报告给Gitea -- 禁用 GraphQL URL,因为Gitea不支持它 -- 每个Job启动一个新的容器,而不是重复使用,以确保隔离性。 - -这些修改没有理由合并到上游。 -如果用户只想在本地运行可信的Actions,它们是没有意义的。 - -然而,将来可能会出现重叠,例如两个项目都需要的必要错误修复或新功能。 -在这些情况下,我们将向上游仓库贡献变更。 - -## act runner - -Gitea的Runner被称为act runner,因为它基于act。 - -与其他CIRunner一样,我们将其设计为Gitea的外部部分,这意味着它应该在与Gitea不同的服务器上运行。 - -为了确保Runner连接到正确的Gitea实例,我们需要使用令牌注册它。 -此外,Runner通过声明自己的标签向Gitea报告它可以运行的Job类型。 - -之前,我们提到工作流文件中的 `runs-on: ubuntu-latest` 表示该Job将在具有`ubuntu-latest`标签的Runner上运行。 -但是,Runner如何知道要运行 `ubuntu-latest`?答案在于将标签映射到环境。 -这就是为什么在注册过程中添加自定义标签时,需要输入一些复杂内容,比如`my_custom_label:docker://centos:7`。 -这意味着Runner可以接受需要在`my_custom_label`上运行的Job,并通过使用`centos:7`镜像的Docker容器来运行它。 - -然而,Docker不是唯一的选择。 -act 也支持直接在主机上运行Job。 -这是通过像`linux_arm:host`这样的标签实现的。 -这个标签表示Runner可以接受需要在`linux_arm`上运行的Job,并直接在主机上运行它们。 - -标签的设计遵循格式`label[:schema[:args]]`。 -如果省略了schema,则默认为`host`。 - -因此, - -- `my_custom_label:docker://node:18`:使用`node:18 Docker`镜像运行带有`my_custom_label`标签的Job。 -- `my_custom_label:host`:在主机上直接运行带有`my_custom_label`标签的Job。 -- `my_custom_label`:等同于`my_custom_label:host`。 -- `my_custom_label:vm:ubuntu-latest`:(仅为示例,未实现)使用带有`ubuntu-latest` ISO的虚拟机运行带有`my_custom_label`标签的Job。 - -## 通信协议 - -由于act runner是Gitea的独立部分,我们需要一种协议让Runner与Gitea实例进行通信。 -然而,我们不认为让Gitea监听一个新端口是个好主意。 -相反,我们希望重用HTTP端口,这意味着我们需要一个与HTTP兼容的协议。 -因此,我们选择使用基于HTTP的gRPC。 - -我们使用[actions-proto-def](https://gitea.com/gitea/actions-proto-def) 和 [actions-proto-go](https://gitea.com/gitea/actions-proto-go) 进行连接。 -有关 gRPC 的更多信息,请访问[其官方网站](https://grpc.io/)。 - -## 网络架构 - -让我们来看一下整体的网络架构。 -这将帮助您解决一些问题,并解释为什么使用回环地址注册Runner是个不好的主意。 - -![network](/images/usage/actions/network.png) - -图片中标记了四个网络连接,并且箭头的方向表示建立连接的方向。 - -### 连接 1,act runner到Gitea实例 - -act runner 必须能够连接到Gitea以接收任务并发送执行结果回来。 - -### 连接 2,Job容器到Gitea实例 - -即使Job容器位于同一台机器上,它们的网络命名空间与Runner不同。 -举个例子,如果工作流中包含 `actions/checkout@v4`,Job容器需要连接到Gitea来获取代码。 -获取代码并不总是运行某些Job所必需的,但在大多数情况下是必需的。 - -如果您使用回环地址注册Runner,当Runner与Gitea在同一台机器上时,Runner可以连接到Gitea。 -然而,如果Job容器尝试从本地主机获取代码,它将失败,因为Gitea不在同一个容器中。 - -### 连接 3,act runner到互联网 - -当您使用诸如 `actions/checkout@v4` 的一些Actions时,act runner下载的是脚本,而不是Job容器。 -默认情况下,它从[github.com](http://github.com/)下载,因此需要访问互联网。如果您设置的是 self, -那么默认将从您的当前Gitea实例下载,那么此步骤不需要连接到互联网。 -它还默认从Docker Hub下载一些Docker镜像,这也需要互联网访问。 - -然而,互联网访问并不是绝对必需的。 -您可以配置您的Gitea实例从您的内部网络设施中获取 Actions 或镜像。 - -实际上,您的Gitea实例可以同时充当 Actions 市场和镜像注册表。 -您可以将GitHub上的Actions仓库镜像到您的Gitea实例,并将其用作普通Actions。 -而 [Gitea 容器注册表](usage/packages/container.md) 可用作Docker镜像注册表。 - -### 连接 4,Job容器到互联网 - -当使用诸如`actions/setup-go@v5`的Actions时,可能需要从互联网下载资源,以设置Job容器中的Go语言环境。 -因此,成功完成这些Actions需要访问互联网。 - -然而,这也是可选的。 -您可以使用自定义的Actions来避免依赖互联网访问,或者可以使用已安装所有依赖项的打包的Docker镜像来运行Job。 - -## 总结 - -使用Gitea Actions只需要确保Runner能够连接到Gitea实例。 -互联网访问是可选的,但如果没有互联网访问,将需要额外的工作。 -换句话说:当Runner能够自行查询互联网时,它的工作效果最好,但您不需要将其暴露给互联网(无论是单向还是双向)。 - -如果您在使用Gitea Actions时遇到任何网络问题,希望上面的图片能够帮助您进行故障排除。 diff --git a/docs/content/usage/actions/faq.en-us.md b/docs/content/usage/actions/faq.en-us.md deleted file mode 100644 index 427d57c43e..0000000000 --- a/docs/content/usage/actions/faq.en-us.md +++ /dev/null @@ -1,184 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Frequently Asked Questions of Gitea Actions" -slug: "faq" -sidebar_position: 100 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "FAQ" - sidebar_position: 100 - identifier: "actions-faq" ---- - -# Frequently Asked Questions of Gitea Actions - -This page contains some common questions and answers about Gitea Actions. - -## Why is Actions not enabled by default? - -We know it's annoying to enable Actions for the whole instance and each repository one by one, but not everyone likes or needs this feature. -We believe that more work needs to be done to improve Gitea Actions before it deserves any further special treatment. - -## Is it possible to enable Actions for new repositories by default for my own instance? - -Yes, when you enable Actions for the instance, you can choose to enable the `actions` unit for all new repositories by default. - -```ini -[repository] -DEFAULT_REPO_UNITS = ...,repo.actions -``` - -## Should we use `${{ github.xyz }}` or `${{ gitea.xyz }}` in workflow files? - -You can use `github.xyz` and Gitea will work fine. -As mentioned, Gitea Actions is designed to be compatible with GitHub Actions. -However, we recommend using `gitea.xyz` in case Gitea adds something that GitHub does not have to avoid different kinds of secrets in your workflow file (and because you are using this workflow on Gitea, not GitHub). -Still, this is completely optional since both options have the same effect at the moment. - -## Is it possible to register runners for a specific user (not organization)? - -Not yet. -It is technically possible to implement, but we need to discuss whether it is necessary. - -## Where will the runner download scripts when using actions such as `actions/checkout@v4`? - -There are tens of thousands of [actions scripts](https://github.com/marketplace?type=actions) in GitHub, and when you write `uses: actions/checkout@v4`, it downloads the scripts from [github.com/actions/checkout](http://github.com/actions/checkout) by default. -But what if you want to use actions from other places such as gitea.com instead of GitHub? - -The good news is that you can specify the URL prefix to use actions from anywhere. -This is an extra syntax in Gitea Actions. -For example: - -- `uses: https://gitea.com/xxx/xxx@xxx` -- `uses: https://github.com/xxx/xxx@xxx` -- `uses: http://your_gitea_instance.com/xxx@xxx` - -Be careful, the `https://` or `http://` prefix is necessary! - -This is one of the differences from GitHub Actions which supports actions scripts only from GitHub. -But it should allow users much more flexibility in how they run Actions. - -Alternatively, if you want your runners to download actions from your own Gitea instance by default, you can configure it by setting `[actions].DEFAULT_ACTIONS_URL`. -See [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions). - -## How to limit the permission of the runners? - -Runners have no more permissions than simply connecting to your Gitea instance. -When any runner receives a job to run, it will temporarily gain limited permission to the repository associated with the job. -If you want to give more permissions to the runner, allowing it to access more private repositories or external systems, you can pass [secrets](usage/secrets.md) to it. - -Refined permission control to Actions is a complicated job. -In the future, we will add more options to Gitea to make it more configurable, such as allowing more write access to repositories or read access to all repositories in the same organization. - -## How to avoid being hacked? - -There are two types of possible attacks: unknown runner stealing the code or secrets from your repository, or malicious scripts controlling your runner. - -Avoiding the former means not allowing people you don't know to register runners for your repository, organization, or instance. - -The latter is a bit more complicated. -If you're using a private Gitea instance for your company, you may not need to worry about security since you trust your colleagues and can hold them accountable. - -For public instances, things are a little different. -Here's how we do it on [gitea.com](http://gitea.com/): - -- We only register runners for the "gitea" organization, so our runners will not execute jobs from other repositories. -- Our runners always run jobs with isolated containers. While it is possible to do this directly on the host, we choose not to for more security. -- To run actions for fork pull requests, approval is required. See [#22803](https://github.com/go-gitea/gitea/pull/22803). -- If someone registers their own runner for their repository or organization on [gitea.com](http://gitea.com/), we have no objections and will just not use it in our org. However, they should take care to ensure that the runner is not used by other users they do not know. - -## Which operating systems are supported by act runner? - -It works well on Linux, macOS, and Windows. -While other operating systems are theoretically supported, they require further testing. - -One thing to note is that if you choose to run jobs directly on the host instead of in job containers, the environmental differences between operating systems may cause unexpected failures. - -For example, bash is not available on Windows in most cases, while act tries to use bash to run scripts by default. -Therefore, you need to specify `powershell` as the default shell in your workflow file, see [defaults.run](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun). - -```yaml -defaults: - run: - shell: powershell -``` - -## Why choose GitHub Actions? Why not something compatible with GitLab CI/CD? - -[@lunny](https://gitea.com/lunny) has explained this in the [issue to implement actions](https://github.com/go-gitea/gitea/issues/13539). -Furthermore, Actions is not only a CI/CD system but also an automation tool. - -There have also been numerous [marketplace actions](https://github.com/marketplace?type=actions) implemented in the open-source world. -It is exciting to be able to reuse them. - -## What if it runs on multiple labels, such as `runs-on: [label_a, label_b]`? - -This is valid syntax. -It means that it should run on runners that have both the `label_a` **and** `label_b` labels, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on). -Unfortunately, act runner does not work this way. -As mentioned, we map labels to environments: - -- `ubuntu` → `ubuntu:22.04` -- `centos` → `centos:8` - -But we need to map label groups to environments instead, like so: - -- `[ubuntu]` → `ubuntu:22.04` -- `[with-gpu]` → `linux:with-gpu` -- `[ubuntu, with-gpu]` → `ubuntu:22.04_with-gpu` - -We also need to re-design how tasks are assigned to runners. -A runner with `ubuntu`, `centos`, or `with-gpu` does not necessarily indicate that it can accept jobs with `[centos, with-gpu]`. -Therefore, the runner should inform the Gitea instance that it can only accept jobs with `[ubuntu]`, `[centos]`, `[with-gpu]`, and `[ubuntu, with-gpu]`. -This is not a technical problem, it was just overlooked in the early design. -See [runtime.go#L65](https://gitea.com/gitea/act_runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L65). - -Currently, the act runner attempts to match everyone in the labels and uses the first match it finds. - -## What is the difference between agent labels and custom labels for a runner? - -![labels](/images/usage/actions/labels.png) - -Agent labels are reported to the Gitea instance by the runner during registration. -Custom labels, on the other hand, are added manually by a Gitea administrator or owners of the organization or repository (depending on the level of the runner). - -However, the design here needs improvement, as it currently has some rough edges. -You can add a custom label such as `centos` to a registered runner, which means the runner will receive jobs with `runs-on: centos`. -However, the runner may not know which environment to use for this label, resulting in it using a default image or leading to a logical dead end. -This default may not match user expectations. -See [runtime.go#L71](https://gitea.com/gitea/act_runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L71). - -In the meantime, we suggest that you re-register your runner if you want to change its labels. - -## Will there be more implementations for Gitea Actions runner? - -Although we would like to provide more options, our limited manpower means that act runner will be the only officially supported runner. -However, both Gitea and act runner are completely open source, so anyone can create a new/better implementation. -We support your choice, no matter how you decide. -In case you fork act runner to create your own version: Please contribute the changes back if you can and if you think your changes will help others as well. - -## What workflow trigger events does Gitea support? - -All events listed in this table are supported events and are compatible with GitHub. -For events supported only by GitHub, see GitHub's [documentation](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows). - -| trigger event | activity types | -|-----------------------------|--------------------------------------------------------------------------------------------------------------------------| -| create | not applicable | -| delete | not applicable | -| fork | not applicable | -| gollum | not applicable | -| push | not applicable | -| issues | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `milestoned`, `demilestoned`, `labeled`, `unlabeled` | -| issue_comment | `created`, `edited`, `deleted` | -| pull_request | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `synchronize`, `labeled`, `unlabeled` | -| pull_request_review | `submitted`, `edited` | -| pull_request_review_comment | `created`, `edited` | -| release | `published`, `edited` | -| registry_package | `published` | - -> For `pull_request` events, in [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request), the `ref` is `refs/pull/:prNumber/merge`, which is a reference to the merge commit preview. However, Gitea has no such reference. -> Therefore, the `ref` in Gitea Actions is `refs/pull/:prNumber/head`, which points to the head of pull request rather than the preview of the merge commit. diff --git a/docs/content/usage/actions/faq.zh-cn.md b/docs/content/usage/actions/faq.zh-cn.md deleted file mode 100644 index d6e1466801..0000000000 --- a/docs/content/usage/actions/faq.zh-cn.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "Gitea Actions常见问题解答" -slug: "faq" -sidebar_position: 100 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "常见问题" - sidebar_position: 100 - identifier: "actions-faq" ---- - -# Gitea Actions常见问题解答 - -本页面包含一些关于Gitea Actions的常见问题和答案。 - -## 为什么默认情况下不启用Actions? - -我们知道为整个实例和每个仓库启用Actions可能很麻烦,但并不是每个人都喜欢或需要此功能。 -在我们认为Gitea Actions值得被特别对待之前,我们认为还需要做更多的工作来改进它。 - -## 是否可以在我的实例中默认启用新仓库的Actions? - -是的,当您为实例启用Actions时,您可以选择默认启用actions单元以适用于所有新仓库。 - -```ini -[repository] -DEFAULT_REPO_UNITS = ...,repo.actions -``` - -## 在工作流文件中应该使用`${{ github.xyz }}`还是`${{ gitea.xyz }}`? - -您可以使用`github.xyz`,Gitea将正常工作。 -如前所述,Gitea Actions的设计是与GitHub Actions兼容的。 -然而,我们建议在工作流文件中使用`gitea.xyz`,以防止在工作流文件中出现不同类型的密钥(因为您在Gitea上使用此工作流,而不是GitHub)。 -不过,这完全是可选的,因为目前这两个选项的效果是相同的。 - -## 是否可以为特定用户(而不是组织)注册Runner? - -目前还不可以。 -从技术上讲是可以实现的,但我们需要讨论是否有必要。 - -## 使用`actions/checkout@v4`等Actions时,Job容器会从何处下载脚本? - -GitHub 上有成千上万个 [Actions 脚本](https://github.com/marketplace?type=actions)。 -当您编写 `uses: actions/checkout@v4` 时,它默认会从 [github.com/actions/checkout](https://github.com/actions/checkout) 下载脚本。 -那如果您想使用一些托管在其它平台上的脚本呢,比如在 gitea.com 上的? - -好消息是,您可以指定要从任何位置使用Actions的URL前缀。 -这是Gitea Actions中的额外语法。 -例如: - -- `uses: https://gitea.com/xxx/xxx@xxx` -- `uses: https://github.com/xxx/xxx@xxx` -- `uses: http://your_gitea_instance.com/xxx@xxx` - -注意,`https://`或`http://`前缀是必需的! - -这是与 GitHub Actions 的一个区别,GitHub Actions 只允许使用托管在 GitHub 上的 actions 脚本。 -但用户理应拥有权利去灵活决定如何运行 Actions。 - -另外,如果您希望您的 Runner 默认从您自己的 Gitea 实例下载 Actions,可以通过设置 `[actions].DEFAULT_ACTIONS_URL`进行配置。 -参见[配置速查表](administration/config-cheat-sheet.md#actions-actions)。 - -## 如何限制Runner的权限? - -Runner仅具有连接到您的Gitea实例的权限。 -当任何Runner接收到要运行的Job时,它将临时获得与Job关联的仓库的有限权限。 -如果您想为Runner提供更多权限,允许它访问更多私有仓库或外部系统,您可以向其传递[密钥](usage/secrets.md)。 - -对于 Actions 的细粒度权限控制是一项复杂的工作。 -在未来,我们将添加更多选项以使Gitea更可配置,例如允许对仓库进行更多写访问或对同一组织中的所有仓库进行读访问。 - -## 如何避免被黑客攻击? - -有两种可能的攻击类型:未知的Runner窃取您的仓库中的代码或密钥,或恶意脚本控制您的Runner。 - -避免前者意味着不允许您不认识的人为您的仓库、组织或实例注册Runner。 - -后者要复杂一些。 -如果您为公司使用私有的Gitea实例,您可能不需要担心安全问题,因为您信任您的同事,并且可以追究他们的责任。 - -对于公共实例,情况略有不同。 -以下是我们在 [gitea.com](http://gitea.com/)上的做法: - -- 我们仅为 "gitea" 组织注册Runner,因此我们的Runner不会执行来自其他仓库的Job。 -- 我们的Runner始终在隔离容器中运行Job。虽然可以直接在主机上进行这样的操作,但出于安全考虑,我们选择不这样做。 -- 对于 fork 的拉取请求,需要获得批准才能运行Actions。参见[#22803](https://github.com/go-gitea/gitea/pull/22803)。 -- 如果有人在[gitea.com](http://gitea.com/)为其仓库或组织注册自己的Runner,我们不会反对,只是不会在我们的组织中使用它。然而,他们应该注意确保该Runner不被他们不认识的其他用户使用。 - -## act runner支持哪些操作系统? - -它在Linux、macOS和Windows上运行良好。 -虽然理论上支持其他操作系统,但需要进一步测试。 - -需要注意的一点是,如果选择直接在主机上运行Job而不是在Job容器中运行,操作系统之间的环境差异可能会导致意外的失败。 - -例如,在大多数情况下,Windows上没有可用的bash,而act尝试默认使用bash运行脚本。 -因此,您需要在工作流文件中将默认shell指定为`powershell`,参考[defaults.run](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun)。 - -```yaml -defaults: - run: - shell: powershell -``` - -## 为什么选择GitHub Actions?为什么不选择与GitLab CI/CD兼容的工具? - -[@lunny](https://gitea.com/lunny)在实现Actions的[问题](https://github.com/go-gitea/gitea/issues/13539)中已经解释过这个问题。 -此外,Actions不仅是一个CI/CD 系统,还是一个自动化工具。 - -在开源世界中,已经有许多[市场上的Actions](https://github.com/marketplace?type=actions)实现了。 -能够重用它们是令人兴奋的。 - -## 如果它在多个标签上运行,例如 `runs-on: [label_a, label_b]`,会发生什么? - -这是有效的语法。 -它意味着它应该在具有`label_a` **和** `label_b`标签的Runner上运行,参考[GitHub Actions的工作流语法](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)。 -不幸的是,act runner 并不支持这种方式。 -如上所述,我们将标签映射到环境: - -- `ubuntu` → `ubuntu:22.04` -- `centos` → `centos:8` - -但我们需要将标签组映射到环境,例如: - -- `[ubuntu]` → `ubuntu:22.04` -- `[with-gpu]` → `linux:with-gpu` -- `[ubuntu, with-gpu]` → `ubuntu:22.04_with-gpu` - -我们还需要重新设计任务分配给Runner的方式。 -具有`ubuntu`、`centos`或`with-gpu`的Runner并不一定表示它可以接受`[centos, with-gpu]`的Job。 -因此,Runner应该通知Gitea实例它只能接受具有 `[ubuntu]`、`[centos]`、`[with-gpu]` 和 `[ubuntu, with-gpu]`的Job。 -这不是一个技术问题,只是在早期设计中被忽视了。 -参见[runtime.go#L65](https://gitea.com/gitea/act_runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L65)。 - -目前,act runner尝试匹配标签中的每一个,并使用找到的第一个匹配项。 - -## 代理标签和自定义标签对于Runner有什么区别? - -![labels](/images/usage/actions/labels.png) - -代理标签是由Runner在注册过程中向Gitea实例报告的。 -而自定义标签则是由Gitea的管理员或组织或仓库的所有者手动添加的(取决于Runner所属的级别)。 - -然而,目前这方面的设计还有待改进,因为它目前存在一些不完善之处。 -您可以向已注册的Runner添加自定义标签,比如 `centos`,这意味着该Runner将接收具有`runs-on: centos`的Job。 -然而,Runner可能不知道要使用哪个环境来执行该标签,导致它使用默认镜像或导致逻辑死胡同。 -这个默认值可能与用户的期望不符。 -参见[runtime.go#L71](https://gitea.com/gitea/act_runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L71)。 - -与此同时,如果您想更改Runner的标签,我们建议您重新注册Runner。 - -## Gitea Actions runner会有更多的实现吗? - -虽然我们希望提供更多的选择,但由于我们有限的人力资源,act runner将是唯一受支持的官方Runner。 -然而,无论您如何决定,Gitea 和act runner都是完全开源的,所以任何人都可以创建一个新的/更好的实现。 -我们支持您的选择,无论您如何决定。 -如果您选择分支act runner来创建自己的版本,请在您认为您的更改对其他人也有帮助的情况下贡献这些更改。 - -## Gitea 支持哪些工作流触发事件? - -表格中列出的所有事件都是支持的,并且与 GitHub 兼容。 -对于仅 GitHub 支持的事件,请参阅 GitHub 的[文档](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)。 - -| 触发事件 | 活动类型 | -|-----------------------------|--------------------------------------------------------------------------------------------------------------------------| -| create | 不适用 | -| delete | 不适用 | -| fork | 不适用 | -| gollum | 不适用 | -| push | 不适用 | -| issues | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `milestoned`, `demilestoned`, `labeled`, `unlabeled` | -| issue_comment | `created`, `edited`, `deleted` | -| pull_request | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `synchronize`, `labeled`, `unlabeled` | -| pull_request_review | `submitted`, `edited` | -| pull_request_review_comment | `created`, `edited` | -| release | `published`, `edited` | -| registry_package | `published` | - -> 对于 `pull_request` 事件,在 [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) 中 `ref` 是 `refs/pull/:prNumber/merge`,它指向这个拉取请求合并提交的一个预览。但是 Gitea 没有这种 reference。 -> 因此,Gitea Actions 中 `ref` 是 `refs/pull/:prNumber/head`,它指向这个拉取请求的头分支而不是合并提交的预览。 diff --git a/docs/content/usage/actions/overview.en-us.md b/docs/content/usage/actions/overview.en-us.md deleted file mode 100644 index 135fdfd433..0000000000 --- a/docs/content/usage/actions/overview.en-us.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Gitea Actions" -slug: "overview" -sidebar_position: 1 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Overview" - sidebar_position: 1 - identifier: "actions-overview" ---- - -# Gitea Actions - -Starting with Gitea **1.19**, Gitea Actions are available as a built-in CI/CD solution. - -## Name - -It is similar and compatible to [GitHub Actions](https://github.com/features/actions), and its name is inspired by it too. -To avoid confusion, we have clarified the spelling here: - -- "Gitea Actions" (with an "s", both words capitalized) is the name of the Gitea feature. -- "GitHub Actions" is the name of the GitHub feature. -- "Actions" could refer to either of the above, depending on the context. So it refers to "Gitea Actions" in this document. -- "action" or "actions" refer to some scripts/plugins to be used, like "actions/checkout@v4" or "actions/cache@v3". - -## Runners - -Just like other CI/CD solutions, Gitea doesn't run the jobs itself, but delegates the jobs to runners. -The runner of Gitea Actions is called [act runner](https://gitea.com/gitea/act_runner), it is a standalone program and also written in Go. -It is based on a [fork](https://gitea.com/gitea/act) of [nektos/act](http://github.com/nektos/act). - -Because the runner is deployed independently, there could be potential security issues. -To avoid them, please follow two simple rules: - -- Don't use a runner you don't trust for your repository, organization or instance. -- Don't provide a runner to a repository, organization or instance you don't trust. - -For Gitea instances used internally, such as instances used by enterprises or individuals, neither of these two rules is a problem, they are naturally so. -However, for public Gitea instances, such as [gitea.com](https://gitea.com), these two rules should be kept in mind when adding or using runners. - -## Status - -Gitea Actions is still under development, so there may be some bugs and missing features. -And breaking changes may be made before it's stable (v1.20 or later). - -If the situation changes, we will update it here. -So please refer to the content here when you find outdated articles elsewhere. diff --git a/docs/content/usage/actions/overview.zh-cn.md b/docs/content/usage/actions/overview.zh-cn.md deleted file mode 100644 index a2ec3070bc..0000000000 --- a/docs/content/usage/actions/overview.zh-cn.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "Gitea Actions" -slug: "overview" -sidebar_position: 1 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Overview" - sidebar_position: 1 - identifier: "actions-overview" ---- - -# Gitea Actions - -从Gitea **1.19**版本开始,Gitea Actions成为了内置的CI/CD解决方案。 - -## 名称 - -Gitea Actions与[GitHub Actions](https://github.com/features/actions)相似且兼容,它的名称也受到了它的启发。 -为了避免混淆,在这里我们明确了拼写方式: - -- "Gitea Actions"(两个单词都大写且带有"s")是Gitea功能的名称。 -- "GitHub Actions"是GitHub功能的名称。 -- "Actions"根据上下文的不同可以指代以上任意一个。在本文档中指代的是"Gitea Actions"。 -- "action"或"actions"指代一些要使用的脚本/插件,比如"actions/checkout@v4"或"actions/cache@v3"。 - -## Runner - -和其他CI/CD解决方案一样,Gitea不会自己运行Job,而是将Job委托给Runner。 -Gitea Actions的Runner被称为[act runner](https://gitea.com/gitea/act_runner),它是一个独立的程序,也是用Go语言编写的。 -它是基于[nektos/act](http://github.com/nektos/act)的一个[分支](https://gitea.com/gitea/act) 。 - -由于Runner是独立部署的,可能存在潜在的安全问题。 -为了避免这些问题,请遵循两个简单的规则: - -- 不要为你的仓库、组织或实例使用你不信任的Runner。 -- 不要为你不信任的仓库、组织或实例提供Runner。 - -对于内部使用的Gitea实例,比如企业或个人使用的实例,这两个规则不是问题,它们自然而然就是如此。 -然而,对于公共的Gitea实例,比如[gitea.com](https://gitea.com),在添加或使用Runner时应当牢记这两个规则。 - -## 状态 - -Gitea Actions仍然在开发中,因此可能存在一些错误和缺失的功能。 -并且在稳定版本(v1.20或更高版本)之前可能会进行一些重大的更改。 - -如果情况发生变化,我们将在此处进行更新。 -因此,请在其他地方找到过时文章时参考此处的内容。 diff --git a/docs/content/usage/actions/quickstart.en-us.md b/docs/content/usage/actions/quickstart.en-us.md deleted file mode 100644 index 0514b6ddf2..0000000000 --- a/docs/content/usage/actions/quickstart.en-us.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -date: "2023-04-27T15:00:00+08:00" -title: "Quick Start" -slug: "quickstart" -sidebar_position: 10 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Quick Start" - sidebar_position: 10 - identifier: "actions-quickstart" ---- - -# Quick Start - -This page will guide you through the process of using Gitea Actions. - -## Set up Gitea - -First of all, you need a Gitea instance. -You can follow the [documentation](installation/from-package.md) to set up a new instance or upgrade your existing one. -It doesn't matter how you install or run Gitea, as long as its version is 1.19.0 or higher. - -Since 1.21.0, Actions are enabled by default. If you are using versions before 1.21.0, you need to add the following to the configuration file to enable it: - -```ini -[actions] -ENABLED=true -``` - -If you want to learn more or encounter any problems while configuring it, please refer to the [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions). - -### Set up runner - -Gitea Actions requires [act runner](https://gitea.com/gitea/act_runner) to run the jobs. -In order to avoid consuming too many resources and affecting the Gitea instance, it is recommended to start runners on separate machines from the Gitea instance. - -You can use the [pre-built binaries](http://dl.gitea.com/act_runner) or the [docker images](https://hub.docker.com/r/gitea/act_runner/tags) to set up the runner. - -Before proceeding any further, we suggest running it as a command line with pre-built binaries to ensure that it works with your environment, especially if you are running a runner on your local host. -And it could be easier to debug if something goes wrong. - -The runner can run the jobs in isolated Docker containers, so you need to make sure that the Docker has been installed and Docker daemon is running. -While it is not strictly necessary, because the runner can also run the jobs directly on the host, it depends on how you configure it. -However, it is recommended to use Docker to run the jobs, because it is more secure and easier to manage. - -Before running a runner, you should first register it to your Gitea instance using the following command: - -```bash -./act_runner register --no-interactive --instance <instance> --token <token> -``` - -There are two arguments required, `instance` and `token`. - -`instance` refers to the address of your Gitea instance, like `http://192.168.8.8:3000` or `https://gitea.com`. -The runner and job containers (which are started by the runner to execute jobs) will connect to this address. -This means that it could be different from the `ROOT_URL` of your Gitea instance, which is configured for web access. -It is always a bad idea to use a loopback address such as `127.0.0.1` or `localhost`. -If you are unsure which address to use, the LAN address is usually the right choice. - -`token` is used for authentication and identification, such as `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`. -Each token can be used to create multiple runners, until it is replaced with a new token using the reset link. -You can obtain different levels of 'tokens' from the following places to create the corresponding level of 'runners': - -- Instance level: The admin settings page, like `<your_gitea.com>/admin/actions/runners`. -- Organization level: The organization settings page, like `<your_gitea.com>/<org>/settings/actions/runners`. -- Repository level: The repository settings page, like `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`. - -![register runner](/images/usage/actions/register-runner.png) - -After registering, a new file named `.runner` will appear in the current directory. -This file stores the registration information. -Please do not edit it manually. -If this file is missing or corrupted, you can simply remove it and register again. - -Finally, it's time to start the runner: - -```bash -./act_runner daemon -``` - -And you can see the new runner in the management page: - -![view runner](/images/usage/actions/view-runner.png) - -You can find more information by visiting [Act runner](usage/actions/act-runner.md). - -### Use Actions - -Even if Actions is enabled for the Gitea instance, repositories still disable Actions by default. - -To enable it, go to the settings page of your repository like `your_gitea.com/<owner>/repo/settings` and enable `Enable Repository Actions`. - -![enable actions](/images/usage/actions/enable-actions.png) - -The next steps may be rather complicated. -You will need to study [the workflow syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) for Actions and write the workflow files you want. - -However, we can just start from a simple demo: - -```yaml -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] - -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." -``` - -You can upload it as a file with the extension `.yaml` in the directory `.gitea/workflows/` of the repository, for example `.gitea/workflows/demo.yaml`. -You might notice that this is fairly similar from the [Quickstart for GitHub Actions](https://docs.github.com/en/actions/quickstart). -That is because Gitea Actions is designed to be compatible with GitHub Actions wherever possible. - -Be careful, the demo file contains some emojis. -Please make sure your database supports them, especially when using MySQL. -If the charset is not `utf8mb4`, errors will occur, such as `Error 1366 (HY000): Incorrect string value: '\\xF0\\x9F\\x8E\\x89 T...' for column 'name' at row 1`. -See [Database Preparation](installation/database-preparation.md#mysql) for more information. - -Alternatively, you can remove all emojis from the demo file and try again. - -The line `on: [push]` indicates that the workflow will be triggered when you push commits to this repository. -However, when you upload the YAML file, it also pushes a commit, so you should see a new task in the Actions tab. - -![view job](/images/usage/actions/view-job.png) - -Great job! You have successfully started working with Actions. diff --git a/docs/content/usage/actions/quickstart.zh-cn.md b/docs/content/usage/actions/quickstart.zh-cn.md deleted file mode 100644 index 8fccc6c909..0000000000 --- a/docs/content/usage/actions/quickstart.zh-cn.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -date: "2023-05-24T15:00:00+08:00" -title: "快速入门" -slug: "quickstart" -sidebar_position: 10 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "快速入门" - sidebar_position: 10 - identifier: "actions-quickstart" ---- - -# 快速入门 - -本页面将指导您使用Gitea Actions的过程。 - -## 设置Gitea - -首先,您需要一个Gitea实例。 -您可以按照[文档](installation/from-package.md) 来设置一个新实例或升级现有实例。 -无论您如何安装或运行Gitea,只要版本号是1.19.0或更高即可。 - -从1.21.0开始,默认情况下,Actions是启用的。如果您正在使用1.21.0之前的版本,您需要将以下内容添加到配置文件中以启用它: - -```ini -[actions] -ENABLED=true -``` - -如果您想了解更多信息或在配置过程中遇到任何问题,请参考[配置速查表](administration/config-cheat-sheet.md#actions-actions)。 - -### 设置Runner - -Gitea Actions需要[act runner](https://gitea.com/gitea/act_runner) 来运行Job。 -为了避免消耗过多资源并影响Gitea实例,建议您在与Gitea实例分开的机器上启动Runner。 - -您可以使用[预构建的二进制文件](http://dl.gitea.com/act_runner)或[容器镜像](https://hub.docker.com/r/gitea/act_runner/tags)来设置Runner。 - -在进一步操作之前,建议您先使用预构建的二进制文件以命令行方式运行它,以确保它与您的环境兼容,尤其是如果您在本地主机上运行Runner。 -如果出现问题,这样调试起来会更容易。 - -该Runner可以在隔离的Docker容器中运行Job,因此您需要确保已安装Docker并且Docker守护进程正在运行。 -虽然这不是严格必需的,因为Runner也可以直接在主机上运行Job,这取决于您的配置方式。 -然而,建议使用Docker运行Job,因为它更安全且更易于管理。 - -在运行Runner之前,您需要使用以下命令将其注册到Gitea实例中: - -```bash -./act_runner register --no-interactive --instance <instance> --token <token> -``` - -需要两个必需的参数:`instance` 和 `token`。 - -`instance`是您的Gitea实例的地址,如`http://192.168.8.8:3000`或`https://gitea.com`。 -Runner和Job容器(由Runner启动以执行Job)将连接到此地址。 -这意味着它可能与用于Web访问的`ROOT_URL`不同。 -使用回环地址(例如 `127.0.0.1` 或 `localhost`)是一个不好的选择。 -如果不确定使用哪个地址,通常选择局域网地址即可。 - -`token` 用于身份验证和标识,例如 `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`。 -它只能使用一次,并且不能用于注册多个Runner。 -您可以从以下位置获取不同级别的`token`,从而创建出相应级别的`runner` - -- 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/actions/runners`。 -- 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/actions/runners`。 -- 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`。 - -![register runner](/images/usage/actions/register-runner.png) - -注册后,当前目录中将出现一个名为 `.runner` 的新文件,该文件存储了注册信息。 -请不要手动编辑该文件。 -如果该文件丢失或损坏,只需删除它然后重新注册即可。 - -最后,是时候启动Runner了: - -```bash -./act_runner daemon -``` - -您可以在管理页面上看到新的Runner: - -![view runner](/images/usage/actions/view-runner.png) - -您可以通过访问[act runner](usage/actions/act-runner.md) 获取更多信息。 - -### 使用Actions - -即使对于启用了Gitea实例的Actions,存储库仍默认禁用Actions。 - -要启用它,请转到存储库的设置页面,例如`your_gitea.com/<owner>/repo/settings`,然后启用`Enable Repository Actions`。 - -![enable actions](/images/usage/actions/enable-actions.png) - -接下来的步骤可能相当复杂。 -您需要学习Actions的[工作流语法](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions),并编写您想要的工作流文件。 - -不过,我们可以从一个简单的演示开始: - -```yaml -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] - -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." -``` - -您可以将上述示例上传为一个以`.yaml`扩展名的文件,放在存储库的`.gitea/workflows/`目录中,例如`.gitea/workflows/demo.yaml`。 -您可能会注意到,这与[GitHub Actions的快速入门](https://docs.github.com/en/actions/quickstart)非常相似。 -这是因为Gitea Actions在尽可能兼容GitHub Actions的基础上进行设计。 - -请注意,演示文件中包含一些表情符号。 -请确保您的数据库支持它们,特别是在使用MySQL时。 -如果字符集不是`utf8mb4`,将出现错误,例如`Error 1366 (HY000): Incorrect string value: '\\xF0\\x9F\\x8E\\x89 T...' for column 'name' at row 1`。 -有关更多信息,请参阅[数据库准备工作](installation/database-preparation.md#mysql)。 - -或者,您可以从演示文件中删除所有表情符号,然后再尝试一次。 - -`on: [push]` 这一行表示当您向该存储库推送提交时,工作流将被触发。 -然而,当您上传 YAML 文件时,它也会推送一个提交,所以您应该在"Actions"标签中看到一个新的任务。 - -![view job](/images/usage/actions/view-job.png) - -做得好!您已成功开始使用Actions。 diff --git a/docs/content/usage/actions/secrets.en-us.md b/docs/content/usage/actions/secrets.en-us.md deleted file mode 100644 index 5bf1f1a1e8..0000000000 --- a/docs/content/usage/actions/secrets.en-us.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -date: "2022-12-19T21:26:00+08:00" -title: "Secrets" -slug: "secrets" -sidebar_position: 50 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Secrets" - sidebar_position: 50 - identifier: "usage-secrets" ---- - -# Secrets - -Secrets allow you to store sensitive information in your user, organization or repository. -Secrets are available on Gitea 1.19+ and are only visible in 1.20+ when ACTIONS are enabled. - -# Naming your secrets - -The following rules apply to secret names: - -- Secret names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed. - -- Secret names must not start with the `GITHUB_` and `GITEA_` prefix. - -- Secret names must not start with a number. - -- Secret names are not case-sensitive. - -- Secret names must be unique at the level they are created at. - -For example, a secret created at the repository level must have a unique name in that repository, and a secret created at the organization level must have a unique name at that level. - -If a secret with the same name exists at multiple levels, the secret at the lowest level takes precedence. For example, if an organization-level secret has the same name as a repository-level secret, then the repository-level secret takes precedence. diff --git a/docs/content/usage/actions/secrets.zh-cn.md b/docs/content/usage/actions/secrets.zh-cn.md deleted file mode 100644 index 939042f0a8..0000000000 --- a/docs/content/usage/actions/secrets.zh-cn.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "密钥管理" -slug: "secrets" -sidebar_position: 50 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "密钥管理" - sidebar_position: 50 - identifier: "usage-secrets" ---- - -# 密钥管理 - -密钥管理允许您在用户、组织或仓库中存储敏感信息。 -密钥管理在 Gitea 1.19+ 版本中可用。 - -# 设置密钥名称 - -以下规则适用于密钥名称: - -- 密钥名称只能包含字母数字字符 (`[a-z]`, `[A-Z]`, `[0-9]`) 或下划线 (`_`)。不允许使用空格。 - -- 密钥名称不能以 `GITHUB_` 和 `GITEA_` 前缀开头。 - -- 密钥名称不能以数字开头。 - -- 密钥名称不区分大小写。 - -- 密钥名称在创建它们的级别上必须是唯一的。 - -例如,对于在仓库级别创建的密钥,它在该仓库中必须具有唯一的名称;对于在组织级别创建的密钥,它在该级别上必须具有唯一的名称。 - -如果在多个级别上存在具有相同名称的密钥,则最低级别的密钥优先生效。例如,如果组织级别的密钥与仓库级别的密钥具有相同的名称,则仓库级别的密钥将优先生效。 diff --git a/docs/content/usage/actions/variables.en-us.md b/docs/content/usage/actions/variables.en-us.md deleted file mode 100644 index dee2e74234..0000000000 --- a/docs/content/usage/actions/variables.en-us.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -date: "2024-04-10T22:21:00+08:00" -title: "Variables" -slug: "actions-variables" -sidebar_position: 25 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "Variables" - sidebar_position: 25 - identifier: "actions-variables" ---- - -## Variables - -You can create configuration variables on the user, organization and repository level. -The level of the variable depends on where you created it. When creating a variable, the -key will be converted to uppercase. You need use uppercase on the yaml file. - -### Naming conventions - -The following rules apply to variable names: - -- Variable names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed. -- Variable names must not start with the `GITHUB_` and `GITEA_` prefix. -- Variable names must not start with a number. -- Variable names are case-insensitive. -- Variable names must be unique at the level they are created at. -- Variable names must not be `CI`. - -### Using variable - -After creating configuration variables, they will be automatically filled in the `vars` context. -They can be accessed through expressions like `${{ vars.VARIABLE_NAME }}` in the workflow. - -### Precedence - -If a variable with the same name exists at multiple levels, the variable at the lowest level takes precedence: -A repository variable will always be chosen over an organization/user variable. diff --git a/docs/content/usage/actions/variables.zh-cn.md b/docs/content/usage/actions/variables.zh-cn.md deleted file mode 100644 index 77643408a1..0000000000 --- a/docs/content/usage/actions/variables.zh-cn.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -date: "2024-04-10T22:21:00+08:00" -title: "变量" -slug: "actions-variables" -sidebar_position: 25 -draft: false -toc: false -menu: - sidebar: - parent: "actions" - name: "变量" - sidebar_position: 25 - identifier: "actions-variables" ---- - -## 变量 - -您可以创建用户、组织和仓库级别的变量。变量的级别取决于创建它的位置。当创建变量时,变量的名称会被 -转换为大写,在yaml文件中引用时需要使用大写。 - -### 命名规则 - -以下规则适用于变量名: - -- 变量名称只能包含字母数字字符 (`[a-z]`, `[A-Z]`, `[0-9]`) 或下划线 (`_`)。不允许使用空格。 -- 变量名称不能以 `GITHUB_` 和 `GITEA_` 前缀开头。 -- 变量名称不能以数字开头。 -- 变量名称不区分大小写。 -- 变量名称在创建它们的级别上必须是唯一的。 -- 变量名称不能为 `CI`。 - -### 使用 - -创建配置变量后,它们将自动填充到 `vars` 上下文中。您可以在工作流中使用类似 `${{ vars.VARIABLE_NAME }}` 这样的表达式来使用它们。 - -### 优先级 - -如果同名变量存在于多个级别,则级别最低的变量优先。 -仓库级别的变量总是比组织或者用户级别的变量优先被选中。 diff --git a/docs/content/usage/agit-support.en-us.md b/docs/content/usage/agit-support.en-us.md deleted file mode 100644 index fff9124320..0000000000 --- a/docs/content/usage/agit-support.en-us.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -date: " 2022-09-01T20:50:42+0000" -title: "Agit Setup" -slug: "agit-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /en-us/agit-setup -menu: - sidebar: - parent: "usage" - name: "Agit Setup" - sidebar_position: 12 - identifier: "agit-setup" ---- - -# Agit Setup - -In Gitea `1.13`, support for [agit](https://git-repo.info/en/2020/03/agit-flow-and-git-repo/) was added. -**Note**: git version 2.29 or higher is required on the server side for this to work. - -## Creating PRs with Agit - -Agit allows to create PRs while pushing code to the remote repo. -This can be done by pushing to the branch followed by a specific refspec (a location identifier known to git). -The following example illustrates this: - -```shell -git push origin HEAD:refs/for/main -``` - -The command has the following structure: - -- `HEAD`: The target branch -- `origin`: The target repository (not a fork!) -- `HEAD`: The local branch containing the changes you are proposing -- `refs/<for|draft|for-review>/<branch>`: The target PR type and configuration - - `for`: Create a normal PR with `<branch>` as the target branch - - `draft`/`for-review`: Currently ignored silently - - `<branch>/`: The branch you want your changes to be merged into -- `-o <topic|title|description>`: Options for the PR - - `topic`: The topic of this change. It will become the name of the branch holding the changes waiting for review. This is REQUIRED to trigger a pull request. - - `title`: The PR title (optional but recommended), only used for topics not already having an associated PR. - - `description`: The PR description (optional but recommended), only used for topics not already having an associated PR. - - `force-push`: confirm force update the target branch - -Here's another advanced example for creating a new PR targeting `main` with `topic`, `title`, and `description`: - -```shell -git push origin HEAD:refs/for/main -o topic="Topic of my PR" -o title="Title of the PR" -o description="# The PR Description\nThis can be **any** markdown content.\n- [x] Ok" -``` diff --git a/docs/content/usage/agit-support.zh-cn.md b/docs/content/usage/agit-support.zh-cn.md deleted file mode 100644 index 54210d070b..0000000000 --- a/docs/content/usage/agit-support.zh-cn.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "Agit 设置" -slug: "agit-setup" -sidebar_position: 12 -toc: false -draft: false -aliases: - - /zh-cn/agit-setup -menu: - sidebar: - parent: "usage" - name: "Agit 设置" - sidebar_position: 12 - identifier: "agit-setup" ---- - -# Agit 设置 - -在 Gitea `1.13` 版本中,添加了对 [agit](https://git-repo.info/zh/2020/03/agit-flow-and-git-repo/) 的支持。 - -## 使用 Agit 创建 PR - -Agit 允许在推送代码到远程仓库时创建 PR(合并请求)。 -通过在推送时使用特定的 refspec(git 中已知的位置标识符),可以实现这一功能。 -下面的示例说明了这一点: - -```shell -git push origin HEAD:refs/for/main -``` - -该命令的结构如下: - -- `HEAD`:目标分支 -- `refs/<for|draft|for-review>/<branch>`:目标 PR 类型 - - `for`:创建一个以 `<branch>` 为目标分支的普通 PR - - `draft`/`for-review`:目前被静默忽略 -- `<branch>/<session>`:要打开 PR 的目标分支 -- `-o <topic|title|description>`:PR 的选项 - - `title`:PR 的标题 - - `topic`:PR 应该打开的分支名称 - - `description`:PR 的描述 - - `force-push`:确认强制更新目标分支 - -下面是另一个高级示例,用于创建一个以 `topic`、`title` 和 `description` 为参数的新 PR,目标分支是 `main`: - -```shell -git push origin HEAD:refs/for/main -o topic="Topic of my PR" -o title="Title of the PR" -o description="# The PR Description\nThis can be **any** markdown content.\n- [x] Ok" -``` diff --git a/docs/content/usage/authentication.en-us.md b/docs/content/usage/authentication.en-us.md deleted file mode 100644 index 963f03a095..0000000000 --- a/docs/content/usage/authentication.en-us.md +++ /dev/null @@ -1,351 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Authentication" -slug: "authentication" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /en-us/authentication -menu: - sidebar: - parent: "usage" - name: "Authentication" - sidebar_position: 10 - identifier: "authentication" ---- - -# Authentication - -## LDAP (Lightweight Directory Access Protocol) - -Both the LDAP via BindDN and the simple auth LDAP share the following fields: - -- Authorization Name **(required)** - - - A name to assign to the new method of authorization. - -- Host **(required)** - - - The address where the LDAP server can be reached. - - Example: `mydomain.com` - -- Port **(required)** - - - The port to use when connecting to the server. - - Example: `389` for LDAP or `636` for LDAP SSL - -- Enable TLS Encryption (optional) - - - Whether to use TLS when connecting to the LDAP server. - -- Admin Filter (optional) - - - An LDAP filter specifying if a user should be given administrator - privileges. If a user account passes the filter, the user will be - privileged as an administrator. - - Example: `(objectClass=adminAccount)` - - Example for Microsoft Active Directory (AD): `(memberOf=CN=admin-group,OU=example,DC=example,DC=org)` - -- Username attribute (optional) - - - The attribute of the user's LDAP record containing the user name. Given - attribute value will be used for new Gitea account user name after first - successful sign-in. Leave empty to use login name given on sign-in form. - - This is useful when supplied login name is matched against multiple - attributes, but only single specific attribute should be used for Gitea - account name, see "User Filter". - - Example: `uid` - - Example for Microsoft Active Directory (AD): `sAMAccountName` - -- First name attribute (optional) - - - The attribute of the user's LDAP record containing the user's first name. - This will be used to populate their account information. - - Example: `givenName` - -- Surname attribute (optional) - - - The attribute of the user's LDAP record containing the user's surname. - This will be used to populate their account information. - - Example: `sn` - -- E-mail attribute **(required)** - - The attribute of the user's LDAP record containing the user's email - address. This will be used to populate their account information. - - Example: `mail` - -### LDAP via BindDN - -Adds the following fields: - -- Bind DN (optional) - - - The DN to bind to the LDAP server with when searching for the user. This - may be left blank to perform an anonymous search. - - Example: `cn=Search,dc=mydomain,dc=com` - -- Bind Password (optional) - - - The password for the Bind DN specified above, if any. _Note: The password - is stored encrypted with the SECRET_KEY on the server. It is still recommended - to ensure that the Bind DN has as few privileges as possible._ - -- User Search Base **(required)** - - - The LDAP base at which user accounts will be searched for. - - Example: `ou=Users,dc=mydomain,dc=com` - -- User Filter **(required)** - - An LDAP filter declaring how to find the user record that is attempting to - authenticate. The `%[1]s` matching parameter will be substituted with login - name given on sign-in form. - - Example: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))` - - Example for Microsoft Active Directory (AD): `(&(objectCategory=Person)(memberOf=CN=user-group,OU=example,DC=example,DC=org)(sAMAccountName=%s)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))` - - To substitute more than once, `%[1]s` should be used instead, e.g. when - matching supplied login name against multiple attributes such as user - identifier, email or even phone number. - - Example: `(&(objectClass=Person)(|(uid=%[1]s)(mail=%[1]s)(mobile=%[1]s)))` -- Enable user synchronization - - This option enables a periodic task that synchronizes the Gitea users with - the LDAP server. The default period is every 24 hours but that can be - changed in the app.ini file. See the _cron.sync_external_users_ section in - the [sample - app.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) - for detailed comments about that section. The _User Search Base_ and _User - Filter_ settings described above will limit which users can use Gitea and - which users will be synchronized. When initially run the task will create - all LDAP users that match the given settings so take care if working with - large Enterprise LDAP directories. - -### LDAP using simple auth - -Adds the following fields: - -- User DN **(required)** - - - A template to use as the user's DN. The `%s` matching parameter will be - substituted with login name given on sign-in form. - - Example: `cn=%s,ou=Users,dc=mydomain,dc=com` - - Example: `uid=%s,ou=Users,dc=mydomain,dc=com` - -- User Search Base (optional) - - - The LDAP base at which user accounts will be searched for. - - Example: `ou=Users,dc=mydomain,dc=com` - -- User Filter **(required)** - - An LDAP filter declaring when a user should be allowed to log in. The `%[1]s` - matching parameter will be substituted with login name given on sign-in - form. - - Example: `(&(objectClass=posixAccount)(|(cn=%[1]s)(mail=%[1]s)))` - - Example: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))` - -### Verify group membership in LDAP - -Uses the following fields: - -- Group Search Base DN (optional) - - - The LDAP DN used for groups. - - Example: `ou=group,dc=mydomain,dc=com` - -- Group Attribute Containing List Of Users (optional) - - The attribute of the group object that lists/contains the group members. - - Example: `memberUid` or `member` - -- User Attribute Listed in Group (optional) - - - The user attribute that is used to reference a user in the group object. - - Example: `uid` if the group objects contains a `member: bender` and the user object contains a `uid: bender`. - - Example: `dn` if the group object contains a `member: uid=bender,ou=users,dc=planetexpress,dc=com`. - -- Verify group membership in LDAP (optional) - - - An LDAP filter declaring how to find valid groups in the above DN. - - Example: `(|(cn=gitea_users)(cn=admins))` - -## PAM (Pluggable Authentication Module) - -This procedure enables PAM authentication. Users may still be added to the -system manually using the user administration. PAM provides a mechanism to -automatically add users to the current database by testing them against PAM -authentication. To work with normal Linux passwords, the user running Gitea -must also have read access to `/etc/shadow` in order to check the validity of -the account when logging in using a public key. - -**Note**: If a user has added SSH public keys into Gitea, the use of these -keys _may_ bypass the login check system. Therefore, if you wish to disable a user who -authenticates with PAM, you _should_ also manually disable the account in Gitea using the -built-in user manager. - -1. Configure and prepare the installation. - - It is recommended that you create an administrative user. - - Deselecting automatic sign-up may also be desired. -1. Once the database has been initialized, log in as the newly created -administrative user. -1. Navigate to the user setting (icon in top-right corner), and select -`Site Administration` -> `Authentication Sources`, and select -`Add Authentication Source`. -1. Fill out the field as follows: - - `Authentication Type` : `PAM` - - `Name` : Any value should be valid here, use "System Authentication" if - you'd like. - - `PAM Service Name` : Select the appropriate file listed under `/etc/pam.d/` - that performs the authentication desired.[^1] - - `PAM Email Domain` : The e-mail suffix to append to user authentication. - For example, if the login system expects a user called `gituser`, and this - field is set to `mail.com`, then Gitea will expect the `user email` field - for an authenticated GIT instance to be `gituser@mail.com`.[^2] - -**Note**: PAM support is added via [build-time flags](installation/from-source.md#build), -and the official binaries provided do not have this enabled. PAM requires that -the necessary libpam dynamic library be available and the necessary PAM -development headers be accessible to the compiler. - -[^1]: For example, using standard Linux log-in on Debian "Bullseye" use -`common-session-noninteractive` - this value may be valid for other flavors of -Debian including Ubuntu and Mint, consult your distribution's documentation. -[^2]: **This is a required field for PAM**. Be aware: In the above example, the -user will log into the Gitea web interface as `gituser` and not `gituser@mail.com` - -## SMTP (Simple Mail Transfer Protocol) - -This option allows Gitea to log in to an SMTP host as a Gitea user. To -configure this, set the fields below: - -- Authentication Name **(required)** - - - A name to assign to the new method of authorization. - -- SMTP Authentication Type **(required)** - - - Type of authentication to use to connect to SMTP host, PLAIN or LOGIN. - -- Host **(required)** - - - The address where the SMTP host can be reached. - - Example: `smtp.mydomain.com` - -- Port **(required)** - - - The port to use when connecting to the server. - - Example: `587` - -- Allowed Domains - - - Restrict what domains can log in if using a public SMTP host or SMTP host - with multiple domains. - - Example: `gitea.com,mydomain.com,mydomain2.com` - -- Force SMTPS - - - SMTPS will be used by default for connections to port 465, if you wish to use SMTPS - for other ports. Set this value. - - Otherwise if the server provides the `STARTTLS` extension this will be used. - -- Skip TLS Verify - - - Disable TLS verify on authentication. - -- This Authentication Source is Activated - - Enable or disable this authentication source. - -## FreeIPA - -- In order to log in to Gitea using FreeIPA credentials, a bind account needs to - be created for Gitea: - -- On the FreeIPA server, create a `gitea.ldif` file, replacing `dc=example,dc=com` - with your DN, and provide an appropriately secure password: - - ```sh - dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com - changetype: add - objectclass: account - objectclass: simplesecurityobject - uid: gitea - userPassword: secure password - passwordExpirationTime: 20380119031407Z - nsIdleTimeout: 0 - ``` - -- Import the LDIF (change localhost to an IPA server if needed). A prompt for - Directory Manager password will be presented: - - ```sh - ldapmodify -h localhost -p 389 -x -D \ - "cn=Directory Manager" -W -f gitea.ldif - ``` - -- Add an IPA group for gitea_users : - - ```sh - ipa group-add --desc="Gitea Users" gitea_users - ``` - -- Note: For errors about IPA credentials, run `kinit admin` and provide the - domain admin account password. - -- Log in to Gitea as an Administrator and click on "Authentication" under Admin Panel. - Then click `Add New Source` and fill in the details, changing all where appropriate. - -## SPNEGO with SSPI (Kerberos/NTLM, for Windows only) - -Gitea supports SPNEGO single sign-on authentication (the scheme defined by RFC4559) for the web part of the server via the Security Support Provider Interface (SSPI) built in Windows. SSPI works only in Windows environments - when both the server and the clients are running Windows. - -Before activating SSPI single sign-on authentication (SSO) you have to prepare your environment: - -- Create a separate user account in active directory, under which the `gitea.exe` process will be running (eg. `user` under domain `domain.local`): - -- Create a service principal name for the host where `gitea.exe` is running with class `HTTP`: - - - Start `Command Prompt` or `PowerShell` as a privileged domain user (eg. Domain Administrator) - - Run the command below, replacing `host.domain.local` with the fully qualified domain name (FQDN) of the server where the web application will be running, and `domain\user` with the name of the account created in the previous step: - - ```sh - setspn -A HTTP/host.domain.local domain\user - ``` - -- Sign in (_sign out if you were already signed in_) with the user created - -- Make sure that `ROOT_URL` in the `[server]` section of `custom/conf/app.ini` is the fully qualified domain name of the server where the web application will be running - the same you used when creating the service principal name (eg. `host.domain.local`) - -- Start the web server (`gitea.exe web`) - -- Enable SSPI authentication by adding an `SPNEGO with SSPI` authentication source in `Site Administration -> Authentication Sources` - -- Sign in to a client computer in the same domain with any domain user (client computer, different from the server running `gitea.exe`) - -- If you are using Chrome or Edge, add the URL of the web app to the Local intranet sites (`Internet Options -> Security -> Local intranet -> Sites`) - -- Start Chrome or Edge and navigate to the FQDN URL of Gitea (eg. `http://host.domain.local:3000`) - -- Click the `Sign In` button on the dashboard and choose SSPI to be automatically logged in with the same user that is currently logged on to the computer - -- If it does not work, make sure that: - - You are not running the web browser on the same server where Gitea is running. You should be running the web browser on a domain joined computer (client) that is different from the server. If both the client and server are running on the same computer NTLM will be preferred over Kerberos. - - There is only one `HTTP/...` SPN for the host - - The SPN contains only the hostname, without the port - - You have added the URL of the web app to the `Local intranet zone` - - The clocks of the server and client should not differ with more than 5 minutes (depends on group policy) - - `Integrated Windows Authentication` should be enabled in Internet Explorer (under `Advanced settings`) - -## Reverse Proxy - -Gitea supports Reverse Proxy Header authentication, it will read headers as a trusted login user name or user email address. This hasn't been enabled by default, you can enable it with - -```ini -[service] -ENABLE_REVERSE_PROXY_AUTHENTICATION = true -``` - -The default login user name is in the `X-WEBAUTH-USER` header, you can change it via changing `REVERSE_PROXY_AUTHENTICATION_USER` in app.ini. If the user doesn't exist, you can enable automatic registration with `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION=true`. - -The default login user email is `X-WEBAUTH-EMAIL`, you can change it via changing `REVERSE_PROXY_AUTHENTICATION_EMAIL` in app.ini, this could also be disabled with `ENABLE_REVERSE_PROXY_EMAIL` - -If set `ENABLE_REVERSE_PROXY_FULL_NAME=true`, a user full name expected in `X-WEBAUTH-FULLNAME` will be assigned to the user when auto creating the user. You can also change the header name with `REVERSE_PROXY_AUTHENTICATION_FULL_NAME`. - -You can also limit the reverse proxy's IP address range with `REVERSE_PROXY_TRUSTED_PROXIES` which default value is `127.0.0.0/8,::1/128`. By `REVERSE_PROXY_LIMIT`, you can limit trusted proxies level. - -Notice: Reverse Proxy Auth doesn't support the API. You still need an access token or basic auth to make API requests. diff --git a/docs/content/usage/authentication.zh-cn.md b/docs/content/usage/authentication.zh-cn.md deleted file mode 100644 index 00a24531d9..0000000000 --- a/docs/content/usage/authentication.zh-cn.md +++ /dev/null @@ -1,293 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "认证" -slug: "authentication" -sidebar_position: 10 -toc: false -draft: false -aliases: - - /zh-cn/authentication -menu: - sidebar: - parent: "usage" - name: "认证" - sidebar_position: 10 - identifier: "authentication" ---- - -# 认证 - -## 轻量级目录访问协议(Lightweight Directory Access Protocol,LDAP) - -通过BindDN的LDAP和简单认证方式LDAP共享以下字段: - -- 认证名称 **(必选)** - - - 分配给新授权方法的名称。 - -- 主机名 **(必选)** - - - LDAP 服务的主机地址. - - 例如:`mydomain.com` - -- 端口号 **(必选)** - - - LDAP 服务的端口号. - - 例如: LDAP `389`/ LDAPs `636` - -- 安全协议 (可选) - - 连接LDAP服务器时是否使用TLS协议。 - -- 管理员过滤规则 (可选) - - 一个LDAP过滤器,用于指定哪些用户应该被赋予管理员特权。如果用户帐户符合过滤器条件,则该用户将被授予管理员权限。 - - 示例:`(objectClass=adminAccount)` - - 适用于Microsoft Active Directory(AD)的示例:`memberOf=CN=admin-group,OU=example,DC=example,DC=org` - -- 用户名属性(可选) - - - 用户LDAP记录中包含用户名称的属性。在第一次成功登录后,将使用指定的属性值作为新的Gitea账户用户名。若留空,则使用登录表单上提供的用户名。 - - 当提供的登录名与多个属性匹配时,这一选项非常有用,但是只有一个特定属性应该用于Gitea账户名称,请参阅"用户过滤器"。 - - 示例:uid - - 适用于Microsoft Active Directory(AD)的示例:`sAMAccountName` - -- 名字属性(可选) - - - 用户LDAP记录中包含用户名字的属性。将用于填充他们的账户信息。 - - 示例:givenName -- 姓氏属性(可选) - - 用户LDAP记录中包含用户姓氏的属性。将用于填充他们的账户信息。 - - 示例:`sn` - -- 电子邮件属性 **(必选)** - - 用户LDAP记录中包含用户电子邮件地址的属性。将用于填充他们的账户信息。 - - 示例:`mail` - -### LDAP(via BindDN) - -需要额外设置以下字段: - -- 绑定DN (可选) - - - 搜索用户时绑定到LDAP服务器的DN。这可以留空以执行匿名搜索。 - - 示例: `cn=Search,dc=mydomain,dc=com` - -- 绑定密码 (可选) - - - 上述指定的Bind DN(绑定区别名)的密码,如果有的话。注意:该密码在服务器上使用SECRET_KEY进行加密存储。仍然建议确保Bind DN具有尽可能少的权限。 - -- 用户搜索基准 **(必选)** - - - 这是用于搜索用户帐户的LDAP基础路径. - - 示例: `ou=Users,dc=mydomain,dc=com` - -- 用户过滤规则 **(必选)** - - LDAP 过滤器声明如何查找试图进行身份验证的用户记录 - `%[1]s`匹配参数将替换为登录表单中给出的登录名 - - 示例: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))` - - 示例 for Microsoft Active Directory (AD): `(&(objectCategory=Person)(memberOf=CN=user-group,OU=example,DC=example,DC=org)(sAMAccountName=%s)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))` - - 如需多次替换,应使用 `%[1]s`,例如在将提供的登录名与多个属性(如用户标识符、电子邮件甚至电话号码)进行匹配时。 - - 示例: `(&(objectClass=Person)(|(uid=%[1]s)(mail=%[1]s)(mobile=%[1]s)))` -- 启用用户同步 - - 这个选项启用了一个周期性任务,用于将Gitea用户与LDAP服务器进行同步。默认的同步周期是每24小时, - 但您可以在app.ini文件中进行更改。 - 有关此部分的详细说明,请参阅[sample - app.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) - 的_cron.sync_external_users_ 部分的注释。前面提到的_User Search Base_和_User Filter_ - 设置将限制哪些用户可以使用Gitea以及哪些用户将被同步。 - 在初始运行任务时,将根据给定的设置创建所有与LDAP匹配的用户,因此在使用大型企业LDAP目录时需要小心。 - -### LDAP(simple auth) - -需要额外设置以下字段: - -- 用户DN **(必选)** - - - 用作用户 DN 的模板。匹配参数 `%s` 将替换为登录表单中的登录名。 - - 示例: `cn=%s,ou=Users,dc=mydomain,dc=com` - - 示例: `uid=%s,ou=Users,dc=mydomain,dc=com` - -- 用户搜索基准 (可选) - - - 用户搜索基准声明哪些用户帐户将被搜索. - - 示例: `ou=Users,dc=mydomain,dc=com` - -- 用户过滤规则 **(必选)** - - LDAP 过滤器声明何时允许用户登录 - `%[1]s`匹配参数将替换为登录表单中给出的登录名。 - - 示例: `(&(objectClass=posixAccount)(|(cn=%[1]s)(mail=%[1]s)))` - - 示例: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))` - -### 使用LDAP验证分组成员 - -使用以下字段: - -- 群组搜索基础DN(可选) - - 组使用的 LDAP DN。 - - 示例: `ou=group,dc=mydomain,dc=com` - -- 组名过滤器 (可选) - - - LDAP 过滤器,声明如何在上述 DN 中查找有效组。 - - 示例: `(|(cn=gitea_users)(cn=admins))` - -- 组中的用户属性 (可选) - - - 组中列出了哪个用户的 LDAP 属性。 - - 示例: `uid` - -- 用户组属性 (可选) - - 哪个组的 LDAP 属性包含一个高于用户属性名称的数组。 - - 示例: `memberUid` - -## 可插拔式认证模块(Pluggable Authentication Module,PAM) - -这个过程启用了PAM(Pluggable Authentication Modules)认证。用户仍然可以通过用户管理手动添加到系统中。 -PAM提供了一种机制,通过对用户进行PAM认证来自动将其添加到当前数据库中。为了与普通的Linux密码一起使用, -运行Gitea的用户还必须具有对`/etc/shadow`的读取权限,以便在使用公钥登录时检查账户的有效性。 - -**注意**:如果用户已将SSH公钥添加到Gitea中,使用这些密钥可能会绕过登录检查系统。因此, -如果您希望禁用使用PAM进行身份验证的用户,应该在Gitea中手动禁用该账户,使用内置的用户管理功能。 - -1. 配置和安装准备. - - 建议您创建一个管理用户. - - 建议取消自动注册. -1. 一旦数据库已初始化完成,使用新创建的管理员账户登录. -1. 导航至用户设置(右上角的图标),然后选择 -`Site Administration` -> `Authentication Sources`, 并选择 -`Add Authentication Source`. -1. 填写字段如下: - - 认证类型:`PAM`。 - - 名称:任何有效的值都可以,如果您愿意,可以使用"System Authentication"。 - - PAM服务名称:从/etc/pam.d/目录下选择适用于所需认证的正确文件[^1]。 - - PAM电子邮件域:用户认证时要附加的电子邮件后缀。例如,如果登录系统期望一个名为gituse的用户, - 并且将此字段设置为mail.com,那么Gitea在验证一个GIT实例的用户时将期望user emai字段为gituser@mail.com[^2]。 - -**Note**: PAM 支持通过[build-time flags](installation/from-source.md#build)添加, -而官方提供的二进制文件通常不会默认启用此功能。PAM需要确保系统上有必要的libpam动态库,并且编译器可以访问必要的PAM开发头文件。 - -[^1]: 例如,在Debian "Bullseye"上使用标准Linux登录,可以使用`common-session-noninteractive`。这个值对于其他版本的Debian, -包括Ubuntu和Mint,可能也是有效的,请查阅您所使用发行版的文档以确认。 - -[^2]: **PAM的必选项** 请注意:在上面的示例中,用户将作为`gituser`而不是`gituser@mail.com`登录到Gitea的Web界面。 - -## 简单邮件传输协议(Simple Mail Transfer Protocol,SMTP) - -此选项允许 Gitea 以 Gitea 用户身份登录 SMTP 主机。请设置以下字段: - -- 身份验证名称 **(必选)** - - 分配给新授权方法的名称 - -- SMTP 验证类型 **(必选)** - - 用于连接 SMTP 主机的验证类型,plain 或 login - -- 主机名 **(必选)** - - - SMTP 服务的主机地址 - - 例如:`smtp.mydomain.com` - -- 端口号 **(必选)** - - - SMTP 服务的端口号 - - 例如: `587` - -- 允许的域名 - - - 如果使用公共 SMTP 主机或有多个域的 SMTP 主机,限制哪些域可以登录 - 限制哪些域可以登录。 - - 示例: `gitea.com,mydomain.com,mydomain2.com` - -- 强制使用 SMTPS - - 默认情况下将使用SMTPS连接到端口465.如果您希望将smtp用于其他端口,自行设置 - - 否则,如果服务器提供' STARTTLS '扩展名,则将使用此扩展名 -- 跳过 TLS 验证 - - 禁用 TLS 验证身份. -- 该认证源处于激活状态 - - 启用或禁用此身份验证源 - -## FreeIPA - -- 要使用 FreeIPA 凭据登录 Gitea,需要为 Gitea 创建一个绑定帐户。 - 创建一个绑定帐户: -- 在FreeIPA服务器上创建一个gitea.ldif文件,并将`dc=example,dc=com`替换为您的`dn`,然后提供一个适当安全的密码。 - - ```sh - dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com - changetype: add - objectclass: account - objectclass: simplesecurityobject - uid: gitea - userPassword: secure password - passwordExpirationTime: 20380119031407Z - nsIdleTimeout: 0 - ``` - -- 导入LDIF文件(如果需要,请将localhost更改为IPA服务器)。系统会提示您输入Directory Manager的密码。: - - ```sh - ldapmodify -h localhost -p 389 -x -D \ - "cn=Directory Manager" -W -f gitea.ldif - ``` - -- 为`gitea_users`添加IPA组: - - ```sh - ipa group-add --desc="Gitea Users" gitea_users - ``` - -- **提示**:对于IPA凭证错误,运行' kinit admin '并提供域管理帐户密码. -- 以管理员身份登录Gitea,点击Admin Panel下的`Authentication`。然后单击`Add New Source`并填写详细信息,更改所有适当的地方。 - -## SPNEGO with SSPI (Kerberos/NTLM, for Windows only) - -Gitea支持通过Windows内置的安全支持提供程序接口(Security Support Provider Interface,SSPI)实现SPNEGO单点登录认证(由RFC4559定义的方案),用于服务器的Web部分。SSPI仅在Windows环境中工作,即当服务器和客户端都在Windows操作系统上运行时。 - -在激活SSPI单点登录认证(SSO)之前,您需要准备您的环境: - -- 在Active Directory中创建一个单独的用户账户,gitea.exe 进程将在该账户下运行(例如,在domain.local域下创建一个名为user的账户: -- 为运行gitea.exe的主机创建一个服务主体名称(Service Principal Name,SPN),其类别为HTTP: - - - 以特权域用户(例如域管理员)的身份启动“命令提示符”或“PowerShell”。 - - 运行下面的命令,将host.domain.local替换为Web应用程序将运行的服务器的完全限定域名(FQDN),将domain\user替换为在前一步中创建的账户名称: - - ```sh - setspn -A HTTP/host.domain.local domain\user - ``` - -在遵循上述步骤之前,请确保您按照以下流程进行操作: - -1. 用之前创建的用户登录(如果已经登录,请先注销)。 -2. 确保在`custom/conf/app.ini`文件的`[server]`部分中,`ROOT_URL`设置为Web应用程序将运行的服务器的完全限定域名(FQDN),与之前创建服务主体名称时使用的一致(例如,`host.domain.local`)。 -3. 启动Web服务器(运行 `gitea.exe web`)。 -4. 在 `Site Administration -> Authentication Sources` 中添加一个 `SPNEGO with SSPI` 认证源,以启用SSPI认证。 -5. 在域中的客户端计算机上,使用任何域用户登录(与运行`gitea.exe`的服务器不同)。 -6. 如果您使用Chrome或Edge浏览器,请将Web应用程序的URL添加到“本地站点”(`Internet选项 -> 安全 -> 本地站点 -> 站点`)。 -7. 启动Chrome或Edge浏览器,导航到Gitea的FQDN URL(例如,`http://host.domain.local:3000`)。 -8. 在控制面板中点击“Sign In”按钮,然后选择SSPI,将会自动使用当前登录到计算机的用户进行登录。 -9. 如果无法正常工作,请确保: - - 您不是在运行`gitea.exe`的同一台服务器上运行Web浏览器。应该在与服务器不同的域加入计算机(客户端)上运行Web浏览器。如果客户端和服务器都在同一台计算机上运行,则NTLM将优先于Kerberos。 - - 主机上只有一个`HTTP/...`的SPN。 - - SPN中只包含主机名,不包含端口号。 - - 将Web应用程序的URL添加到"本地站点"。 - - 服务器和客户端的时钟差异不超过5分钟(取决于组策略)。 - - 在Internet Explorer中启用了"集成Windows身份验证"(在"高级设置"下)。 - -遵循这些步骤,您应该能够成功启用和使用SSPI单点登录认证(SSO)。 - -## 反向代理认证 - -Gitea 支持通过读取反向代理传递的 HTTP 头中的登录名或者 email 地址来支持反向代理来认证。默认是不启用的,你可以用以下配置启用。 - -```ini -[service] -ENABLE_REVERSE_PROXY_AUTHENTICATION = true -``` - -默认的登录用户名的 HTTP 头是 `X-WEBAUTH-USER`,你可以通过修改 `REVERSE_PROXY_AUTHENTICATION_USER` 来变更它。如果用户不存在,可以自动创建用户,当然你需要修改 `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION=true` 来启用它。 - -默认的登录用户 Email 的 HTTP 头是 `X-WEBAUTH-EMAIL`,你可以通过修改 `REVERSE_PROXY_AUTHENTICATION_EMAIL` 来变更它。如果用户不存在,可以自动创建用户,当然你需要修改 `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION=true` 来启用它。你也可以通过修改 `ENABLE_REVERSE_PROXY_EMAIL` 来启用或停用这个 HTTP 头。 - -如果设置了 `ENABLE_REVERSE_PROXY_FULL_NAME=true`,则用户的全名会从 `X-WEBAUTH-FULLNAME` 读取,这样在自动创建用户时将使用这个字段作为用户全名,你也可以通过修改 `REVERSE_PROXY_AUTHENTICATION_FULL_NAME` 来变更 HTTP 头。 - -你也可以通过修改 `REVERSE_PROXY_TRUSTED_PROXIES` 来设置反向代理的IP地址范围,加强安全性,默认值是 `127.0.0.0/8,::1/128`。 通过 `REVERSE_PROXY_LIMIT`, 可以设置最多信任几级反向代理。 - -注意:反向代理认证不支持认证 API,API 仍旧需要用 access token 来进行认证。 diff --git a/docs/content/usage/blame.en-us.md b/docs/content/usage/blame.en-us.md deleted file mode 100644 index 7772bbc16d..0000000000 --- a/docs/content/usage/blame.en-us.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -date: "2023-08-14T00:00:00+00:00" -title: "Blame File View" -slug: "blame" -sidebar_position: 13 -toc: false -draft: false -aliases: - - /en-us/blame -menu: - sidebar: - parent: "usage" - name: "Blame" - sidebar_position: 13 - identifier: "blame" ---- - -# Blame File View - -Gitea supports viewing the line-by-line revision history for a file also known as blame view. -You can also use [`git blame`](https://git-scm.com/docs/git-blame) on the command line to view the revision history of lines within a file. - -1. Navigate to and open the file whose line history you want to view. -1. Click the `Blame` button in the file header bar. -1. The new view shows the line-by-line revision history for a file with author and commit information on the left side. -1. To navigate to an older commit, click the ![versions](/octicon-versions.svg) icon. - -## Ignore commits in the blame view - -All revisions specified in the `.git-blame-ignore-revs` file are hidden from the blame view. -This is especially useful to hide reformatting changes and keep the benefits of `git blame`. -Lines that were changed or added by an ignored commit will be blamed on the previous commit that changed that line or nearby lines. -The `.git-blame-ignore-revs` file must be located in the root directory of the repository. -For more information like the file format, see [the `git blame --ignore-revs-file` documentation](https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt). - -### Bypassing `.git-blame-ignore-revs` in the blame view - -If the blame view for a file shows a message about ignored revisions, you can see the normal blame view by appending the url parameter `?bypass-blame-ignore=true`. diff --git a/docs/content/usage/blocking-users.en-us.md b/docs/content/usage/blocking-users.en-us.md deleted file mode 100644 index b59bbe4d62..0000000000 --- a/docs/content/usage/blocking-users.en-us.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -date: "2024-01-31T00:00:00+00:00" -title: "Blocking a user" -slug: "blocking-user" -sidebar_position: 25 -toc: false -draft: false -aliases: - - /en-us/webhooks -menu: - sidebar: - parent: "usage" - name: "Blocking a user" - sidebar_position: 30 - identifier: "blocking-user" ---- - -# Blocking a user - -Gitea supports blocking of users to restrict how they can interact with you and your content. - -You can block a user in your account settings, from the user's profile or from comments created by the user. -The user is not directly notified about the block, but they can notice they are blocked when they attempt to interact with you. -Organization owners can block anyone who is not a member of the organization too. -If a blocked user has admin permissions, they can still perform all actions even if blocked. - -### When you block a user - -- the user stops following you -- you stop following the user -- the user's stars are removed from your repositories -- your stars are removed from their repositories -- the user stops watching your repositories -- you stop watching their repositories -- the user's issue assignments are removed from your repositories -- your issue assignments are removed from their repositories -- the user is removed as a collaborator on your repositories -- you are removed as a collaborator on their repositories -- any pending repository transfers to or from the blocked user are canceled - -### When you block a user, the user cannot - -- follow you -- watch your repositories -- star your repositories -- fork your repositories -- transfer repositories to you -- open issues or pull requests on your repositories -- comment on issues or pull requests you've created -- comment on issues or pull requests on your repositories -- react to your comments on issues or pull requests -- react to comments on issues or pull requests on your repositories -- assign you to issues or pull requests -- add you as a collaborator on their repositories -- send you notifications by @mentioning your username -- be added as team member (if blocked by an organization) diff --git a/docs/content/usage/clone-filter.en-us.md b/docs/content/usage/clone-filter.en-us.md deleted file mode 100644 index c3d4a43e2c..0000000000 --- a/docs/content/usage/clone-filter.en-us.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -date: "2021-02-02" -title: "Clone filters (partial clone)" -slug: "clone-filters" -sidebar_position: 25 -draft: false -toc: false -aliases: - - /en-us/clone-filters -menu: - sidebar: - parent: "usage" - name: "Clone filters" - sidebar_position: 25 - identifier: "clone-filters" ---- - -# Clone filters (partial clone) - -Git introduces `--filter` option to `git clone` command, which filters out -large files and objects (such as blobs) to create partial clone of a repo. -Clone filters are especially useful for large repo and/or metered connection, -where full clone (without `--filter`) can be expensive (as all history data -must be downloaded). - -This requires Git version 2.22 or later, both on the Gitea server and on the -client. For clone filters to work properly, make sure that Git version -on the client is at least the same as on the server (or later). Login to -Gitea server as admin and head to Site Administration -> Configuration to -see Git version of the server. - -By default, clone filters are enabled, unless `DISABLE_PARTIAL_CLONE` under -`[git]` is set to `true`. - -See [GitHub blog post: Get up to speed with partial clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) -for common use cases of clone filters (blobless and treeless clones), and -[GitLab docs for partial clone](https://docs.gitlab.com/ee/topics/git/partial_clone.html) -for more advanced use cases (such as filter by file size and remove -filters to turn partial clone into full clone). diff --git a/docs/content/usage/clone-filter.zh-cn.md b/docs/content/usage/clone-filter.zh-cn.md deleted file mode 100644 index 53ce060fdf..0000000000 --- a/docs/content/usage/clone-filter.zh-cn.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "克隆过滤器 (部分克隆)" -slug: "clone-filters" -sidebar_position: 25 -draft: false -toc: false -aliases: - - /zh-cn/clone-filters -menu: - sidebar: - parent: "usage" - name: "克隆过滤器" - sidebar_position: 25 - identifier: "clone-filters" ---- - -# 克隆过滤器 (部分克隆) - -Git 引入了 `--filter` 选项用于 `git clone` 命令,该选项可以过滤掉大文件和对象(如 blob),从而创建一个仓库的部分克隆。克隆过滤器对于大型仓库和/或按流量计费的连接特别有用,因为完全克隆(不使用 `--filter`)可能会很昂贵(需要下载所有历史数据)。 - -这需要 Git 2.22 或更高版本,无论是在 Gitea 服务器上还是在客户端上都需要如此。为了使克隆过滤器正常工作,请确保客户端上的 Git 版本至少与服务器上的版本相同(或更高)。以管理员身份登录到 Gitea,然后转到管理后台 -> 应用配置,查看服务器的 Git 版本。 - -默认情况下,克隆过滤器是启用的,除非在 `[git]` 下将 `DISABLE_PARTIAL_CLONE` 设置为 `true`。 - -请参阅 [GitHub 博客文章:了解部分克隆](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) 以获取克隆过滤器的常见用法(无 Blob 和无树的克隆),以及 [GitLab 部分克隆文档](https://docs.gitlab.com/ee/topics/git/partial_clone.html) 以获取更高级的用法(例如按文件大小过滤和取消过滤以将部分克隆转换为完全克隆)。 diff --git a/docs/content/usage/code-owners.en-us.md b/docs/content/usage/code-owners.en-us.md deleted file mode 100644 index 7642175d8d..0000000000 --- a/docs/content/usage/code-owners.en-us.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -date: "2023-05-24T16:00:00+00:00" -title: "Code Owners" -slug: "code-owners" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /en-us/code-owners -menu: - sidebar: - parent: "usage" - name: "Code Owners" - sidebar_position: 30 - identifier: "code-owners" ---- - -# Code Owners - -Gitea maintains code owner files. It looks for it in the following locations in this order: - -- `./CODEOWNERS` -- `./docs/CODEOWNERS` -- `./.gitea/CODEOWNERS` - -And stops at the first found file. - -File format: `<regexp rule> <@user or @org/team> [@user or @org/team]...` - -Regexp specified in golang Regex format. -Regexp can start with `!` for negative rules - match all files except specified. - -Example file: - -``` -.*\\.go @user1 @user2 # This is comment - -# Comment too -# You can assigning code owning for users or teams -frontend/src/.*\\.js @org1/team1 @org1/team2 @user3 - -# You can use negative pattern -!frontend/src/.* @org1/team3 @user5 - -# You can use power of go regexp -docs/(aws|google|azure)/[^/]*\\.(md|txt) @user8 @org1/team4 -!/assets/.*\\.(bin|exe|msi) @user9 -``` - -### Escaping - -You can escape characters `#`, ` ` (space) and `\` with `\`, like: - -``` -dir/with\#hashtag @user1 -path\ with\ space @user2 -path/with\\backslash @user3 -``` - -Some character (`.+*?()|[]{}^$\`) should be escaped with `\\` inside regexp, like: - -``` -path/\\.with\\.dots -path/with\\+plus -``` diff --git a/docs/content/usage/incoming-email.en-us.md b/docs/content/usage/incoming-email.en-us.md deleted file mode 100644 index 3f20f3b1fe..0000000000 --- a/docs/content/usage/incoming-email.en-us.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -date: "2022-12-01T00:00:00+00:00" -title: "Incoming Email" -slug: "incoming-email" -sidebar_position: 13 -draft: false -toc: false -aliases: - - /en-us/incoming-email -menu: - sidebar: - parent: "usage" - name: "Incoming Email" - sidebar_position: 13 - identifier: "incoming-email" ---- - -# Incoming Email - -Gitea supports the execution of several actions through incoming mails. This page describes how to set this up. - -## Requirements - -Handling incoming email messages requires an IMAP-enabled email account. -The recommended strategy is to use [email sub-addressing](https://en.wikipedia.org/wiki/Email_address#Sub-addressing) but a catch-all mailbox does work too. -The receiving email address contains a user/action specific token which tells Gitea which action should be performed. -This token is expected in the `To` and `Delivered-To` header fields. - -Gitea tries to detect automatic responses to skip and the email server should be configured to reduce the incoming noise too (spam, newsletter). - -## Configuration - -To activate the handling of incoming email messages you have to configure the `email.incoming` section in the configuration file. - -The `REPLY_TO_ADDRESS` contains the address an email client will respond to. -This address needs to contain the `%{token}` placeholder which will be replaced with a token describing the user/action. -This placeholder must only appear once in the address and must be in the user part of the address (before the `@`). - -An example using email sub-addressing may look like this: `incoming+%{token}@example.com` - -If a catch-all mailbox is used, the placeholder may be used anywhere in the user part of the address: `incoming+%{token}@example.com`, `incoming_%{token}@example.com`, `%{token}@example.com` - -## Security - -Be careful when choosing the domain used for receiving incoming email. -It's recommended receiving incoming email on a subdomain, such as `incoming.example.com` to prevent potential security problems with other services running on `example.com`. diff --git a/docs/content/usage/incoming-email.zh-cn.md b/docs/content/usage/incoming-email.zh-cn.md deleted file mode 100644 index 7aeb3c0866..0000000000 --- a/docs/content/usage/incoming-email.zh-cn.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "邮件接收" -slug: "incoming-email" -sidebar_position: 13 -draft: false -toc: false -aliases: - - /zh-cn/incoming-email -menu: - sidebar: - parent: "usage" - name: "邮件接收" - sidebar_position: 13 - identifier: "incoming-email" ---- - -# 邮件接收 - -Gitea 支持通过接收邮件执行多种操作。本页面描述了如何进行设置。 - -## 要求 - -处理接收的电子邮件需要启用 IMAP 功能的电子邮件帐户。 -推荐的策略是使用 [电子邮件子地址](https://en.wikipedia.org/wiki/Email_address#Sub-addressing),但也可以使用 catch-all 邮箱。 -接收电子邮件地址中包含一个用户/操作特定的令牌,告诉 Gitea 应执行哪个操作。 -此令牌应该出现在 `To` 和 `Delivered-To` 头字段中。 - -Gitea 会尝试检测自动回复并跳过它们,电子邮件服务器也应该配置以减少接收到的干扰(垃圾邮件、通讯订阅等)。 - -## 配置 - -要激活处理接收的电子邮件消息功能,您需要在配置文件中配置 `email.incoming` 部分。 - -`REPLY_TO_ADDRESS` 包含电子邮件客户端将要回复的地址。 -该地址需要包含 `%{token}` 占位符,该占位符将被替换为描述用户/操作的令牌。 -此占位符在地址中只能出现一次,并且必须位于地址的用户部分(`@` 之前)。 - -使用电子邮件子地址的示例可能如下:`incoming+%{token}@example.com` - -如果使用 catch-all 邮箱,则占位符可以出现在地址的用户部分的任何位置:`incoming+%{token}@example.com`、`incoming_%{token}@example.com`、`%{token}@example.com` - -## 安全性 - -在选择用于接收传入电子邮件的域时要小心。 -建议在子域名上接收传入电子邮件,例如 `incoming.example.com`,以防止与运行在 `example.com` 上的其他服务可能存在的安全问题。 diff --git a/docs/content/usage/issue-pull-request-templates.en-us.md b/docs/content/usage/issue-pull-request-templates.en-us.md deleted file mode 100644 index 5220e0c7a0..0000000000 --- a/docs/content/usage/issue-pull-request-templates.en-us.md +++ /dev/null @@ -1,328 +0,0 @@ ---- -date: "2018-05-10T16:00:00+02:00" -title: "Issue and Pull Request templates" -slug: "issue-pull-request-templates" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /en-us/issue-pull-request-templates -menu: - sidebar: - parent: "usage" - name: "Issue and Pull Request templates" - sidebar_position: 15 - identifier: "issue-pull-request-templates" ---- - -# Issue and Pull Request Templates - -Some projects have a standard list of questions that users need to answer -when creating an issue or pull request. Gitea supports adding templates to the -**default branch of the repository** so that they can autopopulate the form when users are -creating issues and pull requests. This will cut down on the initial back and forth -of getting some clarifying details. -It is currently not possible to provide generic issue/pull-request templates globally. - -Additionally, the New Issue page URL can be suffixed with `?title=Issue+Title&body=Issue+Text` and the form will be populated with those strings. Those strings will be used instead of the template if there is one. - -## File names - -Possible file names for issue templates: - -- `ISSUE_TEMPLATE.md` -- `ISSUE_TEMPLATE.yaml` -- `ISSUE_TEMPLATE.yml` -- `issue_template.md` -- `issue_template.yaml` -- `issue_template.yml` -- `.gitea/ISSUE_TEMPLATE.md` -- `.gitea/ISSUE_TEMPLATE.yaml` -- `.gitea/ISSUE_TEMPLATE.yml` -- `.gitea/issue_template.md` -- `.gitea/issue_template.yaml` -- `.gitea/issue_template.yml` -- `.github/ISSUE_TEMPLATE.md` -- `.github/ISSUE_TEMPLATE.yaml` -- `.github/ISSUE_TEMPLATE.yml` -- `.github/issue_template.md` -- `.github/issue_template.yaml` -- `.github/issue_template.yml` - -Possible file names for issue config: - -- `.gitea/ISSUE_TEMPLATE/config.yaml` -- `.gitea/ISSUE_TEMPLATE/config.yml` -- `.gitea/issue_template/config.yaml` -- `.gitea/issue_template/config.yml` -- `.github/ISSUE_TEMPLATE/config.yaml` -- `.github/ISSUE_TEMPLATE/config.yml` -- `.github/issue_template/config.yaml` -- `.github/issue_template/config.yml` - -Possible file names for PR templates: - -- `PULL_REQUEST_TEMPLATE.md` -- `PULL_REQUEST_TEMPLATE.yaml` -- `PULL_REQUEST_TEMPLATE.yml` -- `pull_request_template.md` -- `pull_request_template.yaml` -- `pull_request_template.yml` -- `.gitea/PULL_REQUEST_TEMPLATE.md` -- `.gitea/PULL_REQUEST_TEMPLATE.yaml` -- `.gitea/PULL_REQUEST_TEMPLATE.yml` -- `.gitea/pull_request_template.md` -- `.gitea/pull_request_template.yaml` -- `.gitea/pull_request_template.yml` -- `.github/PULL_REQUEST_TEMPLATE.md` -- `.github/PULL_REQUEST_TEMPLATE.yaml` -- `.github/PULL_REQUEST_TEMPLATE.yml` -- `.github/pull_request_template.md` -- `.github/pull_request_template.yaml` -- `.github/pull_request_template.yml` - -## Directory names - -Alternatively, users can create multiple issue templates inside a special directory and allow users to choose one that more specifically -addresses their problem. - -Possible directory names for issue templates: - -- `ISSUE_TEMPLATE` -- `issue_template` -- `.gitea/ISSUE_TEMPLATE` -- `.gitea/issue_template` -- `.github/ISSUE_TEMPLATE` -- `.github/issue_template` -- `.gitlab/ISSUE_TEMPLATE` -- `.gitlab/issue_template` - -Inside the directory can be multiple markdown (`.md`) or yaml (`.yaml`/`.yml`) issue templates of the form. - -## Syntax for markdown template - -```md ---- - -name: "Template Name" -about: "This template is for testing!" -title: "[TEST] " -ref: "main" -labels: - -- bug -- "help needed" - ---- - -This is the template! -``` - -In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description -`This template is for testing!`. When submitting an issue with the above example, the issue title would be pre-populated with -`[TEST] ` while the issue body would be pre-populated with `This is the template!`. The issue would also be assigned two labels, -`bug` and `help needed`, and the issue will have a reference to `main`. - -## Syntax for yaml template - -This example YAML configuration file defines an issue form using several inputs to report a bug. - -```yaml -name: Bug Report -about: File a bug report -title: "[Bug]: " -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! - # some markdown that will only be visible once the issue has been created - - type: markdown - attributes: - value: | - This issue was created by an issue **template** :) - visible: [content] - - type: input - id: contact - attributes: - label: Contact Details - description: How can we get in touch with you if we need more info? - placeholder: ex. email@example.com - validations: - required: false - - type: textarea - id: what-happened - attributes: - label: What happened? - description: Also tell us, what did you expect to happen? - placeholder: Tell us what you see! - value: "A bug happened!" - validations: - required: true - - type: dropdown - id: version - attributes: - label: Version - description: What version of our software are you running? - options: - - 1.0.2 (Default) - - 1.0.3 (Edge) - validations: - required: true - - type: dropdown - id: browsers - attributes: - label: What browsers are you seeing the problem on? - multiple: true - options: - - Firefox - - Chrome - - Safari - - Microsoft Edge - - type: textarea - id: logs - attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. - render: shell - - type: checkboxes - id: terms - attributes: - label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) - options: - - label: I agree to follow this project's Code of Conduct - required: true - - label: I have also read the CONTRIBUTION.MD - required: true - visible: [form] - - label: This is a TODO only visible after issue creation - visible: [content] -``` - -### Markdown - -You can use a `markdown` element to display Markdown in your form that provides extra context to the user, but is not submitted by default. - -Attributes: - -| Key | Description | Required | Type | Default | Valid values | -|-------|--------------------------------------------------------------|----------|--------|---------|--------------| -| value | The text that is rendered. Markdown formatting is supported. | Required | String | - | - | - -visible: Default is **[form]** - -### Textarea - -You can use a `textarea` element to add a multi-line text field to your form. Contributors can also attach files in `textarea` fields. - -Attributes: - -| Key | Description | Required | Type | Default | Valid values | -|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|--------|--------------|---------------------------| -| label | A brief description of the expected user input, which is also displayed in the form. | Required | String | - | - | -| description | A description of the text area to provide context or guidance, which is displayed in the form. | Optional | String | Empty String | - | -| placeholder | A semi-opaque placeholder that renders in the text area when empty. | Optional | String | Empty String | - | -| value | Text that is pre-filled in the text area. | Optional | String | - | - | -| render | If a value is provided, submitted text will be formatted into a codeblock. When this key is provided, the text area will not expand for file attachments or Markdown editing. | Optional | String | - | Languages known to Gitea. | - -Validations: - -| Key | Description | Required | Type | Default | Valid values | -|----------|------------------------------------------------------|----------|---------|---------|--------------| -| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | - -visible: Default is **[form, content]** - -### Input - -You can use an `input` element to add a single-line text field to your form. - -Attributes: - -| Key | Description | Required | Type | Default | Valid values | -|-------------|--------------------------------------------------------------------------------------------|----------|--------|--------------|--------------| -| label | A brief description of the expected user input, which is also displayed in the form. | Required | String | - | - | -| description | A description of the field to provide context or guidance, which is displayed in the form. | Optional | String | Empty String | - | -| placeholder | A semi-transparent placeholder that renders in the field when empty. | Optional | String | Empty String | - | -| value | Text that is pre-filled in the field. | Optional | String | - | - | - -Validations: - -| Key | Description | Required | Type | Default | Valid values | -|-----------|--------------------------------------------------------------------------------------------------|----------|---------|---------|--------------------------------------------------------------------------| -| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | -| is_number | Prevents form submission until element is filled with a number. | Optional | Boolean | false | - | -| regex | Prevents form submission until element is filled with a value that match the regular expression. | Optional | String | - | a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) | - -visible: Default is **[form, content]** - -### Dropdown - -You can use a `dropdown` element to add a dropdown menu in your form. - -Attributes: - -| Key | Description | Required | Type | Default | Valid values | -|-------------|-----------------------------------------------------------------------------------------------------|----------|--------------|--------------|--------------| -| label | A brief description of the expected user input, which is displayed in the form. | Required | String | - | - | -| description | A description of the dropdown to provide extra context or guidance, which is displayed in the form. | Optional | String | Empty String | - | -| multiple | Determines if the user can select more than one option. | Optional | Boolean | false | - | -| options | An array of options the user can choose from. Cannot be empty and all choices must be distinct. | Required | String array | - | - | - -Validations: - -| Key | Description | Required | Type | Default | Valid values | -|----------|------------------------------------------------------|----------|---------|---------|--------------| -| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | - -visible: Default is **[form, content]** - -### Checkboxes - -You can use the `checkboxes` element to add a set of checkboxes to your form. - -Attributes: - -| Key | Description | Required | Type | Default | Valid values | -| ----------- | ----------------------------------------------------------------------------------------------------- | -------- | ------ | ------------ | ------------ | -| label | A brief description of the expected user input, which is displayed in the form. | Required | String | - | - | -| description | A description of the set of checkboxes, which is displayed in the form. Supports Markdown formatting. | Optional | String | Empty String | - | -| options | An array of checkboxes that the user can select. For syntax, see below. | Required | Array | - | - | - -For each value in the options array, you can set the following keys. - -| Key | Description | Required | Type | Default | Options | -|--------------|------------------------------------------------------------------------------------------------------------------------------------------|----------|--------------|---------|---------| -| label | The identifier for the option, which is displayed in the form. Markdown is supported for bold or italic text formatting, and hyperlinks. | Required | String | - | - | -| required | Prevents form submission until element is completed. | Optional | Boolean | false | - | -| visible | Whether a specific checkbox appears in the form only, in the created issue only, or both. Valid options are "form" and "content". | Optional | String array | false | - | - -visible: Default is **[form, content]** - -## Syntax for issue config - -This is a example for a issue config file - -```yaml -blank_issues_enabled: true -contact_links: - - name: Gitea - url: https://gitea.com - about: Visit the Gitea Website -``` - -### Possible Options - -| Key | Description | Type | Default | -|----------------------|-------------------------------------------------------|--------------------|-------------| -| blank_issues_enabled | If set to false, the User is forced to use a Template | Boolean | true | -| contact_links | Custom Links to show in the Choose Box | Contact Link Array | Empty Array | - -### Contact Link - -| Key | Description | Type | Required | -|-------|----------------------------------|--------|----------| -| name | the name of your link | String | true | -| url | The URL of your Link | String | true | -| about | A short description of your Link | String | true | diff --git a/docs/content/usage/issue-pull-request-templates.zh-cn.md b/docs/content/usage/issue-pull-request-templates.zh-cn.md deleted file mode 100644 index fe865e3358..0000000000 --- a/docs/content/usage/issue-pull-request-templates.zh-cn.md +++ /dev/null @@ -1,294 +0,0 @@ ---- -date: "2022-09-07T16:00:00+08:00" -title: "工单与合并请求模板" -slug: "issue-pull-request-templates" -sidebar_position: 15 -toc: true -draft: false -aliases: - - /zh-cn/issue-pull-request-templates -menu: - sidebar: - parent: "usage" - name: "工单与合并请求模板" - sidebar_position: 15 - identifier: "issue-pull-request-templates" ---- - -# 从模板创建工单与合并请求 - -开发者可以利用问题模板创建工单与合并请求,其目的在于规范参与者的语言表达。 - -## 模板介绍 - -Gitea 支持两种格式的模板:Markdown 和 YAML。 - -### Markdown 模板 - -在 Gitea 中存在两种用途的 Markdown 模板: - -- `ISSUE_TEMPLATE/bug-report.md` 用于规范工单的 Markdown 文本描述 -- `PULL_REQUEST_TEMPLATE.md` 用于规范合并请求的 Markdown 文本描述 - -对于以上 Markdown 模板,我们推荐您将它们放置到项目目录 `.gitea` 进行收纳。 - -### YAML 模板 - -用 YAML 语法编写的模板相比 Markdown 可以实现更丰富的功能,利用表单实现诸如:问卷调查、字符校验。在 Gitea 中的 YAML 同样支持两种用途: - -- `ISSUE_TEMPLATE/bug-report.yaml` 用于创建问卷调查形式的工单 -- `PULL_REQUEST_TEMPLATE.yaml` 用于创建表单形式的合并请求 - -对于以上 YAML 模板,我们同样推荐您将它们放置到项目目录 `.gitea` 进行收纳。 - -##### 表单支持通过 URL 查询参数传值 - -当新建工单页面 URL 以 `?title=Issue+Title&body=Issue+Text` 为查询参数,表单将使用其中的参数(key-value)填充表单内容。 - -### Gitea 支持的模板文件路径 - -工单模板文件名: - -- `ISSUE_TEMPLATE.md` -- `ISSUE_TEMPLATE.yaml` -- `ISSUE_TEMPLATE.yml` -- `issue_template.md` -- `issue_template.yaml` -- `issue_template.yml` -- `.gitea/ISSUE_TEMPLATE.md` -- `.gitea/ISSUE_TEMPLATE.yaml` -- `.gitea/ISSUE_TEMPLATE.yml` -- `.gitea/issue_template.md` -- `.gitea/issue_template.yaml` -- `.gitea/issue_template.yml` -- `.github/ISSUE_TEMPLATE.md` -- `.github/ISSUE_TEMPLATE.yaml` -- `.github/ISSUE_TEMPLATE.yml` -- `.github/issue_template.md` -- `.github/issue_template.yaml` -- `.github/issue_template.yml` - -合并请求模板: - -- `PULL_REQUEST_TEMPLATE.md` -- `PULL_REQUEST_TEMPLATE.yaml` -- `PULL_REQUEST_TEMPLATE.yml` -- `pull_request_template.md` -- `pull_request_template.yaml` -- `pull_request_template.yml` -- `.gitea/PULL_REQUEST_TEMPLATE.md` -- `.gitea/PULL_REQUEST_TEMPLATE.yaml` -- `.gitea/PULL_REQUEST_TEMPLATE.yml` -- `.gitea/pull_request_template.md` -- `.gitea/pull_request_template.yaml` -- `.gitea/pull_request_template.yml` -- `.github/PULL_REQUEST_TEMPLATE.md` -- `.github/PULL_REQUEST_TEMPLATE.yaml` -- `.github/PULL_REQUEST_TEMPLATE.yml` -- `.github/pull_request_template.md` -- `.github/pull_request_template.yaml` -- `.github/pull_request_template.yml` - -#### 工单模板目录 - -由于工单存在多种类型,Gitea 支持将工单模板统一收纳到 `ISSUE_TEMPLATE` 目录。以下是 Gitea 支持的工单模板目录: - -- `ISSUE_TEMPLATE` -- `issue_template` -- `.gitea/ISSUE_TEMPLATE` -- `.gitea/issue_template` -- `.github/ISSUE_TEMPLATE` -- `.github/issue_template` -- `.gitlab/ISSUE_TEMPLATE` -- `.gitlab/issue_template` - -目录支持混合存放 Markdown (`.md`) 或 YAML (`.yaml`/`.yml`) 格式的工单模板。另外,合并请求模板不支持目录存放。 - -## Markdown 模板语法 - -```md ---- - -name: "Template Name" -about: "This template is for testing!" -title: "[TEST] " -ref: "main" -labels: - -- bug -- "help needed" - ---- - -This is the template! -``` - -上面的示例表示用户从列表中选择一个工单模板时,列表会展示模板名称 `Template Name` 和模板描述 `This template is for testing!`。 同时,标题会预先填充为 `[TEST]`,而正文将预先填充 `This is the template!`。 最后,Issue 还会被分配两个标签,`bug` 和 `help needed`,并且将问题指向 `main` 分支。 - -## YAML 模板语法 - -YAML 模板格式如下,相比 Markdown 模板提供了更多实用性的功能。 - -```yaml -name: 表单名称 -about: 表单描述 -title: 默认标题 -body: 主体内容 - type: 定义表单元素类型 - id: 定义表单标号 - attributes: 扩展的属性 - validations: 内容校验 -``` - -下例 YAML 配置文件完整定义了一个用于提交 bug 的问卷调查。 - -```yaml -name: Bug Report -about: File a bug report -title: "[Bug]: " -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! - - type: input - id: contact - attributes: - label: Contact Details - description: How can we get in touch with you if we need more info? - placeholder: ex. email@example.com - validations: - required: false - - type: textarea - id: what-happened - attributes: - label: What happened? - description: Also tell us, what did you expect to happen? - placeholder: Tell us what you see! - value: "A bug happened!" - validations: - required: true - - type: dropdown - id: version - attributes: - label: Version - description: What version of our software are you running? - options: - - 1.0.2 (Default) - - 1.0.3 (Edge) - validations: - required: true - - type: dropdown - id: browsers - attributes: - label: What browsers are you seeing the problem on? - multiple: true - options: - - Firefox - - Chrome - - Safari - - Microsoft Edge - - type: textarea - id: logs - attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. - render: shell - - type: checkboxes - id: terms - attributes: - label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) - options: - - label: I agree to follow this project's Code of Conduct - required: true -``` - -### Markdown 段落 - -您可以在 YAML 模板中使用 `markdown` 元素为开发者提供额外的上下文支撑,这部分内容会作为创建工单的提示但不会作为工单内容提交。 - -`attributes` 子项提供了以下扩展能力: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ------- | ------------------------------ | ---- | ------ | ------ | ------ | -| `value` | 渲染的文本。支持 Markdown 格式 | 必选 | 字符串 | - | - | - -### Textarea 多行文本输入框 - -您可以使用 `textarea` 元素在表单中添加多行文本输入框。 除了输入文本,开发者还可以在 `textarea` 区域附加文件。 - -`attributes` 子项提供了以下扩展能力: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ------------- | ----------------------------------------------------------------------------------------------------- | ---- | ------ | -------- | ------------------ | -| `label` | 预期用户输入的简短描述,也以表单形式显示。 | 必选 | 字符串 | - | - | -| `description` | 提供上下文或指导的文本区域的描述,以表单形式显示。 | 可选 | 字符串 | 空字符串 | - | -| `placeholder` | 半透明的占位符,在文本区域空白时呈现 | 可选 | 字符串 | 空字符串 | - | -| `value` | 在文本区域中预填充的文本。 | 可选 | 字符串 | - | - | -| `render` | 如果提供了值,提交的文本将格式化为代码块。 提供此键时,文本区域将不会扩展到文件附件或 Markdown 编辑。 | 可选 | 字符串 | - | Gitea 支持的语言。 | - -`validations` 子项提供以下文本校验参数: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ---------- | ---------------------------- | ---- | ------ | ------ | ------ | -| `required` | 防止在元素完成之前提交表单。 | 可选 | 布尔型 | false | - | - -### Input 单行输入框 - -您可以使用 `input` 元素添加单行文本字段到表单。 - -`attributes` 子项提供了以下扩展能力: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ------------- | ---------------------------------------------- | ---- | ------ | -------- | ------ | -| `label` | 预期用户输入的简短描述,也以表单形式显示。 | 必选 | 字符串 | - | - | -| `description` | 提供上下文或指导的字段的描述,以表单形式显示。 | 可选 | 字符串 | 空字符串 | - | -| `placeholder` | 半透明的占位符,在字段空白时呈现。 | 可选 | 字符串 | 空字符串 | - | -| `value` | 字段中预填的文本。 | 可选 | 字符串 | - | - | - -`validations` 子项提供以下文本校验参数: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ----------- | -------------------------------- | ---- | ------ | ------ | -------------------------------------------------------------- | -| `required` | 防止在未填内容时提交表单。 | 可选 | 布尔型 | false | - | -| `is_number` | 防止在未填数字时提交表单。 | 可选 | 布尔型 | false | - | -| `regex` | 直到满足了与正则表达式匹配的值。 | 可选 | 字符串 | - | [正则表达式](https://en.wikipedia.org/wiki/Regular_expression) | - -### Dropdown 下拉菜单 - -您可以使用 `dropdown` 元素在表单中添加下拉菜单。 - -`attributes` 子项提供了以下扩展能力: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ------------- | --------------------------------------------------------- | ---- | ---------- | -------- | ------ | -| `label` | 预期用户输入的简短描述,以表单形式显示。 | 必选 | 字符串 | - | - | -| `description` | 提供上下文或指导的下拉列表的描述,以表单形式显示。 | 可选 | 字符串 | 空字符串 | - | -| `multiple` | 确定用户是否可以选择多个选项。 | 可选 | 布尔型 | false | - | -| `options` | 用户可以选择的选项列表。 不能为空,所有选择必须是不同的。 | 必选 | 字符串数组 | - | - | - -`validations` 子项提供以下文本校验参数: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ---------- | ---------------------------- | ---- | ------ | ------ | ------ | -| `required` | 防止在元素完成之前提交表单。 | 可选 | 布尔型 | false | - | - -### Checkboxes 复选框 - -您可以使用 `checkboxes` 元素添加一组复选框到表单。 - -`attributes` 子项提供了以下扩展能力: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ------------- | ----------------------------------------------------- | ---- | ------ | -------- | ------ | -| `label` | 预期用户输入的简短描述,以表单形式显示。 | 必选 | 字符串 | - | - | -| `description` | 复选框集的描述,以表单形式显示。 支持 Markdown 格式。 | 可选 | 字符串 | 空字符串 | - | -| `options` | 用户可以选择的复选框列表。 有关语法,请参阅下文。 | 必选 | 数组 | - | - | - -对于 `options`,您可以设置以下参数: - -| 键 | 描述 | 必选 | 类型 | 默认值 | 有效值 | -| ---------- | --------------------------------------------------------------------------------- | ---- | ------ | ------ | ------ | -| `label` | 选项的标识符,显示在表单中。 支持 Markdown 用于粗体或斜体文本格式化和超文本链接。 | 必选 | 字符串 | - | - | -| `required` | 防止在元素完成之前提交表单。 | 可选 | 布尔型 | false | - | diff --git a/docs/content/usage/labels.en-us.md b/docs/content/usage/labels.en-us.md deleted file mode 100644 index 4058ca14e4..0000000000 --- a/docs/content/usage/labels.en-us.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -date: "2023-03-04T19:00:00+00:00" -title: "Labels" -slug: "labels" -sidebar_position: 13 -toc: false -draft: false -aliases: - - /en-us/labels -menu: - sidebar: - parent: "usage" - name: "Labels" - sidebar_position: 13 - identifier: "labels" ---- - -# Labels - -You can use labels to classify issues and pull requests and to improve your overview over them. - -## Creating Labels - -For repositories, labels can be created by going to `Issues` and clicking on `Labels`. - -For organizations, you can define organization-wide labels that are shared with all organization repositories, including both already-existing repositories as well as newly created ones. Organization-wide labels can be created in the organization `Settings`. - -Labels have a mandatory name, a mandatory color, an optional description, and must either be exclusive or not (see `Scoped Labels` below). - -When you create a repository, you can ensure certain labels exist by using the `Issue Labels` option. This option lists a number of available label sets that are [configured globally on your instance](../administration/customizing-gitea/#labels). Its contained labels will all be created as well while creating the repository. - -## Scoped Labels - -Scoped labels are used to ensure at most a single label with the same scope is assigned to an issue or pull request. For example, if labels `kind/bug` and `kind/enhancement` have the Exclusive option set, an issue can only be classified as a bug or an enhancement. - -A scoped label must contain `/` in its name (not at either end of the name). The scope of a label is determined based on the **last** `/`, so for example the scope of label `scope/subscope/item` is `scope/subscope`. - -## Filtering by Label - -Issue and pull request lists can be filtered by label. Selecting multiple labels shows issues and pull requests that have all selected labels assigned. - -By holding alt to click the label, issues and pull requests with the chosen label are excluded from the list. diff --git a/docs/content/usage/labels.zh-cn.md b/docs/content/usage/labels.zh-cn.md deleted file mode 100644 index b9cf39304e..0000000000 --- a/docs/content/usage/labels.zh-cn.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "标签" -slug: "labels" -sidebar_position: 13 -toc: false -draft: false -aliases: - - /zh-cn/labels -menu: - sidebar: - parent: "usage" - name: "标签" - sidebar_position: 13 - identifier: "labels" ---- - -# 标签 - -您可以使用标签对工单和合并请求进行分类,并提高对它们的概览。 - -## 创建标签 - -对于仓库,可以在 `工单(Issues)` 中点击 `标签(Labels)` 来创建标签。 - -对于组织,您可以定义组织级别的标签,这些标签与所有组织仓库共享,包括已存在的仓库和新创建的仓库。可以在组织的 `设置(Settings)` 中创建组织级别的标签。 - -标签具有必填的名称和颜色,可选的描述,以及必须是独占的或非独占的(见下面的“作用域标签”)。 - -当您创建一个仓库时,可以通过使用 `工单标签(Issue Labels)` 选项来选择标签集。该选项列出了一些在您的实例上 [全局配置的可用标签集](administration/customizing-gitea.md#labels)。在创建仓库时,这些标签也将被创建。 - -## 作用域标签 - -作用域标签用于确保将至多一个具有相同作用域的标签分配给工单或合并请求。例如,如果标签 `kind/bug` 和 `kind/enhancement` 的独占选项被设置,那么工单只能被分类为 bug 或 enhancement 中的一个。 - -作用域标签的名称必须包含 `/`(不能在名称的任一端)。标签的作用域是基于最后一个 `/` 决定的,因此例如标签 `scope/subscope/item` 的作用域是 `scope/subscope`。 - -## 按标签筛选 - -工单和合并请求列表可以按标签进行筛选。选择多个标签将显示具有所有选定标签的工单和合并请求。 - -通过按住 alt 键并单击标签,可以将具有所选标签的工单和合并请求从列表中排除。 diff --git a/docs/content/usage/linked-references.en-us.md b/docs/content/usage/linked-references.en-us.md deleted file mode 100644 index a0acb0242d..0000000000 --- a/docs/content/usage/linked-references.en-us.md +++ /dev/null @@ -1,201 +0,0 @@ ---- -date: "2019-11-21T17:00:00-03:00" -title: "Automatically Linked References" -slug: "automatically-linked-references" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /en-us/automatically-linked-references -menu: - sidebar: - parent: "usage" - name: "Automatically Linked References" - sidebar_position: 15 - identifier: "automatically-linked-references" ---- - -# Automatically Linked References in Issues, Pull Requests and Commit Messages - -When an issue, pull request or comment is posted, the text description is parsed -in search for references. These references will be shown as links in the Issue View -and, in some cases, produce certain _actions_. - -Likewise, commit messages are parsed when they are listed, and _actions_ -can be triggered when they are pushed to the main branch. - -To prevent the creation of unintended references, there are certain rules -for them to be recognized. For example, they should not be included inside code -text. They should also be reasonably cleared from their surrounding text -(for example, using spaces). - -## User, Team and Organization Mentions - -When a text in the form `@username` is found and `username` matches the name -of an existing user, a _mention_ reference is created. This will be shown -by changing the text into a link to said user's profile, and possibly create -a notification for the mentioned user depending on whether they have -the necessary permission to access the contents. - -Example: - -> [@John](#), can you give this a look? - -This is also valid for teams and organizations: - -> [@Documenters](#), we need to plan for this. -> [@CoolCompanyInc](#), this issue concerns us all! - -Teams will receive mail notifications when appropriate, but whole organizations won't. - -Commit messages do not produce user notifications. - -## Commits - -Commits can be referenced using their SHA1 hash, or a portion of it of -at least seven characters. They will be shown as a link to the corresponding -commit. - -Example: - -> This bug was introduced in [e59ff077](#) - -## Issues and Pull Requests - -A reference to another issue or pull request can be created using the simple -notation `#1234`, where _1234_ is the number of an issue or pull request -in the same repository. These references will be shown as links to the -referenced content. - -The effect of creating this type of reference is that a _notice_ will be -created in the referenced document, provided the creator of the reference -has reading permissions on it. - -Example: - -> This seems related to [#1234](#) - -Issues and pull requests in other repositories can be referred to as well -using the form `owner/repository#1234`: - -> This seems related to [mike/compiler#1234](#) - -Alternatively, the `!1234` notation can be used as well. Even when in Gitea -a pull request is a form of issue, the `#1234` form will always link to -an issue; if the linked entry happens to be a pull request instead, Gitea -will redirect as appropriate. With the `!1234` notation, a pull request -link will be created, which will be redirected to an issue if required. -However, this distinction could be important if an external tracker is -used, where links to issues and pull requests are not interchangeable. - -## Actionable References in Pull Requests and Commit Messages - -Sometimes a commit or pull request may fix or bring back a problem documented -in a particular issue. Gitea supports closing and reopening the referenced -issues by preceding the reference with a particular _keyword_. Common keywords -include "closes", "fixes", "reopens", etc. This list can be -[customized](administration/config-cheat-sheet.md) by the -site administrator. - -Example: - -> This PR _closes_ [#1234](#) - -If the actionable reference is accepted, this will create a notice on the -referenced issue announcing that it will be closed when the referencing PR -is merged. - -For an actionable reference to be accepted, _at least one_ of the following -conditions must be met: - -- The commenter has permissions to close or reopen the issue at the moment - of creating the reference. -- The reference is inside a commit message. -- The reference is posted as part of the pull request description. - -In the last case, the issue will be closed or reopened only if the merger -of the pull request has permissions to do so. - -Additionally, only pull requests and commit messages can create an action, -and only issues can be closed or reopened this way. - -The default _keywords_ are: - -- **Closing**: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved -- **Reopening**: reopen, reopens, reopened - -## Time tracking in Pull Requests and Commit Messages - -When commit or merging of pull request results in automatic closing of issue -it is possible to also add spent time resolving this issue through commit message. - -To specify spent time on resolving issue you need to specify time in format -`@<number><time-unit>` after issue number. In one commit message you can specify -multiple fixed issues and spent time for each of them. - -Supported time units (`<time-unit>`): - -- `m` - minutes -- `h` - hours -- `d` - days (equals to 8 hours) -- `w` - weeks (equals to 5 days) -- `mo` - months (equals to 4 weeks) - -Numbers to specify time (`<number>`) can be also decimal numbers, ex. `@1.5h` would -result in one and half hours. Multiple time units can be combined, ex. `@1h10m` would -mean 1 hour and 10 minutes. - -Example of commit message: - -> Fixed #123 spent @1h, refs #102, fixes #124 @1.5h - -This would result in 1 hour added to issue #123 and 1 and half hours added to issue #124. - -## External Trackers - -Gitea supports the use of external issue trackers, and references to issues -hosted externally can be created in pull requests. However, if the external -tracker uses numbers to identify issues, they will be indistinguishable from -the pull requests hosted in Gitea. To address this, Gitea allows the use of -the `!` marker to identify pull requests. For example: - -> This is issue [#1234](#), and links to the external tracker. -> This is pull request [!1234](#), and links to a pull request in Gitea. - -The `!` and `#` can be used interchangeably for issues and pull request _except_ -for this case, where a distinction is required. If the repository uses external -tracker, commit message for squash merge will use `!` as reference by default. - -## Issues and Pull Requests References Summary - -This table illustrates the different kinds of cross-reference for issues and pull requests. -In the examples, `User1/Repo1` refers to the repository where the reference is used, while -`UserZ/RepoZ` indicates a different repository. - -| Reference in User1/Repo1 | Repo1 issues are external | RepoZ issues are external | Should render | -| --------------------------- | :-----------------------: | :-----------------------: | ------------------------------------------------------- | -| `#1234` | no | - | A link to issue/pull 1234 in `User1/Repo1` | -| `!1234` | no | - | A link to issue/pull 1234 in `User1/Repo1` | -| `#1234` | yes | - | A link to _external issue_ 1234 for `User1/Repo1` | -| `!1234` | yes | - | A link to _PR_ 1234 for `User1/Repo1` | -| `User1/Repo1#1234` | no | - | A link to issue/pull 1234 in `User1/Repo1` | -| `User1/Repo1!1234` | no | - | A link to issue/pull 1234 in `User1/Repo1` | -| `User1/Repo1#1234` | yes | - | A link to _external issue_ 1234 for `User1/Repo1` | -| `User1/Repo1!1234` | yes | - | A link to _PR_ 1234 for `User1/Repo1` | -| `UserZ/RepoZ#1234` | - | no | A link to issue/pull 1234 in `UserZ/RepoZ` | -| `UserZ/RepoZ!1234` | - | no | A link to issue/pull 1234 in `UserZ/RepoZ` | -| `UserZ/RepoZ#1234` | - | yes | A link to _external issue_ 1234 for `UserZ/RepoZ` | -| `UserZ/RepoZ!1234` | - | yes | A link to _PR_ 1234 for `UserZ/RepoZ` | -| **Alphanumeric issue IDs:** | - | - | - | -| `AAA-1234` | yes | - | A link to _external issue_ `AAA-1234` for `User1/Repo1` | -| `!1234` | yes | - | A link to _PR_ 1234 for `User1/Repo1` | -| `User1/Repo1!1234` | yes | - | A link to _PR_ 1234 for `User1/Repo1` | -| _Not supported_ | - | yes | A link to _external issue_ `AAA-1234` for `UserZ/RepoZ` | -| `UserZ/RepoZ!1234` | - | yes | A link to _PR_ 1234 in `UserZ/RepoZ` | - -_The last section is for repositories with external issue trackers that use alphanumeric format._ - -_**-**: not applicable._ - -Note: automatic references between repositories with different types of issues (external vs. internal) are not fully supported -and may render invalid links. diff --git a/docs/content/usage/linked-references.zh-cn.md b/docs/content/usage/linked-references.zh-cn.md deleted file mode 100644 index 2f1b888047..0000000000 --- a/docs/content/usage/linked-references.zh-cn.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "自动链接引用" -slug: "automatically-linked-references" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /zh-cn/automatically-linked-references -menu: - sidebar: - parent: "usage" - name: "自动链接引用s" - sidebar_position: 15 - identifier: "automatically-linked-references" ---- - -# 在工单、合并请求和提交消息中的自动链接引用 - -当发布工单、合并请求或评论时,文本描述会被解析以查找引用。这些引用将显示为工单视图中的链接,并且在某些情况下会触发特定的“操作”。 - -类似地,当列出提交消息时,它们也会被解析,并且当它们被推送到主分支时可以触发“操作”。 - -为了防止意外创建引用,对于引用的识别有一定的规则。例如,它们不应该包含在代码文本内部。它们还应该在周围的文本中合理清晰(例如,使用空格)。 - -## 用户、团队和组织提及 - -当找到形式为 `@username` 的文本,并且 `username` 与现有用户的名称匹配时,将创建一个“提及”引用。这将通过将文本更改为指向该用户个人资料的链接来显示,并根据被提及的用户是否具有访问内容所需的权限来可能创建通知。 - -示例: - -> [@John](#),你能看一下这个吗? - -对于团队和组织也是有效的: - -> [@Documenters](#),我们需要为此进行规划。 -> [@CoolCompanyInc](#),这个问题关系到我们所有人! - -团队将在适当时收到邮件通知,但整个组织不会收到通知。 - -提交消息不会产生用户通知。 - -## 提交 - -可以使用提交的 SHA1 哈希或至少七个字符的一部分来引用提交。它们将显示为指向相应提交的链接。 - -示例: - -> 这个错误是在 [e59ff077](#) 中引入的 - -## 工单和合并请求 - -可以使用简单的符号 `#1234` 来创建对另一个工单或合并请求的引用,其中 _1234_ 是同一仓库中一个工单或合并请求的编号。这些引用将显示为指向被引用内容的链接。 - -创建此类型引用的效果是,在被引用的文档中创建一个“通知”,前提是引用的创建者对其具有读取权限。 - -示例: - -> 这似乎与 [#1234](#) 相关 - -还可以使用形式 `owner/repository#1234` 来引用其他仓库中的工单和合并请求: - -> 这似乎与 [mike/compiler#1234](#) 相关 - -或者也可以使用 `!1234` 符号。虽然在 Gitea 中合并请求是工单的一种形式,但 `#1234` 形式总是链接到工单;如果链接的条目恰好是一个合并请求,Gitea 会适当地进行重定向。而使用 `!1234` 符号,则会创建一个合并请求链接,根据需要会被重定向到工单。然而,如果使用外部跟踪器,这个区别可能很重要,因为工单和合并请求的链接是不能互换的。 - -## 可操作的引用在合并请求和提交消息中 - -有时,一个提交或合并请求可能会修复或重新出现在某个特定工单中。Gitea 支持在引用之前加上特定的“关键字”来关闭和重新打开被引用的工单。常见的关键字包括“closes”、“fixes”、“reopens”等。这个列表可以由站点管理员进行 [自定义](administration/config-cheat-sheet.md)。 - -示例: - -> 这个合并请求 _closes_ [#1234](#) - -如果可操作的引用被接受,这将在被引用的工单上创建一个通知,宣布当引用的合并请求被合并时该工单将被关闭。 - -为了接受可操作的引用,必须满足以下至少一项条件之一: - -- 评论者在创建引用时具有关闭或重新打开工单的权限。 -- 引用位于提交消息中。 -- 引用作为合并请求描述的一部分发布。 - -在最后一种情况下,只有当合并合并请求的人具有相应权限时,工单才会被关闭或重新打开。 - -此外,只有合并请求和提交消息可以创建一个操作,只有工单可以通过这种方式被关闭或重新打开。 - -默认的关键字如下: - -- **关闭工单**: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved -- **重新打开工单**: reopen, reopens, reopened - -## 合并请求和提交消息中的时间跟踪 - -当提交或合并合并请求导致自动关闭工单时,还可以通过提交消息添加解决此工单所花费的时间。 - -要指定解决工单所花费的时间,需要在工单编号后面以 `@<number><time-unit>` 的格式指定时间。在一个提交消息中,可以指定多个已解决的工单,并为每个工单指定花费的时间。 - -支持的时间单位(`<time-unit>`): - -- `m` - 分钟 -- `h` - 小时 -- `d` - 天(相当于8小时) -- `w` - 周(相当于5天) -- `mo` - 月(相当于4周) - -用于指定时间的数字(`<number>`)也可以是小数,例如 `@1.5h` 表示一小时半。多个时间单位可以结合使用,例如 `@1h10m` 表示1小时10分钟。 - -提交消息示例: - -> Fixed #123 spent @1h, refs #102, fixes #124 @1.5h - -这将导致工单 #123 增加 1 小时,工单 #124 增加 1 小时半。 - -## 外部跟踪器 - -Gitea 支持使用外部工单跟踪器,并可以在合并请求中创建对外部托管的工单的引用。但是,如果外部跟踪器使用数字来标识工单,那么它们将与 Gitea 中托管的合并请求无法区分。为了解决这个问题,Gitea 允许使用 `!` 标记来标识合并请求。例如: - -> 这是工单 [#1234](#),并链接到外部跟踪器。 -> 这是合并请求 [!1234](#),并链接到 Gitea 中的合并请求。 - -在工单和合并请求中,`!` 和 `#` 可以互换使用,除非需要进行区分。如果仓库使用外部跟踪器,默认情况下,合并提交消息将使用 `!` 作为引用。 - -## 工单和合并请求引用摘要 - -下表说明了工单和合并请求的不同类型的交叉引用。在示例中,`User1/Repo1` 指的是使用引用的仓库,而 `UserZ/RepoZ` 表示另一个仓库。 - -| 在 User1/Repo1 中的引用 | Repo1 的工单是外部的 | RepoZ 的工单是外部的 | 渲染效果 | -| ----------------------- | :-------------------: | :-------------------: | ------------------------------------------------ | -| `#1234` | 否 | - | 链接到 `User1/Repo1` 中的工单/合并请求 1234 | -| `!1234` | 否 | - | 链接到 `User1/Repo1` 中的工单/合并请求 1234 | -| `#1234` | 是 | - | 链接到 `User1/Repo1` 的 _外部工单_ 1234 | -| `!1234` | 是 | - | 链接到 `User1/Repo1` 的 _PR_ 1234 | -| `User1/Repo1#1234` | 否 | - | 链接到 `User1/Repo1` 中的工单/合并请求 1234 | -| `User1/Repo1!1234` | 否 | - | 链接到 `User1/Repo1` 中的工单/合并请求 1234 | -| `User1/Repo1#1234` | 是 | - | 链接到 `User1/Repo1` 的 _外部工单_ 1234 | -| `User1/Repo1!1234` | 是 | - | 链接到 `User1/Repo1` 的 _PR_ 1234 | -| `UserZ/RepoZ#1234` | - | 否 | 链接到 `UserZ/RepoZ` 中的工单/合并请求 1234 | -| `UserZ/RepoZ!1234` | - | 否 | 链接到 `UserZ/RepoZ` 中的工单/合并请求 1234 | -| `UserZ/RepoZ#1234` | - | 是 | 链接到 `UserZ/RepoZ` 的 _外部工单_ 1234 | -| `UserZ/RepoZ!1234` | - | 是 | 链接到 `UserZ/RepoZ` 的 _PR_ 1234 | -| **字母数字工单编号:** | - | - | - | -| `AAA-1234` | 是 | - | 链接到 `User1/Repo1` 的 _外部工单_ `AAA-1234` | -| `!1234` | 是 | - | 链接到 `User1/Repo1` 的 _PR_ 1234 | -| `User1/Repo1!1234` | 是 | - | 链接到 `User1/Repo1` 的 _PR_ 1234 | -| _不支持_ | - | 是 | 链接到 `UserZ/RepoZ` 的 _外部工单_ `AAA-1234` | -| `UserZ/RepoZ!1234` | - | 是 | 链接到 `UserZ/RepoZ` 中的 _PR_ 1234 | - -_最后一部分适用于使用字母数字格式的外部工单跟踪器的仓库。_ - -_**-**: 不适用_ - -注意:不完全支持具有不同类型工单(外部 vs. 内部)的仓库之间的自动引用,可能会导致无效链接。 diff --git a/docs/content/usage/merge-message-templates.en-us.md b/docs/content/usage/merge-message-templates.en-us.md deleted file mode 100644 index 5116be3387..0000000000 --- a/docs/content/usage/merge-message-templates.en-us.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -date: "2022-08-31T17:35:40+08:00" -title: "Merge Message templates" -slug: "merge-message-templates" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /en-us/merge-message-templates -menu: - sidebar: - parent: "usage" - name: "Merge Message templates" - sidebar_position: 15 - identifier: "merge-message-templates" ---- - -# Merge Message templates - -## File names - -Possible file names for PR default merge message templates: - -- `.gitea/default_merge_message/MERGE_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE-MERGE_TEMPLATE.md` -- `.gitea/default_merge_message/SQUASH_TEMPLATE.md` -- `.gitea/default_merge_message/MANUALLY-MERGED_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE-UPDATE-ONLY_TEMPLATE.md` - -## Variables - -You can use the following variables enclosed in `${}` inside these templates which follow [os.Expand](https://pkg.go.dev/os#Expand) syntax: - -- BaseRepoOwnerName: Base repository owner name of this pull request -- BaseRepoName: Base repository name of this pull request -- BaseBranch: Base repository target branch name of this pull request -- HeadRepoOwnerName: Head repository owner name of this pull request -- HeadRepoName: Head repository name of this pull request -- HeadBranch: Head repository branch name of this pull request -- PullRequestTitle: Pull request's title -- PullRequestDescription: Pull request's description -- PullRequestPosterName: Pull request's poster name -- PullRequestIndex: Pull request's index number -- PullRequestReference: Pull request's reference char with index number. i.e. #1, !2 -- ClosingIssues: return a string contains all issues which will be closed by this pull request i.e. `close #1, close #2` -- ReviewedOn: Which pull request this commit belongs to. For example `Reviewed-on: https://gitea.com/foo/bar/pulls/1` -- ReviewedBy: Who approved the pull request before the merge. For example `Reviewed-by: Jane Doe <jane.doe@example.com>` - -## Rebase - -When rebasing without a merge commit, `REBASE_TEMPLATE.md` modifies the message of the last commit. The following additional variables are available in this template: - -- CommitTitle: Commit's title -- CommitBody: Commits's body text diff --git a/docs/content/usage/merge-message-templates.zh-cn.md b/docs/content/usage/merge-message-templates.zh-cn.md deleted file mode 100644 index 0923e637a5..0000000000 --- a/docs/content/usage/merge-message-templates.zh-cn.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "合并消息模板" -slug: "merge-message-templates" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /zh-cn/merge-message-templates -menu: - sidebar: - parent: "usage" - name: "合并消息模板" - sidebar_position: 15 - identifier: "merge-message-templates" ---- - -# 合并消息模板 - -## 文件名 - -PR 默认合并消息模板可能的文件名: - -- `.gitea/default_merge_message/MERGE_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE-MERGE_TEMPLATE.md` -- `.gitea/default_merge_message/SQUASH_TEMPLATE.md` -- `.gitea/default_merge_message/MANUALLY-MERGED_TEMPLATE.md` -- `.gitea/default_merge_message/REBASE-UPDATE-ONLY_TEMPLATE.md` - -## 变量 - -您可以在这些模板中使用以下以 `${}` 包围的变量,这些变量遵循 [os.Expand](https://pkg.go.dev/os#Expand) 语法: - -- BaseRepoOwnerName:此合并请求的基础仓库所有者名称 -- BaseRepoName:此合并请求的基础仓库名称 -- BaseBranch:此合并请求的基础仓库目标分支名称 -- HeadRepoOwnerName:此合并请求的源仓库所有者名称 -- HeadRepoName:此合并请求的源仓库名称 -- HeadBranch:此合并请求的源仓库分支名称 -- PullRequestTitle:合并请求的标题 -- PullRequestDescription:合并请求的描述 -- PullRequestPosterName:合并请求的提交者名称 -- PullRequestIndex:合并请求的索引号 -- PullRequestReference:合并请求的引用字符与索引号。例如,#1、!2 -- ClosingIssues:返回一个包含将由此合并请求关闭的所有工单的字符串。例如 `close #1, close #2` - -## 变基(Rebase) - -在没有合并提交的情况下进行变基时,`REBASE_TEMPLATE.md` 修改最后一次提交的消息。此模板还提供以下附加变量: - -- CommitTitle:提交的标题 -- CommitBody:提交的正文文本 diff --git a/docs/content/usage/multi-factor-authentication.en-us.md b/docs/content/usage/multi-factor-authentication.en-us.md deleted file mode 100644 index 30323f6de5..0000000000 --- a/docs/content/usage/multi-factor-authentication.en-us.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -date: "2023-08-22T14:21:00+08:00" -title: "Multi-factor Authentication (MFA)" -slug: "multi-factor-authentication" -weight: 15 -toc: false -draft: false -menu: - sidebar: - parent: "usage" - name: "Multi-factor Authentication (MFA)" - weight: 15 - identifier: "multi-factor-authentication" ---- - -# Multi-factor Authentication (MFA) - -Multi-factor Authentication (also referred to as MFA or 2FA) enhances security by requiring a time-sensitive set of credentials in addition to a password. -If a password were later to be compromised, logging into Gitea will not be possible without the additional credentials and the account would remain secure. -Gitea supports both TOTP (Time-based One-Time Password) tokens and FIDO-based hardware keys using the Webauthn API. - -MFA can be configured within the "Security" tab of the user settings page. - -## MFA Considerations - -Enabling MFA on a user does affect how the Git HTTP protocol can be used with the Git CLI. -This interface does not support MFA, and trying to use a password normally will no longer be possible whilst MFA is enabled. -If SSH is not an option for Git operations, an access token can be generated within the "Applications" tab of the user settings page. -This access token can be used as if it were a password in order to allow the Git CLI to function over HTTP. - -> **Warning** - By its very nature, an access token sidesteps the security benefits of MFA. -> It must be kept secure and should only be used as a last resort. - -The Gitea API supports providing the relevant TOTP password in the `X-Gitea-OTP` header, as described in [API Usage](development/api-usage.md). -This should be used instead of an access token where possible. diff --git a/docs/content/usage/packages/_index.en-us.md b/docs/content/usage/packages/_index.en-us.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/docs/content/usage/packages/_index.en-us.md +++ /dev/null diff --git a/docs/content/usage/packages/alpine.en-us.md b/docs/content/usage/packages/alpine.en-us.md deleted file mode 100644 index 6cf036cb8b..0000000000 --- a/docs/content/usage/packages/alpine.en-us.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -date: "2023-03-25T00:00:00+00:00" -title: "Alpine Package Registry" -slug: "alpine" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Alpine" - sidebar_position: 4 - identifier: "alpine" ---- - -# Alpine Package Registry - -Publish [Alpine](https://pkgs.alpinelinux.org/) packages for your user or organization. - -## Requirements - -To work with the Alpine registry, you need to use a HTTP client like `curl` to upload and a package manager like `apk` to consume packages. - -The following examples use `apk`. - -## Configuring the package registry - -To register the Alpine registry add the url to the list of known apk sources (`/etc/apk/repositories`): - -``` -https://gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the packages. | -| `branch` | The branch to use. | -| `repository` | The repository to use. | - -If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication): - -``` -https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> -``` - -The Alpine registry files are signed with a RSA key which must be known to apk. Download the public key and store it in `/etc/apk/keys/`: - -```shell -curl -JO https://gitea.example.com/api/packages/{owner}/alpine/key -``` - -Afterwards update the local package index: - -```shell -apk update -``` - -## Publish a package - -To publish an Alpine package (`*.apk`), perform a HTTP `PUT` operation with the package content in the request body. - -``` -PUT https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository} -``` - -| Parameter | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | -| `branch` | The branch may match the release version of the OS, ex: `v3.17`. | -| `repository` | The repository can be used [to group packages](https://wiki.alpinelinux.org/wiki/Repositories) or just `main` or similar. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.apk \ - https://gitea.example.com/api/packages/testuser/alpine/v3.17/main -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a file with the same name twice to a package. You must delete the existing package file first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package name, version, branch, repository or architecture are invalid. | -| `409 Conflict` | A package file with the same combination of parameters exist already in the package. | - -## Delete a package - -To delete an Alpine package perform a HTTP `DELETE` operation. This will delete the package version too if there is no file left. - -``` -DELETE https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository}/{architecture}/{filename} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `owner` | The owner of the package. | -| `branch` | The branch to use. | -| `repository` | The repository to use. | -| `architecture` | The package architecture. | -| `filename` | The file to delete. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/alpine/v3.17/main/test-package-1.0.0.apk -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `204 No Content` | Success | -| `404 Not Found` | The package or file was not found. | - -## Install a package - -To install a package from the Alpine registry, execute the following commands: - -```shell -# use latest version -apk add {package_name} -# use specific version -apk add {package_name}={package_version} -``` diff --git a/docs/content/usage/packages/alpine.zh-cn.md b/docs/content/usage/packages/alpine.zh-cn.md deleted file mode 100644 index cca002caf4..0000000000 --- a/docs/content/usage/packages/alpine.zh-cn.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -date: "2023-03-25T00:00:00+00:00" -title: "Alpine 软件包注册表" -slug: "alpine" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Alpine" - sidebar_position: 4 - identifier: "alpine" ---- - -# Alpine 软件包注册表 - -在您的用户或组织中发布 [Alpine](https://pkgs.alpinelinux.org/) 软件包。 - -## 要求 - -要使用 Alpine 注册表,您需要使用像 curl 这样的 HTTP 客户端来上传包,并使用像 apk 这样的包管理器来消费包。 - -以下示例使用 `apk`。 - -## 配置软件包注册表 - -要注册 Alpine 注册表,请将 URL 添加到已知的 apk 源列表中 (`/etc/apk/repositories`): - -``` -https://gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> -``` - -| 占位符 | 描述 | -| ------------ | -------------- | -| `owner` | 软件包所有者 | -| `branch` | 要使用的分支名 | -| `repository` | 要使用的仓库名 | - -如果注册表是私有的,请在 URL 中提供凭据。您可以使用密码或[个人访问令牌](development/api-usage.md#通过-api-认证): - -``` -https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> -``` - -Alpine 注册表文件使用 RSA 密钥进行签名,apk 必须知道该密钥。下载公钥并将其存储在 `/etc/apk/keys/` 目录中: - -```shell -curl -JO https://gitea.example.com/api/packages/{owner}/alpine/key -``` - -之后,更新本地软件包索引: - -```shell -apk update -``` - -## 发布软件包 - -要发布一个 Alpine 包(`*.apk`),请执行带有包内容的 HTTP `PUT` 操作,将其放在请求体中。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository} -``` - -| 参数 | 描述 | -| ------------ | --------------------------------------------------------------------------------------------------- | -| `owner` | 包的所有者。 | -| `branch` | 分支可以与操作系统的发行版本匹配,例如:v3.17。 | -| `repository` | 仓库可以用于[分组包](https://wiki.alpinelinux.org/wiki/Repositories) 或者只是 `main` 或类似的名称。 | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.apk \ - https://gitea.example.com/api/packages/testuser/alpine/v3.17/main -``` - -如果您使用的是双重身份验证或 OAuth,请使用[个人访问令牌](development/api-usage.md#authentication)代替密码。 -您不能将具有相同名称的文件两次发布到一个包中。您必须首先删除现有的包文件。 - -服务器将以以下的 HTTP 状态码响应: - -| HTTP 状态码 | 含义 | -| ----------------- | ------------------------------------------ | -| `201 Created` | 软件包已发布。 | -| `400 Bad Request` | 软件包的名称、版本、分支、仓库或架构无效。 | -| `409 Conflict` | 具有相同参数组合的包文件已存在于软件包中。 | - -## 删除软件包 - -要删除 Alpine 包,执行 HTTP 的 DELETE 操作。如果没有文件,这将同时删除包版本。 - -``` -DELETE https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository}/{architecture}/{filename} -``` - -| 参数 | 描述 | -| -------------- | -------------- | -| `owner` | 软件包的所有者 | -| `branch` | 要使用的分支名 | -| `repository` | 要使用的仓库名 | -| `architecture` | 软件包的架构 | -| `filename` | 要删除的文件名 | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/alpine/v3.17/main/test-package-1.0.0.apk -``` - -服务器将以以下的 HTTP 状态码响应: - -| HTTP 状态码 | 含义 | -| ---------------- | ------------------ | -| `204 No Content` | 成功 | -| `404 Not Found` | 未找到软件包或文件 | - -## 安装软件包 - -要从 Alpine 注册表安装软件包,请执行以下命令: - -```shell -# use latest version -apk add {package_name} -# use specific version -apk add {package_name}={package_version} -``` diff --git a/docs/content/usage/packages/cargo.en-us.md b/docs/content/usage/packages/cargo.en-us.md deleted file mode 100644 index 356e7ff0b9..0000000000 --- a/docs/content/usage/packages/cargo.en-us.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -date: "2022-11-20T00:00:00+00:00" -title: "Cargo Package Registry" -slug: "cargo" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Cargo" - sidebar_position: 5 - identifier: "cargo" ---- - -# Cargo Package Registry - -Publish [Cargo](https://doc.rust-lang.org/stable/cargo/) packages for your user or organization. - -## Requirements - -To work with the Cargo package registry, you need [Rust and Cargo](https://www.rust-lang.org/tools/install). - -Cargo stores information about the available packages in a package index stored in a git repository. -This repository is needed to work with the registry. -The following section describes how to create it. - -## Index Repository - -Cargo stores information about the available packages in a package index stored in a git repository. -In Gitea this repository has the special name `_cargo-index`. -After a package was uploaded, its metadata is automatically written to the index. -The content of this repository should not be manually modified. - -The user or organization package settings page allows to create the index repository along with the configuration file. -If needed this action will rewrite the configuration file. -This can be useful if for example the Gitea instance domain was changed. - -If the case arises where the packages stored in Gitea and the information in the index repository are out of sync, the settings page allows to rebuild the index repository. -This action iterates all packages in the registry and writes their information to the index. -If there are lot of packages this process may take some time. - -## Configuring the package registry - -To register the package registry the Cargo configuration must be updated. -Add the following text to the configuration file located in the current users home directory (for example `~/.cargo/config.toml`): - -``` -[registry] -default = "gitea" - -[registries.gitea] -index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index -# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git - -# [net] -# git-fetch-with-cli = true -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | - -If the registry is private or you want to publish new packages, you have to configure your credentials. -Add the credentials section to the credentials file located in the current users home directory (for example `~/.cargo/credentials.toml`): - -``` -[registries.gitea] -token = "Bearer {token}" -``` - -| Parameter | Description | -| --------- | ----------- | -| `token` | Your [personal access token](development/api-usage.md#authentication) | - -## Git vs Sparse - -Currently, cargo supports two ways for fetching crates in a registry: Git index & sparse index. -Sparse index is the newest method and offers better performance when updating crates compared to git. -Since Rust 1.68, sparse is the default method for crates.io. - -## Publish a package - -Publish a package by running the following command in your project: - -```shell -cargo publish -``` - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a package from the package registry, execute the following command: - -```shell -cargo add {package_name} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `package_name` | The package name. | - -## Supported commands - -``` -cargo publish -cargo add -cargo install -cargo yank -cargo unyank -cargo search -``` diff --git a/docs/content/usage/packages/cargo.zh-cn.md b/docs/content/usage/packages/cargo.zh-cn.md deleted file mode 100644 index 285fe9c8b3..0000000000 --- a/docs/content/usage/packages/cargo.zh-cn.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -date: "2022-11-20T00:00:00+00:00" -title: "Cargo 软件包注册表" -slug: "cargo" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Cargo" - sidebar_position: 5 - identifier: "cargo" ---- - -# Cargo 软件包注册表 - -为您的用户或组织发布 [Cargo](https://doc.rust-lang.org/stable/cargo/) 软件包。 - -## 要求 - -若要使用 Cargo 软件包注册表, 您需要安装 [Rust 和 Cargo](https://www.rust-lang.org/tools/install). - -Cargo 将可用软件包的信息存储在一个存储在 git 仓库中的软件包索引中。 -这个仓库是与注册表交互所必需的。 -下面的部分将介绍如何创建它。 - -## 索引仓库 - -Cargo 将可用软件包的信息存储在一个存储在 git 仓库中的软件包索引中。 -在 Gitea 中,这个仓库有一个特殊的名称叫做 `_cargo-index`。 -在上传软件包之后,它的元数据会自动写入索引中。 -不应手动修改这个注册表的内容。 - -用户或组织软件包设置页面允许创建这个索引仓库以及配置文件。 -如果需要,此操作将重写配置文件。 -例如,如果 Gitea 实例的域名已更改,这将非常有用。 - -如果存储在 Gitea 中的软件包与索引注册表中的信息不同步,设置页面允许重建这个索引注册表。 -这个操作将遍历注册表中的所有软件包,并将它们的信息写入索引中。 -如果有很多软件包,这个过程可能需要一些时间。 - -## 配置软件包注册表 - -要注册这个软件包注册表,必须更新 Cargo 的配置。 -将以下文本添加到位于当前用户主目录中的配置文件中(例如 `~/.cargo/config.toml`): - -``` -[registry] -default = "gitea" - -[registries.gitea] -index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index -# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git - -[net] -git-fetch-with-cli = true -``` - -| 参数 | 描述 | -| ------- | ---------------- | -| `owner` | 软件包的所有者。 | - -如果这个注册表是私有的或者您想要发布新的软件包,您必须配置您的凭据。 -将凭据部分添加到位于当前用户主目录中的凭据文件中(例如 `~/.cargo/credentials.toml`): - -``` -[registries.gitea] -token = "Bearer {token}" -``` - -| 参数 | 描述 | -| ------- | ------------------------------------------------------------------------------------- | -| `token` | 您的[个人访问令牌](development/api-usage.md#通过-api-认证) | - -## 发布软件包 - -在项目中运行以下命令来发布软件包: - -```shell -cargo publish -``` - -如果已经存在同名和版本的软件包,您将无法发布新的软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装软件包,请执行以下命令: - -```shell -cargo add {package_name} -``` - -| 参数 | 描述 | -| -------------- | ------------ | -| `package_name` | 软件包名称。 | - -## 支持的命令 - -``` -cargo publish -cargo add -cargo install -cargo yank -cargo unyank -cargo search -``` diff --git a/docs/content/usage/packages/chef.en-us.md b/docs/content/usage/packages/chef.en-us.md deleted file mode 100644 index 9f23b9eac8..0000000000 --- a/docs/content/usage/packages/chef.en-us.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -date: "2023-01-20T00:00:00+00:00" -title: "Chef Package Registry" -slug: "chef" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Chef" - sidebar_position: 5 - identifier: "chef" ---- - -# Chef Package Registry - -Publish [Chef](https://chef.io/) cookbooks for your user or organization. - -## Requirements - -To work with the Chef package registry, you have to use [`knife`](https://docs.chef.io/workstation/knife/). - -## Authentication - -The Chef package registry does not use an username:password authentication but signed requests with a private:public key pair. -Visit the package owner settings page to create the necessary key pair. -Only the public key is stored inside Gitea. if you loose access to the private key you must re-generate the key pair. -[Configure `knife`](https://docs.chef.io/workstation/knife_setup/) to use the downloaded private key with your Gitea username as `client_name`. - -## Configure the package registry - -To [configure `knife`](https://docs.chef.io/workstation/knife_setup/) to use the Gitea package registry add the url to the `~/.chef/config.rb` file. - -``` -knife[:supermarket_site] = 'https://gitea.example.com/api/packages/{owner}/chef' -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | - -## Publish a package - -To publish a Chef package execute the following command: - -```shell -knife supermarket share {package_name} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `package_name` | The package name. | - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a package from the package registry, execute the following command: - -```shell -knife supermarket install {package_name} -``` - -Optional you can specify the package version: - -```shell -knife supermarket install {package_name} {package_version} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `package_name` | The package name. | -| `package_version` | The package version. | - -## Delete a package - -If you want to remove a package from the registry, execute the following command: - -```shell -knife supermarket unshare {package_name} -``` - -Optional you can specify the package version: - -```shell -knife supermarket unshare {package_name}/versions/{package_version} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `package_name` | The package name. | -| `package_version` | The package version. | diff --git a/docs/content/usage/packages/chef.zh-cn.md b/docs/content/usage/packages/chef.zh-cn.md deleted file mode 100644 index d76b33c13e..0000000000 --- a/docs/content/usage/packages/chef.zh-cn.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -date: "2023-01-20T00:00:00+00:00" -title: "Chef 软件包注册表" -slug: "chef" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Chef" - sidebar_position: 5 - identifier: "chef" ---- - -# Chef Package Registry - -为您的用户或组织发布 [Chef](https://chef.io/) cookbooks。 - -## 要求 - -要使用 Chef 软件包注册表,您需要使用 [`knife`](https://docs.chef.io/workstation/knife/). - -## 认证 - -Chef 软件包注册表不使用用户名和密码进行身份验证,而是使用私钥和公钥对请求进行签名。 -请访问软件包所有者设置页面以创建必要的密钥对。 -只有公钥存储在Gitea中。如果您丢失了私钥的访问权限,您必须重新生成密钥对。 -[配置 `knife`](https://docs.chef.io/workstation/knife_setup/),使用下载的私钥,并将 Gitea 用户名设置为 `client_name`。 - -## 配置软件包注册表 - -要将 [`knife` 配置](https://docs.chef.io/workstation/knife_setup/)为使用 Gitea 软件包注册表,请将 URL 添加到 `~/.chef/config.rb` 文件中。 - -``` -knife[:supermarket_site] = 'https://gitea.example.com/api/packages/{owner}/chef' -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -## 发布软件包 - -若要发布 Chef 软件包,请执行以下命令: - -```shell -knife supermarket share {package_name} -``` - -| 参数 | 描述 | -| -------------- | ---------- | -| `package_name` | 软件包名称 | - -如果已经存在同名和版本的软件包,则无法发布新的软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表中安装软件包,请执行以下命令: - -```shell -knife supermarket install {package_name} -``` - -您可以指定软件包的版本,这是可选的: - -```shell -knife supermarket install {package_name} {package_version} -``` - -| 参数 | 描述 | -| ----------------- | ---------- | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | - -## 删除软件包 - -如果您想要从注册表中删除软件包,请执行以下命令: - -```shell -knife supermarket unshare {package_name} -``` - -可选地,您可以指定软件包的版本: - -```shell -knife supermarket unshare {package_name}/versions/{package_version} -``` - -| 参数 | 描述 | -| ----------------- | ---------- | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | diff --git a/docs/content/usage/packages/composer.en-us.md b/docs/content/usage/packages/composer.en-us.md deleted file mode 100644 index 60ad52ac2d..0000000000 --- a/docs/content/usage/packages/composer.en-us.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Composer Package Registry" -slug: "composer" -sidebar_position: 10 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Composer" - sidebar_position: 10 - identifier: "composer" ---- - -# Composer Package Registry - -Publish [Composer](https://getcomposer.org/) packages for your user or organization. - -## Requirements - -To work with the Composer package registry, you can use [Composer](https://getcomposer.org/download/) to consume and a HTTP upload client like `curl` to publish packages. - -## Publish a package - -To publish a Composer package perform a HTTP PUT operation with the package content in the request body. -The package content must be the zipped PHP project with the `composer.json` file. - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -``` -PUT https://gitea.example.com/api/packages/{owner}/composer -``` - -| Parameter | Description | -| ---------- | ----------- | -| `owner` | The owner of the package. | - -If the `composer.json` file does not contain a `version` property, you must provide it as a query parameter: - -``` -PUT https://gitea.example.com/api/packages/{owner}/composer?version={x.y.z} -``` - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/project.zip \ - https://gitea.example.com/api/packages/testuser/composer -``` - -Or specify the package version as query parameter: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/project.zip \ - https://gitea.example.com/api/packages/testuser/composer?version=1.0.3 -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exists already. | - -## Configuring the package registry - -To register the package registry you need to add it to the Composer `config.json` file (which can usually be found under `<user-home-dir>/.composer/config.json`): - -```json -{ - "repositories": [{ - "type": "composer", - "url": "https://gitea.example.com/api/packages/{owner}/composer" - } - ] -} -``` - -To access the package registry using credentials, you must specify them in the `auth.json` file as follows: - -```json -{ - "http-basic": { - "gitea.example.com": { - "username": "{username}", - "password": "{password}" - } - } -} -``` - -| Parameter | Description | -| ---------- | ----------- | -| `owner` | The owner of the package. | -| `username` | Your Gitea username. | -| `password` | Your Gitea password or a personal access token. | - -## Install a package - -To install a package from the package registry, execute the following command: - -```shell -composer require {package_name} -``` - -Optional you can specify the package version: - -```shell -composer require {package_name}:{package_version} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `package_name` | The package name. | -| `package_version` | The package version. | diff --git a/docs/content/usage/packages/composer.zh-cn.md b/docs/content/usage/packages/composer.zh-cn.md deleted file mode 100644 index c37e46b57a..0000000000 --- a/docs/content/usage/packages/composer.zh-cn.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Composer 软件包注册表" -slug: "composer" -sidebar_position: 10 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Composer" - sidebar_position: 10 - identifier: "composer" ---- - -# Composer 软件包注册表 - -为您的用户或组织发布 [Composer](https://getcomposer.org/) 软件包。 - -## 要求 - -要使用 Composer 软件包注册表,您可以使用 [Composer](https://getcomposer.org/download/) 消费,并使用类似 `curl` 的 HTTP 上传客户端发布软件包。 - -## 发布软件包 - -要发布 Composer 软件包,请执行 HTTP `PUT` 操作,将软件包内容放入请求体中。 -软件包内容必须是包含 `composer.json` 文件的压缩 PHP 项目。 -如果已经存在同名和版本的软件包,则无法发布新的软件包。您必须先删除现有的软件包。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/composer -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -如果 `composer.json` 文件不包含 `version` 属性,您必须将其作为查询参数提供: - -``` -PUT https://gitea.example.com/api/packages/{owner}/composer?version={x.y.z} -``` - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/project.zip \ - https://gitea.example.com/api/packages/testuser/composer -``` - -或者将软件包版本指定为查询参数: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/project.zip \ - https://gitea.example.com/api/packages/testuser/composer?version=1.0.3 -``` - -如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。 - -服务器将以以下 HTTP 状态码响应。 - -| HTTP 状态码 | 含义 | -| ----------------- | ----------------------------------------------------------- | -| `201 Created` | 软件包已发布 | -| `400 Bad Request` | 软件包名称和/或版本无效,或具有相同名称和版本的软件包已存在 | - -## 配置软件包注册表 - -要注册软件包注册表,您需要将其添加到 Composer 的 `config.json` 文件中(通常可以在 `<user-home-dir>/.composer/config.json` 中找到): - -```json -{ - "repositories": [{ - "type": "composer", - "url": "https://gitea.example.com/api/packages/{owner}/composer" - } - ] -} -``` - -要使用凭据访问软件包注册表,您必须在 `auth.json` 文件中指定它们,如下所示: - -```json -{ - "http-basic": { - "gitea.example.com": { - "username": "{username}", - "password": "{password}" - } - } -} -``` - -| 参数 | 描述 | -| ---------- | --------------------------- | -| `owner` | 软件包的所有者 | -| `username` | 您的 Gitea 用户名 | -| `password` | 您的Gitea密码或个人访问令牌 | - -## 安装软件包 - -要从软件包注册表中安装软件包,请执行以下命令: - -```shell -composer require {package_name} -``` - -您可以指定软件包的版本,这是可选的: - -```shell -composer require {package_name}:{package_version} -``` - -| 参数 | 描述 | -| ----------------- | ---------- | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | diff --git a/docs/content/usage/packages/conan.en-us.md b/docs/content/usage/packages/conan.en-us.md deleted file mode 100644 index 505460b319..0000000000 --- a/docs/content/usage/packages/conan.en-us.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Conan Package Registry" -slug: "conan" -sidebar_position: 20 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Conan" - sidebar_position: 20 - identifier: "conan" ---- - -# Conan Package Registry - -Publish [Conan](https://conan.io/) packages for your user or organization. - -## Requirements - -To work with the Conan package registry, you need to use the [conan](https://conan.io/downloads.html) command line tool to consume and publish packages. - -## Configuring the package registry - -To register the package registry you need to configure a new Conan remote: - -```shell -conan remote add {remote} https://gitea.example.com/api/packages/{owner}/conan -conan user --remote {remote} --password {password} {username} -``` - -| Parameter | Description | -| -----------| ----------- | -| `remote` | The remote name. | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | -| `owner` | The owner of the package. | - -For example: - -```shell -conan remote add gitea https://gitea.example.com/api/packages/testuser/conan -conan user --remote gitea --password password123 testuser -``` - -## Publish a package - -Publish a Conan package by running the following command: - -```shell -conan upload --remote={remote} {recipe} -``` - -| Parameter | Description | -| ----------| ----------- | -| `remote` | The remote name. | -| `recipe` | The recipe to upload. | - -For example: - -```shell -conan upload --remote=gitea ConanPackage/1.2@gitea/final -``` - -You cannot publish a file with the same name twice to a package. You must delete the existing package or file first. - -The Gitea Conan package registry has full [revision](https://docs.conan.io/en/latest/versioning/revisions.html) support. - -## Install a package - -To install a Conan package from the package registry, execute the following command: - -```shell -conan install --remote={remote} {recipe} -``` - -| Parameter | Description | -| ----------| ----------- | -| `remote` | The remote name. | -| `recipe` | The recipe to download. | - -For example: - -```shell -conan install --remote=gitea ConanPackage/1.2@gitea/final -``` - -## Supported commands - -``` -conan install -conan get -conan info -conan search -conan upload -conan user -conan download -conan remove -``` diff --git a/docs/content/usage/packages/conan.zh-cn.md b/docs/content/usage/packages/conan.zh-cn.md deleted file mode 100644 index 4856002525..0000000000 --- a/docs/content/usage/packages/conan.zh-cn.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Conan 软件包注册表" -slug: "conan" -sidebar_position: 20 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Conan" - sidebar_position: 20 - identifier: "conan" ---- - -# Conan 软件包注册表 - -为您的用户或组织发布 [Conan](https://conan.io/) 软件包。 - -## 要求 - -要使用 [conan](https://conan.io/downloads.html) 软件包注册表,您需要使用 conan 命令行工具来消费和发布软件包。 - -## 配置软件包注册表 - -要注册软件包注册表,您需要配置一个新的 Conan remote: - -```shell -conan remote add {remote} https://gitea.example.com/api/packages/{owner}/conan -conan user --remote {remote} --password {password} {username} -``` - -| 参数 | 描述 | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -| `remote` | 远程名称。 | -| `username` | 您的 Gitea 用户名。 | -| `password` | 您的 Gitea 密码。如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。 | -| `owner` | 软件包的所有者。 | - -例如: - -```shell -conan remote add gitea https://gitea.example.com/api/packages/testuser/conan -conan user --remote gitea --password password123 testuser -``` - -## 发布软件包 - -通过运行以下命令发布 Conan 软件包: - -```shell -conan upload --remote={remote} {recipe} -``` - -| 参数 | 描述 | -| -------- | --------------- | -| `remote` | 远程名称 | -| `recipe` | 要上传的 recipe | - -For example: - -```shell -conan upload --remote=gitea ConanPackage/1.2@gitea/final -``` - -Gitea Conan 软件包注册表支持完整的[版本修订](https://docs.conan.io/en/latest/versioning/revisions.html)。 - -## 安装软件包 - -要从软件包注册表中安装Conan软件包,请执行以下命令: - -```shell -conan install --remote={remote} {recipe} -``` - -| 参数 | 描述 | -| -------- | --------------- | -| `remote` | 远程名称 | -| `recipe` | 要下载的 recipe | - -例如: - -```shell -conan install --remote=gitea ConanPackage/1.2@gitea/final -``` - -## 支持的命令 - -``` -conan install -conan get -conan info -conan search -conan upload -conan user -conan download -conan remove -``` diff --git a/docs/content/usage/packages/conda.en-us.md b/docs/content/usage/packages/conda.en-us.md deleted file mode 100644 index a256dca51c..0000000000 --- a/docs/content/usage/packages/conda.en-us.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -date: "2022-12-28T00:00:00+00:00" -title: "Conda Package Registry" -slug: "conda" -sidebar_position: 25 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Conda" - sidebar_position: 25 - identifier: "conda" ---- - -# Conda Package Registry - -Publish [Conda](https://docs.conda.io/en/latest/) packages for your user or organization. - -## Requirements - -To work with the Conda package registry, you need to use [conda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html). - -## Configuring the package registry - -To register the package registry and provide credentials, edit your `.condarc` file: - -```yaml -channel_alias: https://gitea.example.com/api/packages/{owner}/conda -channels: - - https://gitea.example.com/api/packages/{owner}/conda -default_channels: - - https://gitea.example.com/api/packages/{owner}/conda -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | - -See the [official documentation](https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html) for explanations of the individual settings. - -If you need to provide credentials, you may embed them as part of the channel url (`https://user:password@gitea.example.com/...`). - -## Publish a package - -To publish a package, perform a HTTP PUT operation with the package content in the request body. - -``` -PUT https://gitea.example.com/api/packages/{owner}/conda/{channel}/{filename} -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | -| `channel` | The [channel](https://conda.io/projects/conda/en/latest/user-guide/concepts/channels.html) of the package. (optional) | -| `filename` | The name of the file. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/package-1.0.conda \ - https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exists already. | - -## Install a package - -To install a package from the package registry, execute one of the following commands: - -```shell -conda install {package_name} -conda install {package_name}={package_version} -conda install -c {channel} {package_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `channel` | The channel of the package. (optional) | diff --git a/docs/content/usage/packages/conda.zh-cn.md b/docs/content/usage/packages/conda.zh-cn.md deleted file mode 100644 index 6b385d2575..0000000000 --- a/docs/content/usage/packages/conda.zh-cn.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -date: "2022-12-28T00:00:00+00:00" -title: "Conda 软件包注册表" -slug: "conda" -sidebar_position: 25 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Conda" - sidebar_position: 25 - identifier: "conda" ---- - -# Conda 软件包注册表 - -为您的用户或组织发布 [Conda](https://docs.conda.io/en/latest/) 软件包。 - -## 要求 - -要使用 Conda 软件包注册表,您需要使用 [conda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html) 命令行工具。 - -## 配置软件包注册表 - -要注册软件包注册表并提供凭据,请编辑您的 `.condarc` 文件: - -```yaml -channel_alias: https://gitea.example.com/api/packages/{owner}/conda -channels: - - https://gitea.example.com/api/packages/{owner}/conda -default_channels: - - https://gitea.example.com/api/packages/{owner}/conda -``` - -| 占位符 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -有关各个设置的解释,请参阅[官方文档](https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html)。 - -如果需要提供凭据,可以将它们作为通道 URL 的一部分嵌入(`https://user:password@gitea.example.com/...`)。 - -## 发布软件包 - -要发布一个软件包,请执行一个HTTP `PUT`操作,请求正文中包含软件包内容。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/conda/{channel}/{filename} -``` - -| 占位符 | 描述 | -| ---------- | --------------------------------------------------------------------------------------------------- | -| `owner` | 软件包的所有者 | -| `channel` | 软件包的[通道](https://conda.io/projects/conda/en/latest/user-guide/concepts/channels.html)(可选) | -| `filename` | 文件名 | - -使用HTTP基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/package-1.0.conda \ - https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda -``` - -如果已经存在同名和版本的软件包,则无法发布软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表中安装软件包,请执行以下命令之一: - -```shell -conda install {package_name} -conda install {package_name}={package_version} -conda install -c {channel} {package_name} -``` - -| 参数 | 描述 | -| ----------------- | -------------------- | -| `package_name` | 软件包的名称 | -| `package_version` | 软件包的版本 | -| `channel` | 软件包的通道(可选) | diff --git a/docs/content/usage/packages/container.en-us.md b/docs/content/usage/packages/container.en-us.md deleted file mode 100644 index 5676aa36fb..0000000000 --- a/docs/content/usage/packages/container.en-us.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Container Registry" -slug: "container" -sidebar_position: 30 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Container Registry" - sidebar_position: 30 - identifier: "container" ---- - -# Container Registry - -Publish [Open Container Initiative](https://opencontainers.org/) compliant images for your user or organization. -The container registry follows the OCI specs and supports all compatible images like [Docker](https://www.docker.com/) and [Helm Charts](https://helm.sh/). - -## Requirements - -To work with the Container registry, you can use the tools for your specific image type. -The following examples use the `docker` client. - -## Login to the container registry - -To push an image or if the image is in a private registry, you have to authenticate: - -```shell -docker login gitea.example.com -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -## Image naming convention - -Images must follow this naming convention: - -`{registry}/{owner}/{image}` - -When building your docker image, using the naming convention above, this looks like: - -```shell -# build an image with tag -docker build -t {registry}/{owner}/{image}:{tag} . -# name an existing image with tag -docker tag {some-existing-image}:{tag} {registry}/{owner}/{image}:{tag} -``` - -where your registry is the domain of your gitea instance (e.g. gitea.example.com). -For example, these are all valid image names for the owner `testuser`: - -`gitea.example.com/testuser/myimage` - -`gitea.example.com/testuser/my-image` - -`gitea.example.com/testuser/my/image` - -**NOTE:** The registry only supports case-insensitive tag names. So `image:tag` and `image:Tag` get treated as the same image and tag. - -## Push an image - -Push an image by executing the following command: - -```shell -docker push gitea.example.com/{owner}/{image}:{tag} -``` - -| Parameter | Description | -| ----------| ----------- | -| `owner` | The owner of the image. | -| `image` | The name of the image. | -| `tag` | The tag of the image. | - -For example: - -```shell -docker push gitea.example.com/testuser/myimage:latest -``` - -## Pull an image - -Pull an image by executing the following command: - -```shell -docker pull gitea.example.com/{owner}/{image}:{tag} -``` - -| Parameter | Description | -| ----------| ----------- | -| `owner` | The owner of the image. | -| `image` | The name of the image. | -| `tag` | The tag of the image. | - -For example: - -```shell -docker pull gitea.example.com/testuser/myimage:latest -``` diff --git a/docs/content/usage/packages/container.zh-cn.md b/docs/content/usage/packages/container.zh-cn.md deleted file mode 100644 index 28e4835a3d..0000000000 --- a/docs/content/usage/packages/container.zh-cn.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "容器注册表" -slug: "container" -sidebar_position: 30 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "容器" - sidebar_position: 30 - identifier: "container" ---- - -# 容器注册表 - -为您的用户或组织发布符合 [Open Container Initiative(OCI)](https://opencontainers.org/) 规范的镜像。 -该容器注册表遵循 OCI 规范,并支持所有兼容的镜像类型,如 [Docker](https://www.docker.com/) 和 [Helm Charts](https://helm.sh/)。 - -## 目录 - -要使用容器注册表,您可以使用适用于特定镜像类型的工具。 -以下示例使用 `docker` 客户端。 - -## 登录容器注册表 - -要推送镜像或者如果镜像位于私有注册表中,您需要进行身份验证: - -```shell -docker login gitea.example.com -``` - -如果您使用的是 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码进行身份验证。 - -## 镜像命名约定 - -镜像必须遵循以下命名约定: - -`{registry}/{owner}/{image}` - -例如,以下是所有者为 `testuser` 的有效镜像名称示例: - -`gitea.example.com/testuser/myimage` - -`gitea.example.com/testuser/my-image` - -`gitea.example.com/testuser/my/image` - -**注意:** 该注册表仅支持大小写不敏感的标签名称。因此,`image:tag` 和 `image:Tag` 将被视为相同的镜像和标签。 - -## 推送镜像 - -通过执行以下命令来推送镜像: - -```shell -docker push gitea.example.com/{owner}/{image}:{tag} -``` - -| 参数 | 描述 | -| ------- | ------------ | -| `owner` | 镜像的所有者 | -| `image` | 镜像的名称 | -| `tag` | 镜像的标签 | - -例如: - -```shell -docker push gitea.example.com/testuser/myimage:latest -``` - -## 拉取镜像 - -通过执行以下命令来拉取镜像: - -```shell -docker pull gitea.example.com/{owner}/{image}:{tag} -``` - -| Parameter | Description | -| --------- | ------------ | -| `owner` | 镜像的所有者 | -| `image` | 镜像的名称 | -| `tag` | 镜像的标签 | - -例如: - -```shell -docker pull gitea.example.com/testuser/myimage:latest -``` diff --git a/docs/content/usage/packages/cran.en-us.md b/docs/content/usage/packages/cran.en-us.md deleted file mode 100644 index a6b0d31856..0000000000 --- a/docs/content/usage/packages/cran.en-us.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -date: "2023-01-01T00:00:00+00:00" -title: "CRAN Package Registry" -slug: "cran" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "CRAN" - sidebar_position: 35 - identifier: "cran" ---- - -# CRAN Package Registry - -Publish [R](https://www.r-project.org/) packages to a [CRAN](https://cran.r-project.org/)-like registry for your user or organization. - -## Requirements - -To work with the CRAN package registry, you need to install [R](https://cran.r-project.org/). - -## Configuring the package registry - -To register the package registry you need to add it to `Rprofile.site`, either on the system-level, user-level (`~/.Rprofile`) or project-level: - -``` -options("repos" = c(getOption("repos"), c(gitea="https://gitea.example.com/api/packages/{owner}/cran"))) -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | - -If you need to provide credentials, you may embed them as part of the url (`https://user:password@gitea.example.com/...`). - -## Publish a package - -To publish a R package, perform a HTTP `PUT` operation with the package content in the request body. - -Source packages: - -``` -PUT https://gitea.example.com/api/packages/{owner}/cran/src -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | - -Binary packages: - -``` -PUT https://gitea.example.com/api/packages/{owner}/cran/bin?platform={platform}&rversion={rversion} -``` - -| Parameter | Description | -| ---------- | ----------- | -| `owner` | The owner of the package. | -| `platform` | The name of the platform. | -| `rversion` | The R version of the binary. | - -For example: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/package.zip \ - https://gitea.example.com/api/packages/testuser/cran/bin?platform=windows&rversion=4.2 -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exists already. | - -## Install a package - -To install a R package from the package registry, execute the following command: - -```shell -install.packages("{package_name}") -``` - -| Parameter | Description | -| -------------- | ----------- | -| `package_name` | The package name. | - -For example: - -```shell -install.packages("testpackage") -``` diff --git a/docs/content/usage/packages/cran.zh-cn.md b/docs/content/usage/packages/cran.zh-cn.md deleted file mode 100644 index c8e32a64c0..0000000000 --- a/docs/content/usage/packages/cran.zh-cn.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -date: "2023-01-01T00:00:00+00:00" -title: "CRAN 软件包注册表" -slug: "cran" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "CRAN" - sidebar_position: 35 - identifier: "cran" ---- - -# CRAN 软件包注册表 - -将 [R](https://www.r-project.org/) 软件包发布到您的用户或组织的类似 [CRAN](https://cran.r-project.org/) 的注册表。 - -## 要求 - -要使用CRAN软件包注册表,您需要安装 [R](https://cran.r-project.org/)。 - -## 配置软件包注册表 - -要注册软件包注册表,您需要将其添加到 `Rprofile.site` 文件中,可以是系统级别、用户级别 `~/.Rprofile` 或项目级别: - -``` -options("repos" = c(getOption("repos"), c(gitea="https://gitea.example.com/api/packages/{owner}/cran"))) -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -如果需要提供凭据,可以将它们嵌入到URL(`https://user:password@gitea.example.com/...`)中。 - -## 发布软件包 - -要发布 R 软件包,请执行带有软件包内容的 HTTP `PUT` 操作。 - -源代码软件包: - -``` -PUT https://gitea.example.com/api/packages/{owner}/cran/src -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -二进制软件包: - -``` -PUT https://gitea.example.com/api/packages/{owner}/cran/bin?platform={platform}&rversion={rversion} -``` - -| 参数 | 描述 | -| ---------- | -------------- | -| `owner` | 软件包的所有者 | -| `platform` | 平台的名称 | -| `rversion` | 二进制的R版本 | - -例如: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/package.zip \ - https://gitea.example.com/api/packages/testuser/cran/bin?platform=windows&rversion=4.2 -``` - -如果同名和版本的软件包已存在,则无法发布软件包。您必须首先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表中安装R软件包,请执行以下命令: - -```shell -install.packages("{package_name}") -``` - -| 参数 | 描述 | -| -------------- | ----------------- | -| `package_name` | The package name. | - -例如: - -```shell -install.packages("testpackage") -``` diff --git a/docs/content/usage/packages/debian.en-us.md b/docs/content/usage/packages/debian.en-us.md deleted file mode 100644 index 6ee8530bc3..0000000000 --- a/docs/content/usage/packages/debian.en-us.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -date: "2023-01-07T00:00:00+00:00" -title: "Debian Package Registry" -slug: "debian" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Debian" - sidebar_position: 35 - identifier: "debian" ---- - -# Debian Package Registry - -Publish [Debian](https://www.debian.org/distrib/packages) packages for your user or organization. - -## Requirements - -To work with the Debian registry, you need to use a HTTP client like `curl` to upload and a package manager like `apt` to consume packages. - -The following examples use `apt`. - -## Configuring the package registry - -To register the Debian registry add the url to the list of known apt sources: - -```shell -echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list -``` - -| Placeholder | Description | -| -------------- | ----------- | -| `owner` | The owner of the package. | -| `distribution` | The distribution to use. | -| `component` | The component to use. | - -If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication): - -```shell -echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list -``` - -The Debian registry files are signed with a PGP key which must be known to apt: - -```shell -sudo curl https://gitea.example.com/api/packages/{owner}/debian/repository.key -o /etc/apt/keyrings/gitea-{owner}.asc -``` - -Afterwards update the local package index: - -```shell -apt update -``` - -## Publish a package - -To publish a Debian package (`*.deb`), perform a HTTP `PUT` operation with the package content in the request body. - -``` -PUT https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/upload -``` - -| Parameter | Description | -| -------------- | ----------- | -| `owner` | The owner of the package. | -| `distribution` | The distribution may match the release name of the OS, ex: `bionic`. | -| `component` | The component can be used to group packages or just `main` or similar. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.deb \ - https://gitea.example.com/api/packages/testuser/debian/pool/bionic/main/upload -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a package if a package of the same name, version, distribution, component and architecture already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exists already. | - -## Delete a package - -To delete a Debian package perform a HTTP `DELETE` operation. This will delete the package version too if there is no file left. - -``` -DELETE https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/{package_name}/{package_version}/{architecture} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `distribution` | The package distribution. | -| `component` | The package component. | -| `architecture` | The package architecture. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/debian/pools/bionic/main/test-package/1.0.0/amd64 -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `204 No Content` | Success | -| `404 Not Found` | The package or file was not found. | - -## Install a package - -To install a package from the Debian registry, execute the following commands: - -```shell -# use latest version -apt install {package_name} -# use specific version -apt install {package_name}={package_version} -``` diff --git a/docs/content/usage/packages/debian.zh-cn.md b/docs/content/usage/packages/debian.zh-cn.md deleted file mode 100644 index 181130c502..0000000000 --- a/docs/content/usage/packages/debian.zh-cn.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -date: "2023-01-07T00:00:00+00:00" -title: "Debian 软件包注册表" -slug: "debian" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Debian" - sidebar_position: 35 - identifier: "debian" ---- - -# Debian 软件包注册表 - -为您的用户或组织发布 [Debian](https://www.debian.org/distrib/packages) 软件包。 - -## 要求 - -要使用 Debian 注册表,您需要使用类似于 `curl` 的 HTTP 客户端进行上传,并使用类似于 `apt` 的软件包管理器消费软件包。 - -以下示例使用 `apt`。 - -## 配置软件包注册表 - -要注册 Debian 注册表,请将 URL 添加到已知 `apt` 源列表中: - -```shell -echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list -``` - -| 占位符 | 描述 | -| -------------- | -------------- | -| `owner` | 软件包的所有者 | -| `distribution` | 要使用的发行版 | -| `component` | 要使用的组件 | - -如果注册表是私有的,请在 URL 中提供凭据。您可以使用密码或[个人访问令牌](development/api-usage.md#通过-api-认证): - -```shell -echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list -``` - -Debian 注册表文件使用 PGP 密钥进行签名,`apt` 必须知道该密钥: - -```shell -sudo curl https://gitea.example.com/api/packages/{owner}/debian/repository.key -o /etc/apt/keyrings/gitea-{owner}.asc -``` - -然后更新本地软件包索引: - -```shell -apt update -``` - -## 发布软件包 - -要发布一个 Debian 软件包(`*.deb`),执行 HTTP `PUT` 操作,并将软件包内容放入请求主体中。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/upload -``` - -| 参数 | 描述 | -| -------------- | ----------------------------------------------------- | -| `owner` | 软件包的所有者 | -| `distribution` | 发行版,可能与操作系统的发行版名称匹配,例如 `bionic` | -| `component` | 组件,可用于分组软件包,或仅为 `main` 或类似的组件。 | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.deb \ - https://gitea.example.com/api/packages/testuser/debian/pool/bionic/main/upload -``` - -如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。 -您无法向软件包中多次发布具有相同名称的文件。您必须首先删除现有的软件包版本。 - -服务器将使用以下 HTTP 状态代码进行响应。 - -| HTTP 状态码 | 意义 | -| ----------------- | ---------------------------------------- | -| `201 Created` | 软件包已发布 | -| `400 Bad Request` | 软件包名称、版本、发行版、组件或架构无效 | -| `409 Conflict` | 具有相同参数组合的软件包文件已经存在 | - -## 删除软件包 - -要删除 Debian 软件包,请执行 HTTP `DELETE` 操作。如果没有文件留下,这将同时删除软件包版本。 - -``` -DELETE https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/{package_name}/{package_version}/{architecture} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | -| `distribution` | 软件包发行版 | -| `component` | 软件包组件 | -| `architecture` | 软件包架构 | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/debian/pools/bionic/main/test-package/1.0.0/amd64 -``` - -服务器将使用以下 HTTP 状态代码进行响应。 - -| HTTP 状态码 | 含义 | -| ---------------- | ------------------ | -| `204 No Content` | 成功 | -| `404 Not Found` | 找不到软件包或文件 | - -## 安装软件包 - -要从 Debian 注册表安装软件包,请执行以下命令: - -```shell -# use latest version -apt install {package_name} -# use specific version -apt install {package_name}={package_version} -``` diff --git a/docs/content/usage/packages/generic.en-us.md b/docs/content/usage/packages/generic.en-us.md deleted file mode 100644 index 04be6e3597..0000000000 --- a/docs/content/usage/packages/generic.en-us.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Generic Package Registry" -slug: "generic" -sidebar_position: 40 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Generic" - sidebar_position: 40 - identifier: "generic" ---- - -# Generic Package Registry - -Publish generic files, like release binaries or other output, for your user or organization. - -## Authenticate to the package registry - -To authenticate to the Package Registry, you need to provide [custom HTTP headers or use HTTP Basic authentication](development/api-usage.md#authentication). - -## Publish a package - -To publish a generic package perform a HTTP PUT operation with the package content in the request body. -You cannot publish a file with the same name twice to a package. You must delete the existing package version first. - -``` -PUT https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{file_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. It can contain only lowercase letters (`a-z`), uppercase letter (`A-Z`), numbers (`0-9`), dots (`.`), hyphens (`-`), pluses (`+`), or underscores (`_`). | -| `package_version` | The package version, a non-empty string without trailing or leading whitespaces. | -| `file_name` | The filename. It can contain only lowercase letters (`a-z`), uppercase letter (`A-Z`), numbers (`0-9`), dots (`.`), hyphens (`-`), pluses (`+`), or underscores (`_`). | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.bin \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package name and/or version and/or file name are invalid. | -| `409 Conflict` | A file with the same name exist already in the package. | - -## Download a package - -To download a generic package perform a HTTP GET operation. - -``` -GET https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{file_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `file_name` | The filename. | - -The file content is served in the response body. The response content type is `application/octet-stream`. - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_token_or_password \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `200 OK` | Success | -| `404 Not Found` | The package or file was not found. | - -## Delete a package - -To delete a generic package perform a HTTP DELETE operation. This will delete all files of this version. - -``` -DELETE https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0 -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `204 No Content` | Success | -| `404 Not Found` | The package was not found. | - -## Delete a package file - -To delete a file of a generic package perform a HTTP DELETE operation. This will delete the package version too if there is no file left. - -``` -DELETE https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{filename} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `filename` | The filename. | - -Example request using HTTP Basic authentication: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `204 No Content` | Success | -| `404 Not Found` | The package or file was not found. | diff --git a/docs/content/usage/packages/generic.zh-cn.md b/docs/content/usage/packages/generic.zh-cn.md deleted file mode 100644 index f20f7ac418..0000000000 --- a/docs/content/usage/packages/generic.zh-cn.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "通用软件包注册表" -slug: "generic" -sidebar_position: 40 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "通用" - sidebar_position: 40 - identifier: "generic" ---- - -# 通用软件包注册表 - -发布通用文件,如发布二进制文件或其他输出,供您的用户或组织使用。 - -## 身份验证软件包注册表 - -要身份验证软件包注册表,您需要提供[自定义 HTTP 头或使用 HTTP 基本身份验证](development/api-usage.md#通过-api-认证)。 - -## 发布软件包 - -要发布通用软件包,请执行 HTTP `PUT` 操作,并将软件包内容放入请求主体中。 -您无法向软件包中多次发布具有相同名称的文件。您必须首先删除现有的软件包版本。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{file_name} -``` - -| 参数 | 描述 | -| ----------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `owner` | 软件包的所有者。 | -| `package_name` | 软件包名称。它只能包含小写字母 (`a-z`)、大写字母 (`A-Z`)、数字 (`0-9`)、点号 (`.`)、连字符 (`-`)、加号 (`+`) 或下划线 (`_`) | -| `package_version` | 软件包版本,一个非空字符串,不包含前导或尾随空格 | -| `file_name` | 文件名。它只能包含小写字母 (`a-z`)、大写字母 (`A-Z`)、数字 (`0-9`)、点号 (`.`)、连字符 (`-`)、加号 (`+`) 或下划线 (`_`) | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.bin \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。 - -服务器将使用以下 HTTP 状态代码进行响应。 - -| HTTP 状态码 | 意义 | -| ----------------- | ---------------------------------- | -| `201 Created` | 软件包已发布 | -| `400 Bad Request` | 软件包名称和/或版本和/或文件名无效 | -| `409 Conflict` | 具有相同名称的文件已存在于软件包中 | - -## 下载软件包 - -要下载通用软件包,请执行 HTTP `GET` 操作。 - -``` -GET https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{file_name} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | -| `file_name` | 文件名 | - -文件内容将在响应主体中返回。响应的内容类型为 `application/octet-stream`。 - -服务器将使用以下 HTTP 状态代码进行响应。 - -```shell -curl --user your_username:your_token_or_password \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -服务器会以以下 HTTP 状态码进行响应: - -| HTTP 状态码 | 含义 | -| --------------- | -------------------- | -| `200 OK` | 成功 | -| `404 Not Found` | 找不到软件包或者文件 | - -## 删除软件包 - -要删除通用软件包,请执行 HTTP DELETE 操作。这将同时删除该版本的所有文件。 - -``` -DELETE https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | - -服务器将使用以下 HTTP 状态代码进行响应。 - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0 -``` - -The server responds with the following HTTP Status codes. - -| HTTP 状态码 | 意义 | -| ---------------- | ------------ | -| `204 No Content` | 成功 | -| `404 Not Found` | 找不到软件包 | - -## 删除软件包文件 - -要删除通用软件包的文件,请执行 HTTP `DELETE` 操作。如果没有文件留下,这将同时删除软件包版本。 - -``` -DELETE https://gitea.example.com/api/packages/{owner}/generic/{package_name}/{package_version}/{filename} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | -| `filename` | 文件名 | - -使用 HTTP 基本身份验证的示例请求: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin -``` - -服务器将使用以下 HTTP 状态代码进行响应: - -| HTTP 状态码 | 含义 | -| ---------------- | ------------------ | -| `204 No Content` | 成功 | -| `404 Not Found` | 找不到软件包或文件 | diff --git a/docs/content/usage/packages/go.en-us.md b/docs/content/usage/packages/go.en-us.md deleted file mode 100644 index ed3c1a87e9..0000000000 --- a/docs/content/usage/packages/go.en-us.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -date: "2023-05-10T00:00:00+00:00" -title: "Go Package Registry" -slug: "go" -sidebar_position: 45 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Go" - sidebar_position: 45 - identifier: "go" ---- - -# Go Package Registry - -Publish Go packages for your user or organization. - -## Publish a package - -To publish a Go package perform a HTTP `PUT` operation with the package content in the request body. -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. -The package must follow the [documented structure](https://go.dev/ref/mod#zip-files). - -``` -PUT https://gitea.example.com/api/packages/{owner}/go/upload -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | - -To authenticate to the package registry, you need to provide [custom HTTP headers or use HTTP Basic authentication](development/api-usage.md#authentication): - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.zip \ - https://gitea.example.com/api/packages/testuser/go/upload -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package with the same name exist already. | - -## Install a package - -To install a Go package instruct Go to use the package registry as proxy: - -```shell -# use latest version -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name} -# or -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@latest -# use specific version -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@{package_version} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version. | - -If the owner of the packages is private you need to [provide credentials](https://go.dev/ref/mod#private-module-proxy-auth). - -More information about the `GOPROXY` environment variable and how to protect against data leaks can be found in [the documentation](https://go.dev/ref/mod#private-modules). diff --git a/docs/content/usage/packages/go.zh-cn.md b/docs/content/usage/packages/go.zh-cn.md deleted file mode 100644 index ddc7b837b0..0000000000 --- a/docs/content/usage/packages/go.zh-cn.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -date: "2023-05-10T00:00:00+00:00" -title: "Go 软件包注册表" -slug: "go" -sidebar_position: 45 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Go" - sidebar_position: 45 - identifier: "go" ---- - -# Go 软件包注册表 - -为您的用户或组织发布 Go 软件包。 - -## 发布软件包 - -要发布 Go 软件包,请执行 HTTP `PUT` 操作,并将软件包内容放入请求主体中。 -如果已经存在相同名称和版本的软件包,您无法发布软件包。您必须首先删除现有的软件包。 -该软件包必须遵循[文档中的结构](https://go.dev/ref/mod#zip-files)。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/go/upload -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -要身份验证到软件包注册表,您需要提供[自定义 HTTP 头或使用 HTTP 基本身份验证](development/api-usage.md#通过-api-认证): - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.zip \ - https://gitea.example.com/api/packages/testuser/go/upload -``` - -如果您使用的是 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码进行身份验证。 - -服务器将使用以下 HTTP 状态代码进行响应。 - -| HTTP 状态码 | 含义 | -| ----------------- | -------------------------- | -| `201 Created` | 软件包已发布 | -| `400 Bad Request` | 软件包无效 | -| `409 Conflict` | 具有相同名称的软件包已存在 | - -## 安装软件包 - -要安装Go软件包,请指示Go使用软件包注册表作为代理: - -```shell -# 使用最新版本 -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name} -# 或者 -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@latest -# 使用特定版本 -GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@{package_version} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | - -如果软件包的所有者是私有的,则需要[提供凭据](https://go.dev/ref/mod#private-module-proxy-auth)。 - -有关 `GOPROXY` 环境变量的更多信息以及如何防止数据泄漏的信息,请[参阅文档](https://go.dev/ref/mod#private-modules)。 diff --git a/docs/content/usage/packages/helm.en-us.md b/docs/content/usage/packages/helm.en-us.md deleted file mode 100644 index a9fe6be89d..0000000000 --- a/docs/content/usage/packages/helm.en-us.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -date: "2022-04-14T00:00:00+00:00" -title: "Helm Chart Registry" -slug: "helm" -sidebar_position: 50 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Helm" - sidebar_position: 50 - identifier: "helm" ---- - -# Helm Chart Registry - -Publish [Helm](https://helm.sh/) charts for your user or organization. - -## Requirements - -To work with the Helm Chart registry use a simple HTTP client like `curl` or the [`helm cm-push`](https://github.com/chartmuseum/helm-push/) plugin. - -## Publish a package - -Publish a package by running the following command: - -```shell -curl --user {username}:{password} -X POST --upload-file ./{chart_file}.tgz https://gitea.example.com/api/packages/{owner}/helm/api/charts -``` - -or with the `helm cm-push` plugin: - -```shell -helm repo add --username {username} --password {password} {repo} https://gitea.example.com/api/packages/{owner}/helm -helm cm-push ./{chart_file}.tgz {repo} -``` - -| Parameter | Description | -| ------------ | ----------- | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | -| `repo` | The name for the repository. | -| `chart_file` | The Helm Chart archive. | -| `owner` | The owner of the package. | - -## Install a package - -To install a Helm char from the registry, execute the following command: - -```shell -helm repo add --username {username} --password {password} {repo} https://gitea.example.com/api/packages/{owner}/helm -helm repo update -helm install {name} {repo}/{chart} -``` - -| Parameter | Description | -| ---------- | ----------- | -| `username` | Your Gitea username. | -| `password` | Your Gitea password or a personal access token. | -| `repo` | The name for the repository. | -| `owner` | The owner of the package. | -| `name` | The local name. | -| `chart` | The name Helm Chart. | diff --git a/docs/content/usage/packages/helm.zh-cn.md b/docs/content/usage/packages/helm.zh-cn.md deleted file mode 100644 index ea9105e63d..0000000000 --- a/docs/content/usage/packages/helm.zh-cn.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -date: "2022-04-14T00:00:00+00:00" -title: "Helm Chart 注册表" -slug: "helm" -sidebar_position: 50 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Helm" - sidebar_position: 50 - identifier: "helm" ---- - -# Helm Chart 注册表 - -为您的用户或组织发布 [Helm](https://helm.sh/) charts。 - -## 要求 - -要使用 Helm Chart 注册表,可以使用诸如 `curl` 或 [`helm cm-push`](https://github.com/chartmuseum/helm-push/) 插件之类的简单HTTP客户端。 - -## 发布软件包 - -通过运行以下命令来发布软件包: - -```shell -curl --user {username}:{password} -X POST --upload-file ./{chart_file}.tgz https://gitea.example.com/api/packages/{owner}/helm/api/charts -``` - -或者使用 `helm cm-push` 插件: - -```shell -helm repo add --username {username} --password {password} {repo} https://gitea.example.com/api/packages/{owner}/helm -helm cm-push ./{chart_file}.tgz {repo} -``` - -| 参数 | 描述 | -| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `username` | 您的Gitea用户名 | -| `password` | 您的Gitea密码。如果您使用的是2FA或OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码进行身份验证。 | -| `repo` | 仓库名称 | -| `chart_file` | Helm Chart 归档文件 | -| `owner` | 软件包的所有者 | - -## 安装软件包 - -要从注册表中安装Helm Chart,请执行以下命令: - -```shell -helm repo add --username {username} --password {password} {repo} https://gitea.example.com/api/packages/{owner}/helm -helm repo update -helm install {name} {repo}/{chart} -``` - -| 参数 | 描述 | -| ---------- | --------------------------- | -| `username` | 您的Gitea用户名 | -| `password` | 您的Gitea密码或个人访问令牌 | -| `repo` | 存储库的名称 | -| `owner` | 软件包的所有者 | -| `name` | 本地名称 | -| `chart` | Helm Chart的名称 | diff --git a/docs/content/usage/packages/maven.en-us.md b/docs/content/usage/packages/maven.en-us.md deleted file mode 100644 index 59e71c87cc..0000000000 --- a/docs/content/usage/packages/maven.en-us.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Maven Package Registry" -slug: "maven" -sidebar_position: 60 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Maven" - sidebar_position: 60 - identifier: "maven" ---- - -# Maven Package Registry - -Publish [Maven](https://maven.apache.org) packages for your user or organization. - -## Requirements - -To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/). -The following examples use `Maven` and `Gradle Groovy`. - -## Configuring the package registry - -To register the package registry you first need to add your access token to the [`settings.xml`](https://maven.apache.org/settings.html) file: - -```xml -<settings> - <servers> - <server> - <id>gitea</id> - <configuration> - <httpHeaders> - <property> - <name>Authorization</name> - <value>token {access_token}</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> -</settings> -``` - -Afterwards add the following sections to your project `pom.xml` file: - -```xml -<repositories> - <repository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </repository> -</repositories> -<distributionManagement> - <repository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </repository> - <snapshotRepository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </snapshotRepository> -</distributionManagement> -``` - -| Parameter | Description | -| -------------- | ----------- | -| `access_token` | Your [personal access token](development/api-usage.md#authentication). | -| `owner` | The owner of the package. | - -### Gradle variant - -When you plan to add some packages from Gitea instance in your project, you should add it in repositories section: - -```groovy -repositories { - // other repositories - maven { url "https://gitea.example.com/api/packages/{owner}/maven" } -} -``` - -In Groovy gradle you may include next script in your publishing part: - -```groovy -publishing { - // other settings of publication - repositories { - maven { - name = "Gitea" - url = uri("https://gitea.example.com/api/packages/{owner}/maven") - - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "token {access_token}" - } - - authentication { - header(HttpHeaderAuthentication) - } - } - } -} -``` - -## Publish a package - -To publish a package simply run: - -```shell -mvn deploy -``` - -Or call `gradle` with task `publishAllPublicationsToGiteaRepository` in case you are using gradle: - -```groovy -./gradlew publishAllPublicationsToGiteaRepository -``` - -If you want to publish a prebuild package to the registry, you can use [`mvn deploy:deploy-file`](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html): - -```shell -mvn deploy:deploy-file -Durl=https://gitea.example.com/api/packages/{owner}/maven -DrepositoryId=gitea -Dfile=/path/to/package.jar -``` - -| Parameter | Description | -| -------------- | ----------- | -| `owner` | The owner of the package. | - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a Maven package from the package registry, add a new dependency to your project `pom.xml` file: - -```xml -<dependency> - <groupId>com.test.package</groupId> - <artifactId>test_project</artifactId> - <version>1.0.0</version> -</dependency> -``` - -And analog in gradle groovy: - -```groovy -implementation "com.test.package:test_project:1.0.0" -``` - -Afterwards run: - -```shell -mvn install -``` - -## Supported commands - -``` -mvn install -mvn deploy -mvn dependency:get: -``` diff --git a/docs/content/usage/packages/maven.zh-cn.md b/docs/content/usage/packages/maven.zh-cn.md deleted file mode 100644 index 6b873c7959..0000000000 --- a/docs/content/usage/packages/maven.zh-cn.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Maven 软件包注册表" -slug: "maven" -sidebar_position: 60 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Maven" - sidebar_position: 60 - identifier: "maven" ---- - -# Maven 软件包注册表 - -为您的用户或组织发布 [Maven](https://maven.apache.org) 软件包。 - -## 要求 - -要使用 Maven 软件包注册表,您可以使用 [Maven](https://maven.apache.org/install.html) 或 [Gradle](https://gradle.org/install/)。 -以下示例使用 `Maven` 和 `Gradle Groovy`。 - -## 配置软件包注册表 - -要注册软件包注册表,首先需要将访问令牌添加到 [`settings.xml`](https://maven.apache.org/settings.html) 文件中: - -```xml -<settings> - <servers> - <server> - <id>gitea</id> - <configuration> - <httpHeaders> - <property> - <name>Authorization</name> - <value>token {access_token}</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> -</settings> -``` - -然后在项目的 `pom.xml` 文件中添加以下部分: - -```xml -<repositories> - <repository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </repository> -</repositories> -<distributionManagement> - <repository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </repository> - <snapshotRepository> - <id>gitea</id> - <url>https://gitea.example.com/api/packages/{owner}/maven</url> - </snapshotRepository> -</distributionManagement> -``` - -| 参数 | 描述 | -| -------------- | ------------------------------------------------------------------------------------- | -| `access_token` | 您的[个人访问令牌](development/api-usage.md#通过-api-认证) | -| `owner` | 软件包的所有者 | - -### Gradle variant - -如果您计划在项目中添加来自 Gitea 实例的一些软件包,请将其添加到 repositories 部分中: - -```groovy -repositories { - // other repositories - maven { url "https://gitea.example.com/api/packages/{owner}/maven" } -} -``` - -在 Groovy gradle 中,您可以在发布部分中包含以下脚本: - -```groovy -publishing { - // 其他发布设置 - repositories { - maven { - name = "Gitea" - url = uri("https://gitea.example.com/api/packages/{owner}/maven") - - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "token {access_token}" - } - - authentication { - header(HttpHeaderAuthentication) - } - } - } -} -``` - -## 发布软件包 - -要发布软件包,只需运行以下命令: - -```shell -mvn deploy -``` - -或者,如果您使用的是 Gradle,请使用 `gradle` 命令和 `publishAllPublicationsToGiteaRepository` 任务: - -```groovy -./gradlew publishAllPublicationsToGiteaRepository -``` - -如果您想要将预构建的软件包发布到注册表中,可以使用 [`mvn deploy:deploy-file`](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html) 命令: - -```shell -mvn deploy:deploy-file -Durl=https://gitea.example.com/api/packages/{owner}/maven -DrepositoryId=gitea -Dfile=/path/to/package.jar -``` - -| 参数 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -如果存在相同名称和版本的软件包,您无法发布该软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表中安装 Maven 软件包,请在项目的 `pom.xml` 文件中添加新的依赖项: - -```xml -<dependency> - <groupId>com.test.package</groupId> - <artifactId>test_project</artifactId> - <version>1.0.0</version> -</dependency> -``` - -在 `Gradle Groovy` 中类似的操作如下: - -```groovy -implementation "com.test.package:test_project:1.0.0" -``` - -然后运行: - -```shell -mvn install -``` - -## 支持的命令 - -``` -mvn install -mvn deploy -mvn dependency:get: -``` diff --git a/docs/content/usage/packages/npm.en-us.md b/docs/content/usage/packages/npm.en-us.md deleted file mode 100644 index ccc075b140..0000000000 --- a/docs/content/usage/packages/npm.en-us.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "npm Package Registry" -slug: "npm" -sidebar_position: 70 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "npm" - sidebar_position: 70 - identifier: "npm" ---- - -# npm Package Registry - -Publish [npm](https://www.npmjs.com/) packages for your user or organization. - -## Requirements - -To work with the npm package registry, you need [Node.js](https://nodejs.org/en/download/) coupled with a package manager such as [Yarn](https://classic.yarnpkg.com/en/docs/install) or [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/) itself. - -The registry supports [scoped](https://docs.npmjs.com/misc/scope/) and unscoped packages. - -The following examples use the `npm` tool with the scope `@test`. - -## Configuring the package registry - -To register the package registry you need to configure a new package source. - -```shell -npm config set {scope}:registry=https://gitea.example.com/api/packages/{owner}/npm/ -npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{token}" -``` - -| Parameter | Description | -| ------------ | ----------- | -| `scope` | The scope of the packages. | -| `owner` | The owner of the package. | -| `token` | Your [personal access token](development/api-usage.md#authentication). | - -For example: - -```shell -npm config set @test:registry=https://gitea.example.com/api/packages/testuser/npm/ -npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token" -``` - -or without scope: - -```shell -npm config set registry https://gitea.example.com/api/packages/testuser/npm/ -npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token" -``` - -## Publish a package - -Publish a package by running the following command in your project: - -```shell -npm publish -``` - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Unpublish a package - -Delete a package by running the following command: - -```shell -npm unpublish {package_name}[@{package_version}] -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `package_name` | The package name. | -| `package_version` | The package version. | - -For example: - -```shell -npm unpublish @test/test_package -npm unpublish @test/test_package@1.0.0 -``` - -## Install a package - -To install a package from the package registry, execute the following command: - -```shell -npm install {package_name} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `package_name` | The package name. | - -For example: - -```shell -npm install @test/test_package -``` - -## Tag a package - -The registry supports [version tags](https://docs.npmjs.com/adding-dist-tags-to-packages/) which can be managed by `npm dist-tag`: - -```shell -npm dist-tag add {package_name}@{version} {tag} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `package_name` | The package name. | -| `version` | The version of the package. | -| `tag` | The tag name. | - -For example: - -```shell -npm dist-tag add test_package@1.0.2 release -``` - -The tag name must not be a valid version. All tag names which are parsable as a version are rejected. - -## Search packages - -The registry supports [searching](https://docs.npmjs.com/cli/v7/commands/npm-search/) but does not support special search qualifiers like `author:gitea`. - -## Supported commands - -``` -npm install -npm ci -npm publish -npm unpublish -npm dist-tag -npm view -npm search -``` diff --git a/docs/content/usage/packages/npm.zh-cn.md b/docs/content/usage/packages/npm.zh-cn.md deleted file mode 100644 index 772cdc08b2..0000000000 --- a/docs/content/usage/packages/npm.zh-cn.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "npm 软件包注册表" -slug: "npm" -sidebar_position: 70 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "npm" - sidebar_position: 70 - identifier: "npm" ---- - -# npm Package Registry - -为您的用户或组织发布 [npm](https://www.npmjs.com/) 包。 - -## 要求 - -要使用 npm 包注册表,您需要安装 [Node.js](https://nodejs.org/en/download/) 以及与之配套的软件包管理器,例如 [Yarn](https://classic.yarnpkg.com/en/docs/install) 或 [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/) 本身。 - -该注册表支持[作用域](https://docs.npmjs.com/misc/scope/)和非作用域软件包。 - -以下示例使用具有作用域 `@test` 的 `npm` 工具。 - -## 配置软件包注册表 - -要注册软件包注册表,您需要配置一个新的软件包源。 - -```shell -npm config set {scope}:registry=https://gitea.example.com/api/packages/{owner}/npm/ -npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{token}" -``` - -| 参数 | 描述 | -| ------- | --------------------------------------------------------------------------------------- | -| `scope` | 软件包的作用域 | -| `owner` | 软件包的所有者 | -| `token` | 您的[个人访问令牌](development/api-usage.md#通过-api-认证)。 | - -例如: - -```shell -npm config set @test:registry=https://gitea.example.com/api/packages/testuser/npm/ -npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token" -``` - -或者,不使用作用域: - -```shell -npm config set registry https://gitea.example.com/api/packages/testuser/npm/ -npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token" -``` - -## 发布软件包 - -在项目中运行以下命令发布软件包: - -```shell -npm publish -``` - -如果已经存在相同名称和版本的软件包,您无法发布该软件包。您必须先删除现有的软件包。 - -## 删除软件包 - -通过运行以下命令删除软件包: - -```shell -npm unpublish {package_name}[@{package_version}] -``` - -| 参数 | 描述 | -| ----------------- | ---------- | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | - -例如 - -```shell -npm unpublish @test/test_package -npm unpublish @test/test_package@1.0.0 -``` - -## 安装软件包 - -要从软件包注册表中安装软件包,请执行以下命令: - -```shell -npm install {package_name} -``` - -| 参数 | 描述 | -| -------------- | ---------- | -| `package_name` | 软件包名称 | - -例如: - -```shell -npm install @test/test_package -``` - -## 给软件包打标签 - -该注册表支持[版本标签](https://docs.npmjs.com/adding-dist-tags-to-packages/),可以通过 `npm dist-tag` 管理: - -```shell -npm dist-tag add {package_name}@{version} {tag} -``` - -| 参数 | 描述 | -| -------------- | ---------- | -| `package_name` | 软件包名称 | -| `version` | 软件包版本 | -| `tag` | 软件包标签 | - -例如: - -```shell -npm dist-tag add test_package@1.0.2 release -``` - -标签名称不能是有效的版本。所有可解析为版本的标签名称都将被拒绝。 - -## 搜索软件包 - -该注册表支持[搜索](https://docs.npmjs.com/cli/v7/commands/npm-search/),但不支持像 `author:gitea` 这样的特殊搜索限定符。 - -## 支持的命令 - -``` -npm install -npm ci -npm publish -npm unpublish -npm dist-tag -npm view -npm search -``` diff --git a/docs/content/usage/packages/nuget.en-us.md b/docs/content/usage/packages/nuget.en-us.md deleted file mode 100644 index 8cd88e0637..0000000000 --- a/docs/content/usage/packages/nuget.en-us.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "NuGet Package Registry" -slug: "nuget" -sidebar_position: 80 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "NuGet" - sidebar_position: 80 - identifier: "nuget" ---- - -# NuGet Package Registry - -Publish [NuGet](https://www.nuget.org/) packages for your user or organization. The package registry supports the V2 and V3 API protocol and you can work with [NuGet Symbol Packages](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg) too. - -## Requirements - -To work with the NuGet package registry, you can use command-line interface tools as well as NuGet features in various IDEs like Visual Studio. -More information about NuGet clients can be found in [the official documentation](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools). -The following examples use the `dotnet nuget` tool. - -## Configuring the package registry - -To register the package registry you need to configure a new NuGet feed source: - -```shell -dotnet nuget add source --name {source_name} --username {username} --password {password} https://gitea.example.com/api/packages/{owner}/nuget/index.json -``` - -| Parameter | Description | -| ------------- | ----------- | -| `source_name` | The desired source name. | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | -| `owner` | The owner of the package. | - -For example: - -```shell -dotnet nuget add source --name gitea --username testuser --password password123 https://gitea.example.com/api/packages/testuser/nuget/index.json -``` - -You can add the source without credentials and use the [`--api-key`](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push) parameter when publishing packages. In this case you need to provide a [personal access token](development/api-usage.md#authentication). - -## Publish a package - -Publish a package by running the following command: - -```shell -dotnet nuget push --source {source_name} {package_file} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `source_name` | The desired source name. | -| `package_file` | Path to the package `.nupkg` file. | - -For example: - -```shell -dotnet nuget push --source gitea test_package.1.0.0.nupkg -``` - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -### Symbol Packages - -The NuGet package registry has build support for a symbol server. The PDB files embedded in a symbol package (`.snupkg`) can get requested by clients. -To do so, register the NuGet package registry as symbol source: - -``` -https://gitea.example.com/api/packages/{owner}/nuget/symbols -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package registry. | - -For example: - -``` -https://gitea.example.com/api/packages/testuser/nuget/symbols -``` - -## Install a package - -To install a NuGet package from the package registry, execute the following command: - -```shell -dotnet add package --source {source_name} --version {package_version} {package_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `source_name` | The desired source name. | -| `package_name` | The package name. | -| `package_version` | The package version. | - -For example: - -```shell -dotnet add package --source gitea --version 1.0.0 test_package -``` - -## Supported commands - -``` -dotnet add -dotnet nuget push -dotnet nuget delete -``` diff --git a/docs/content/usage/packages/nuget.zh-cn.md b/docs/content/usage/packages/nuget.zh-cn.md deleted file mode 100644 index 692d5f928f..0000000000 --- a/docs/content/usage/packages/nuget.zh-cn.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "NuGet 软件包注册表" -slug: "nuget" -sidebar_position: 80 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "NuGet" - sidebar_position: 80 - identifier: "nuget" ---- - -# NuGet 软件包注册表 - -发布适用于您的用户或组织的 [NuGet](https://www.nuget.org/) 软件包。软件包注册表支持 V2 和 V3 API 协议,并且您还可以使用 [NuGet 符号软件包](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg)。 - -## 要求 - -要使用 NuGet 软件包注册表,您可以使用命令行界面工具,以及各种集成开发环境(IDE)中的 NuGet 功能,如 Visual Studio。有关 NuGet 客户端的更多信息,请参[阅官方文档](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools)。 -以下示例使用 `dotnet nuget` 工具。 - -## 配置软件包注册表 - -要注册软件包注册表,您需要配置一个新的NuGet源: - -```shell -dotnet nuget add source --name {source_name} --username {username} --password {password} https://gitea.example.com/api/packages/{owner}/nuget/index.json -``` - -| 参数 | 描述 | -| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| `source_name` | 所需源名称 | -| `username` | 您的Gitea用户名 | -| `password` | 您的Gitea密码。如果您使用2FA或OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)代替密码。 | -| `owner` | 软件包的所有者 | - -例如: - -```shell -dotnet nuget add source --name gitea --username testuser --password password123 https://gitea.example.com/api/packages/testuser/nuget/index.json -``` - -您可以在不提供凭据的情况下添加源,并在发布软件包时使用--api-key参数。在这种情况下,您需要提供[个人访问令牌](development/api-usage.md#通过-api-认证)。 - -## 发布软件包 - -通过运行以下命令发布软件包: - -```shell -dotnet nuget push --source {source_name} {package_file} -``` - -| 参数 | 描述 | -| -------------- | ---------------------------- | -| `source_name` | 所需源名称 | -| `package_file` | 软件包 `.nupkg` 文件的路径。 | - -例如: - -```shell -dotnet nuget push --source gitea test_package.1.0.0.nupkg -``` - -如果已经存在相同名称和版本的软件包,您无法发布该软件包。您必须先删除现有的软件包。 - -### 符号软件包 - -NuGet 软件包注册表支持构建用于符号服务器的符号软件包。客户端可以请求嵌入在符号软件包(`.snupkg`)中的 PDB 文件。 -为此,请将 NuGet 软件包注册表注册为符号源: - -``` -https://gitea.example.com/api/packages/{owner}/nuget/symbols -``` - -| 参数 | 描述 | -| ------- | -------------------- | -| `owner` | 软件包注册表的所有者 | - -例如: - -``` -https://gitea.example.com/api/packages/testuser/nuget/symbols -``` - -## 安装软件包 - -要从软件包注册表安装 NuGet 软件包,请执行以下命令: - -```shell -dotnet add package --source {source_name} --version {package_version} {package_name} -``` - -| 参数 | 描述 | -| ----------------- | ------------ | -| `source_name` | 所需源名称 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本。 | - -例如: - -```shell -dotnet add package --source gitea --version 1.0.0 test_package -``` - -## 支持的命令 - -``` -dotnet add -dotnet nuget push -dotnet nuget delete -``` diff --git a/docs/content/usage/packages/overview.en-us.md b/docs/content/usage/packages/overview.en-us.md deleted file mode 100644 index 89fc6f286e..0000000000 --- a/docs/content/usage/packages/overview.en-us.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "Package Registry" -slug: "overview" -sidebar_position: 1 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Overview" - sidebar_position: 1 - identifier: "packages-overview" ---- - -# Package Registry - -Starting with Gitea **1.17**, the Package Registry can be used as a public or private registry for common package managers. - -## Supported package managers - -The following package managers are currently supported: - -| Name | Language | Package client | -| ---- | -------- | -------------- | -| [Alpine](usage/packages/alpine.md) | - | `apk` | -| [Cargo](usage/packages/cargo.md) | Rust | `cargo` | -| [Chef](usage/packages/chef.md) | - | `knife` | -| [Composer](usage/packages/composer.md) | PHP | `composer` | -| [Conan](usage/packages/conan.md) | C++ | `conan` | -| [Conda](usage/packages/conda.md) | - | `conda` | -| [Container](usage/packages/container.md) | - | any OCI compliant client | -| [CRAN](usage/packages/cran.md) | R | - | -| [Debian](usage/packages/debian.md) | - | `apt` | -| [Generic](usage/packages/generic.md) | - | any HTTP client | -| [Go](usage/packages/go.md) | Go | `go` | -| [Helm](usage/packages/helm.md) | - | any HTTP client, `cm-push` | -| [Maven](usage/packages/maven.md) | Java | `mvn`, `gradle` | -| [npm](usage/packages/npm.md) | JavaScript | `npm`, `yarn`, `pnpm` | -| [NuGet](usage/packages/nuget.md) | .NET | `nuget` | -| [Pub](usage/packages/pub.md) | Dart | `dart`, `flutter` | -| [PyPI](usage/packages/pypi.md) | Python | `pip`, `twine` | -| [RPM](usage/packages/rpm.md) | - | `yum`, `dnf`, `zypper` | -| [RubyGems](usage/packages/rubygems.md) | Ruby | `gem`, `Bundler` | -| [Swift](usage/packages/swift.md) | Swift | `swift` | -| [Vagrant](usage/packages/vagrant.md) | - | `vagrant` | - -**The following paragraphs only apply if Packages are not globally disabled!** - -## Repository-Packages - -A package always belongs to an owner (a user or organisation), not a repository. -To link an (already uploaded) package to a repository, open the settings page -on that package and choose a repository to link this package to. -The entire package will be linked, not just a single version. - -Linking a package results in showing that package in the repository's package list, -and shows a link to the repository on the package site (as well as a link to the repository issues). - -## Access Restrictions - -| Package owner type | User | Organization | -|--------------------|------|--------------| -| **read** access | public, if user is public too; otherwise for this user only | public, if org is public, otherwise for org members only | -| **write** access | owner only | org members with admin or write access to the org | - -N.B.: These access restrictions are [subject to change](https://github.com/go-gitea/gitea/issues/19270), where more finegrained control will be added via a dedicated organization team permission. - -## Create or upload a package - -Depending on the type of package, use the respective package-manager for that. Check out the sub-page of a specific package manager for instructions. - -## View packages - -You can view the packages of a repository on the repository page. - -1. Go to the repository. -1. Go to **Packages** in the navigation bar. - -To view more details about a package, select the name of the package. - -## Download a package - -To download a package from your repository: - -1. Go to **Packages** in the navigation bar. -1. Select the name of the package to view the details. -1. In the **Assets** section, select the name of the package file you want to download. - -## Delete a package - -You cannot edit a package after you have published it in the Package Registry. Instead, you -must delete and recreate it. - -To delete a package from your repository: - -1. Go to **Packages** in the navigation bar. -1. Select the name of the package to view the details. -1. Click **Delete package** to permanently delete the package. - -## Disable the Package Registry - -The Package Registry is automatically enabled. To disable it for a single repository: - -1. Go to **Settings** in the navigation bar. -1. Disable **Enable Repository Packages Registry**. - -Previously published packages are not deleted by disabling the Package Registry. diff --git a/docs/content/usage/packages/overview.zh-cn.md b/docs/content/usage/packages/overview.zh-cn.md deleted file mode 100644 index daacf1dcfd..0000000000 --- a/docs/content/usage/packages/overview.zh-cn.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "软件包注册表" -slug: "overview" -sidebar_position: 1 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Overview" - sidebar_position: 1 - identifier: "packages-overview" ---- - -# 软件包注册表 - -从Gitea **1.17**版本开始,软件包注册表可以用作常见软件包管理器的公共或私有注册表。 - -## 支持的软件包管理器 - -目前支持以下软件包管理器: - -| Name | Language | Package client | -| ------------------------------------------------------------------- | ---------- | ------------------------- | -| [Alpine](usage/packages/alpine.md) | - | `apk` | -| [Cargo](usage/packages/cargo.md) | Rust | `cargo` | -| [Chef](usage/packages/chef.md) | - | `knife` | -| [Composer](usage/packages/composer.md) | PHP | `composer` | -| [Conan](usage/packages/conan.md) | C++ | `conan` | -| [Conda](usage/packages/conda.md) | - | `conda` | -| [Container](usage/packages/container.md) | - | 任何符合OCI规范的客户端 | -| [CRAN](usage/packages/cran.md) | R | - | -| [Debian](usage/packages/debian.md) | - | `apt` | -| [Generic](usage/packages/generic.md) | - | 任何HTTP客户端 | -| [Go](usage/packages/go.md) | Go | `go` | -| [Helm](usage/packages/helm.md) | - | 任何HTTP客户端, `cm-push` | -| [Maven](usage/packages/maven.md) | Java | `mvn`, `gradle` | -| [npm](usage/packages/npm.md) | JavaScript | `npm`, `yarn`, `pnpm` | -| [NuGet](usage/packages/nuget.md) | .NET | `nuget` | -| [Pub](usage/packages/pub.md) | Dart | `dart`, `flutter` | -| [PyPI](usage/packages/pypi.md) | Python | `pip`, `twine` | -| [RPM](usage/packages/rpm.md) | - | `yum`, `dnf`, `zypper` | -| [RubyGems](usage/packages/rubygems.md) | Ruby | `gem`, `Bundler` | -| [Swift](usage/packages/rubygems.md) | Swift | `swift` | -| [Vagrant](usage/packages/vagrant.md) | - | `vagrant` | - -**以下段落仅适用于未全局禁用软件包的情况!** - -## 仓库 x 软件包 - -软件包始终属于所有者(用户或组织),而不是仓库。 -要将(已上传的)软件包链接到仓库,请打开该软件包的设置页面,并选择要将此软件包链接到的仓库。 -将链接到整个软件包,而不仅是单个版本。 - -链接软件包将导致在仓库的软件包列表中显示该软件包,并在软件包页面上显示到仓库的链接(以及到仓库工单的链接)。 - -## 访问限制 - -| 软件包所有者类型 | 用户 | 组织 | -| ---------------- | ---------------------------------------- | ------------------------------------------ | -| **读取** 访问 | 公开,如果用户也是公开的;否则仅限此用户 | 公开,如果组织是公开的,否则仅限组织成员 | -| **写入** 访问 | 仅软件包所有者 | 具有组织中的管理员或写入访问权限的组织成员 | - -注意:这些访问限制可能会[变化](https://github.com/go-gitea/gitea/issues/19270),将通过专门的组织团队权限添加更细粒度的控制。 - -## 创建或上传软件包 - -根据软件包类型,使用相应的软件包管理器。请查看特定软件包管理器的子页面以获取说明。 - -## 查看软件包 - -您可以在仓库页面上查看仓库的软件包。 - -1. 转到仓库主页。 -2. 在导航栏中选择**软件包** - -要查看有关软件包的更多详细信息,请选择软件包的名称。 - -## 下载软件包 - -要从仓库下载软件包: - -1. 在导航栏中选择**软件包** -2. 选择软件包的名称以查看详细信息。 -3. 在 **Assets** 部分,选择要下载的软件包文件的名称。 - -## 删除软件包 - -在将软件包发布到软件包注册表后,您无法编辑软件包。相反,您必须删除并重新创建它。 - -要从仓库中删除软件包: - -1. 在导航栏中选择**软件包** -2. 选择软件包的名称以查看详细信息。 -3. 单击**删除软件包**以永久删除软件包。 - -## 禁用软件包注册表 - -包注册表已自动启用。要在单个存储库中禁用它: - -1. 在导航栏中选择**设置**。 -2. 禁用**启用仓库软件包注册表**. - -禁用软件包注册表不会删除先前发布的软件包。 diff --git a/docs/content/usage/packages/pub.en-us.md b/docs/content/usage/packages/pub.en-us.md deleted file mode 100644 index e5e12de344..0000000000 --- a/docs/content/usage/packages/pub.en-us.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -date: "2022-07-31T00:00:00+00:00" -title: "Pub Package Registry" -slug: "pub" -sidebar_position: 90 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Pub" - sidebar_position: 90 - identifier: "pub" ---- - -# Pub Package Registry - -Publish [Pub](https://dart.dev/guides/packages) packages for your user or organization. - -## Requirements - -To work with the Pub package registry, you need to use the tools [dart](https://dart.dev/tools/dart-tool) and/or [flutter](https://docs.flutter.dev/reference/flutter-cli). - -The following examples use dart. - -## Configuring the package registry - -To register the package registry and provide credentials, execute: - -```shell -dart pub token add https://gitea.example.com/api/packages/{owner}/pub -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | - -You need to provide your [personal access token](development/api-usage.md#authentication). - -## Publish a package - -To publish a package, edit the `pubspec.yaml` and add the following line: - -```yaml -publish_to: https://gitea.example.com/api/packages/{owner}/pub -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | - -Now you can publish the package by running the following command: - -```shell -dart pub publish -``` - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a Pub package from the package registry, execute the following command: - -```shell -dart pub add {package_name} --hosted-url=https://gitea.example.com/api/packages/{owner}/pub/ -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | - -For example: - -```shell -# use latest version -dart pub add mypackage --hosted-url=https://gitea.example.com/api/packages/testuser/pub/ -# specify version -dart pub add mypackage:1.0.8 --hosted-url=https://gitea.example.com/api/packages/testuser/pub/ -``` diff --git a/docs/content/usage/packages/pub.zh-cn.md b/docs/content/usage/packages/pub.zh-cn.md deleted file mode 100644 index 2b3c302047..0000000000 --- a/docs/content/usage/packages/pub.zh-cn.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -date: "2022-07-31T00:00:00+00:00" -title: "Pub 软件包注册表" -slug: "pub" -sidebar_position: 90 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Pub" - sidebar_position: 90 - identifier: "pub" ---- - -# Pub 软件包注册表 - -为您的用户或组织发布 [Pub](https://dart.dev/guides/packages) 软件包。 - -## 要求 - -要使用Pub软件包注册表,您需要使用 [dart](https://dart.dev/tools/dart-tool) 和/或 [flutter](https://docs.flutter.dev/reference/flutter-cli). 工具。 - -以下示例使用 `dart`。 - -## 配置软件包注册表 - -要注册软件包注册表并提供凭据,请执行以下操作: - -```shell -dart pub token add https://gitea.example.com/api/packages/{owner}/pub -``` - -| 占位符 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -您需要提供您的[个人访问令牌](development/api-usage.md#通过-api-认证)。 - -## 发布软件包 - -要发布软件包,请编辑 `pubspec.yaml` 文件,并添加以下行: - -```yaml -publish_to: https://gitea.example.com/api/packages/{owner}/pub -``` - -| 占位符 | 描述 | -| ------- | -------------- | -| `owner` | 软件包的所有者 | - -现在,您可以通过运行以下命令来发布软件包: - -```shell -dart pub publish -``` - -如果已存在具有相同名称和版本的软件包,则无法发布软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装Pub软件包,请执行以下命令: - -```shell -dart pub add {package_name} --hosted-url=https://gitea.example.com/api/packages/{owner}/pub/ -``` - -| 参数 | 描述 | -| -------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | - -例如: - -```shell -# use latest version -dart pub add mypackage --hosted-url=https://gitea.example.com/api/packages/testuser/pub/ -# specify version -dart pub add mypackage:1.0.8 --hosted-url=https://gitea.example.com/api/packages/testuser/pub/ -``` diff --git a/docs/content/usage/packages/pypi.en-us.md b/docs/content/usage/packages/pypi.en-us.md deleted file mode 100644 index be59df0762..0000000000 --- a/docs/content/usage/packages/pypi.en-us.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "PyPI Package Registry" -slug: "pypi" -sidebar_position: 100 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "PyPI" - sidebar_position: 100 - identifier: "pypi" ---- - -# PyPI Package Registry - -Publish [PyPI](https://pypi.org/) packages for your user or organization. - -## Requirements - -To work with the PyPI package registry, you need to use the tools [pip](https://pypi.org/project/pip/) to consume and [twine](https://pypi.org/project/twine/) to publish packages. - -## Configuring the package registry - -To register the package registry you need to edit your local `~/.pypirc` file. Add - -```ini -[distutils] -index-servers = gitea - -[gitea] -repository = https://gitea.example.com/api/packages/{owner}/pypi -username = {username} -password = {password} -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | - -## Publish a package - -Publish a package by running the following command: - -```shell -python3 -m twine upload --repository gitea /path/to/files/* -``` - -The package files have the extensions `.tar.gz` and `.whl`. - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a PyPI package from the package registry, execute the following command: - -```shell -pip install --index-url https://{username}:{password}@gitea.example.com/api/packages/{owner}/pypi/simple --no-deps {package_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `username` | Your Gitea username. | -| `password` | Your Gitea password or a personal access token. | -| `owner` | The owner of the package. | -| `package_name` | The package name. | - -For example: - -```shell -pip install --index-url https://testuser:password123@gitea.example.com/api/packages/testuser/pypi/simple --no-deps test_package -``` - -You can use `--extra-index-url` instead of `--index-url` but that makes you vulnerable to dependency confusion attacks because `pip` checks the official PyPi repository for the package before it checks the specified custom repository. Read the `pip` docs for more information. - -## Supported commands - -``` -pip install -twine upload -``` diff --git a/docs/content/usage/packages/pypi.zh-cn.md b/docs/content/usage/packages/pypi.zh-cn.md deleted file mode 100644 index 80f95141b7..0000000000 --- a/docs/content/usage/packages/pypi.zh-cn.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "PyPI 软件包注册表" -slug: "pypi" -sidebar_position: 100 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "PyPI" - sidebar_position: 100 - identifier: "pypi" ---- - -# PyPI 软件包注册表 - -为您的用户或组织发布 [PyPI](https://pypi.org/) 软件包。 - -## 要求 - -要使用 PyPI 软件包注册表,您需要使用 [pip](https://pypi.org/project/pip/) 工具来消费和使用 [twine](https://pypi.org/project/twine/) 工具来发布软件包。 - -## 配置软件包注册表 - -要注册软件包注册表,您需要编辑本地的 `~/.pypirc` 文件。添加以下内容: - -```ini -[distutils] -index-servers = gitea - -[gitea] -repository = https://gitea.example.com/api/packages/{owner}/pypi -username = {username} -password = {password} -``` - -| 占位符 | 描述 | -| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `owner` | 软件包的所有者 | -| `username` | 您的 Gitea 用户名 | -| `password` | 您的 Gitea 密码。如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码 | - -## 发布软件包 - -通过运行以下命令来发布软件包: - -```shell -python3 -m twine upload --repository gitea /path/to/files/* -``` - -软件包文件的扩展名为 `.tar.gz` 和 `.whl`。 - -如果已存在具有相同名称和版本的软件包,则无法发布软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装 PyPI 软件包,请执行以下命令: - -```shell -pip install --index-url https://{username}:{password}@gitea.example.com/api/packages/{owner}/pypi/simple --no-deps {package_name} -``` - -| 参数 | 描述 | -| -------------- | ----------------------------- | -| `username` | 您的 Gitea 用户名 | -| `password` | 您的 Gitea 密码或个人访问令牌 | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | - -例如: - -```shell -pip install --index-url https://testuser:password123@gitea.example.com/api/packages/testuser/pypi/simple --no-deps test_package -``` - -您可以使用 `--extra-index-url` 替代 `--index-url`,但这样会使您容易受到依赖混淆攻击,因为 `pip` 会先检查官方 PyPi 仓库中的软件包,然后再检查指定的自定义仓库。请阅读 `pip` 文档以获取更多信息。 - -## 支持的命令 - -``` -pip install -twine upload -``` diff --git a/docs/content/usage/packages/rpm.en-us.md b/docs/content/usage/packages/rpm.en-us.md deleted file mode 100644 index 1f93376b7b..0000000000 --- a/docs/content/usage/packages/rpm.en-us.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -date: "2023-03-08T00:00:00+00:00" -title: "RPM Package Registry" -slug: "rpm" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "RPM" - sidebar_position: 105 - identifier: "rpm" ---- - -# RPM Package Registry - -Publish [RPM](https://rpm.org/) packages for your user or organization. - -## Requirements - -To work with the RPM registry, you need to use a package manager like `yum`, `dnf` or `zypper` to consume packages. - -The following examples use `dnf`. - -## Configuring the package registry - -To register the RPM registry add the url to the list of known sources: - -```shell -dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo -``` - -| Placeholder | Description | -| ----------- | ----------- | -| `owner` | The owner of the package. | -| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. | - -Example: - -```shell -# without a group -dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm.repo - -# with the group 'centos/el7' -dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm/centos/el7.repo -``` - -If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication): - -```shell -dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo -``` - -You have to add the credentials to the urls in the created `.repo` file in `/etc/yum.repos.d` too. - -## Publish a package - -To publish a RPM package (`*.rpm`), perform a HTTP PUT operation with the package content in the request body. - -``` -PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload -``` - -| Parameter | Description | -| --------- | ----------- | -| `owner` | The owner of the package. | -| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. | - -Example request using HTTP Basic authentication: - -```shell -# without a group -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.rpm \ - https://gitea.example.com/api/packages/testuser/rpm/upload - -# with the group 'centos/el7' -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.rpm \ - https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. -You cannot publish a file with the same name twice to a package. You must delete the existing package version first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exist already in the package. | - -## Delete a package - -To delete an RPM package perform a HTTP DELETE operation. This will delete the package version too if there is no file left. - -``` -DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{package_name}/{package_version}/{architecture} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `group` | Optional: The package group. | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `architecture` | The package architecture. | - -Example request using HTTP Basic authentication: - -```shell -# without a group -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/rpm/package/test-package/1.0.0/x86_64 - -# with the group 'centos/el7' -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64 -``` - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `204 No Content` | Success | -| `404 Not Found` | The package or file was not found. | - -## Install a package - -To install a package from the RPM registry, execute the following commands: - -```shell -# use latest version -dnf install {package_name} -# use specific version -dnf install {package_name}-{package_version}.{architecture} -``` diff --git a/docs/content/usage/packages/rpm.zh-cn.md b/docs/content/usage/packages/rpm.zh-cn.md deleted file mode 100644 index cbe74bfee2..0000000000 --- a/docs/content/usage/packages/rpm.zh-cn.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -date: "2023-03-08T00:00:00+00:00" -title: "RPM 软件包注册表" -slug: "packages/rpm" -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "RPM" - sidebar_position: 105 - identifier: "rpm" ---- - -# RPM 软件包注册表 - -为您的用户或组织发布 [RPM](https://rpm.org/) 软件包。 - -## 要求 - -要使用RPM注册表,您需要使用像 `yum`, `dnf` 或 `zypper` 这样的软件包管理器来消费软件包。 - -以下示例使用 `dnf`。 - -## 配置软件包注册表 - -要注册RPM注册表,请将 URL 添加到已知 `apt` 源列表中: - -```shell -dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo -``` - -| 占位符 | 描述 | -| ------- |--------------------------------------| -| `owner` | 软件包的所有者 | -| `group` | 任何名称,例如 `centos/7`、`el-7`、`fc38` | - -如果注册表是私有的,请在URL中提供凭据。您可以使用密码或[个人访问令牌](development/api-usage.md#通过-api-认证): - -```shell -dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo -``` - -您还必须将凭据添加到 `/etc/yum.repos.d` 中的 `rpm.repo` 文件中的URL中。 - -## 发布软件包 - -要发布RPM软件包(`*.rpm`),请执行带有软件包内容的 HTTP `PUT` 操作。 - -``` -PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload -``` - -| 参数 | 描述 | -| ------- |--------------| -| `owner` | 软件包的所有者 | -| `group` | 软件包自定义分组名称 | - -使用HTTP基本身份验证的示例请求: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/file.rpm \ - https://gitea.example.com/api/packages/testuser/rpm/centos/el7/version/upload -``` - -如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。您无法将具有相同名称的文件两次发布到软件包中。您必须先删除现有的软件包版本。 - -服务器将以以下HTTP状态码响应。 - -| HTTP 状态码 | 含义 | -| ----------------- | ------------------------------------------------ | -| `201 Created` | 软件包已发布 | -| `400 Bad Request` | 软件包无效 | -| `409 Conflict` | 具有相同参数组合的软件包文件已经存在于该软件包中 | - -## 删除软件包 - -要删除 RPM 软件包,请执行 HTTP `DELETE` 操作。如果没有文件剩余,这也将删除软件包版本。 - -``` -DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{package_name}/{package_version}/{architecture} -``` - -| 参数 | 描述 | -| ----------------- | -------------- | -| `owner` | 软件包的所有者 | -| `group` | 软件包自定义分组 | -| `package_name` | 软件包名称 | -| `package_version` | 软件包版本 | -| `architecture` | 软件包架构 | - -使用HTTP基本身份验证的示例请求: - -```shell -curl --user your_username:your_token_or_password -X DELETE \ - https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64 -``` - -服务器将以以下HTTP状态码响应: - -| HTTP 状态码 | 含义 | -| ---------------- | ------------------ | -| `204 No Content` | 成功 | -| `404 Not Found` | 未找到软件包或文件 | - -## 安装软件包 - -要从RPM注册表安装软件包,请执行以下命令: - -```shell -# use latest version -dnf install {package_name} -# use specific version -dnf install {package_name}-{package_version}.{architecture} -``` diff --git a/docs/content/usage/packages/rubygems.en-us.md b/docs/content/usage/packages/rubygems.en-us.md deleted file mode 100644 index cb1a225bc6..0000000000 --- a/docs/content/usage/packages/rubygems.en-us.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "RubyGems Package Registry" -slug: "rubygems" -sidebar_position: 110 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "RubyGems" - sidebar_position: 110 - identifier: "rubygems" ---- - -# RubyGems Package Registry - -Publish [RubyGems](https://guides.rubygems.org/) packages for your user or organization. - -## Requirements - -To work with the RubyGems package registry, you need to use the [gem](https://guides.rubygems.org/command-reference/) command line tool to consume and publish packages. - -## Configuring the package registry - -To register the package registry edit the `~/.gem/credentials` file and add: - -```ini ---- -https://gitea.example.com/api/packages/{owner}/rubygems: Bearer {token} -``` - -| Parameter | Description | -| ------------- | ----------- | -| `owner` | The owner of the package. | -| `token` | Your [personal access token](development/api-usage.md#authentication). | - -For example: - -``` ---- -https://gitea.example.com/api/packages/testuser/rubygems: Bearer 3bd626f84b01cd26b873931eace1e430a5773cc4 -``` - -## Publish a package - -Publish a package by running the following command: - -```shell -gem push --host {host} {package_file} -``` - -| Parameter | Description | -| -------------- | ----------- | -| `host` | URL to the package registry. | -| `package_file` | Path to the package `.gem` file. | - -For example: - -```shell -gem push --host https://gitea.example.com/api/packages/testuser/rubygems test_package-1.0.0.gem -``` - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -## Install a package - -To install a package from the package registry you can use [Bundler](https://bundler.io) or `gem`. - -### Bundler - -Add a new `source` block to your `Gemfile`: - -``` -source "https://gitea.example.com/api/packages/{owner}/rubygems" do - gem "{package_name}" -end -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | - -For example: - -``` -source "https://gitea.example.com/api/packages/testuser/rubygems" do - gem "test_package" -end -``` - -Afterwards run the following command: - -```shell -bundle install -``` - -### gem - -Execute the following command: - -```shell -gem install --host https://gitea.example.com/api/packages/{owner}/rubygems {package_name} -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | - -For example: - -```shell -gem install --host https://gitea.example.com/api/packages/testuser/rubygems test_package -``` - -## Supported commands - -``` -gem install -bundle install -gem push -``` diff --git a/docs/content/usage/packages/rubygems.zh-cn.md b/docs/content/usage/packages/rubygems.zh-cn.md deleted file mode 100644 index 71db4aaaeb..0000000000 --- a/docs/content/usage/packages/rubygems.zh-cn.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -date: "2021-07-20T00:00:00+00:00" -title: "RubyGems 软件包注册表" -slug: "rubygems" -sidebar_position: 110 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "RubyGems" - sidebar_position: 110 - identifier: "rubygems" ---- - -# RubyGems 软件包注册表 - -为您的用户或组织发布 [RubyGems](https://guides.rubygems.org/) 软件包。 - -## 要求 - -要使用RubyGems软件包注册表,您需要使用 [gem](https://guides.rubygems.org/command-reference/) 命令行工具来消费和发布软件包。 - -## 配置软件包注册表 - -要注册软件包注册表,请编辑 `~/.gem/credentials` 文件并添加: - -```ini ---- -https://gitea.example.com/api/packages/{owner}/rubygems: Bearer {token} -``` - -| 参数 | 描述 | -| ------- | ------------------------------------------------------------------------------------- | -| `owner` | 软件包的所有者 | -| `token` | 您的[个人访问令牌](development/api-usage.md#通过-api-认证) | - -例如: - -``` ---- -https://gitea.example.com/api/packages/testuser/rubygems: Bearer 3bd626f84b01cd26b873931eace1e430a5773cc4 -``` - -## 发布软件包 - -通过运行以下命令来发布软件包: - -```shell -gem push --host {host} {package_file} -``` - -| 参数 | 描述 | -| -------------- | ------------------------ | -| `host` | 软件包注册表的URL | -| `package_file` | 软件包 `.gem` 文件的路径 | - -例如: - -```shell -gem push --host https://gitea.example.com/api/packages/testuser/rubygems test_package-1.0.0.gem -``` - -如果已经存在相同名称和版本的软件包,您将无法发布软件包。您必须先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装软件包,您可以使用 [Bundler](https://bundler.io) 或 `gem`。 - -### Bundler - -在您的 `Gemfile` 中添加一个新的 `source` 块: - -``` -source "https://gitea.example.com/api/packages/{owner}/rubygems" do - gem "{package_name}" -end -``` - -| 参数 | 描述 | -| -------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | - -例如: - -``` -source "https://gitea.example.com/api/packages/testuser/rubygems" do - gem "test_package" -end -``` - -之后运行以下命令: - -```shell -bundle install -``` - -### gem - -执行以下命令: - -```shell -gem install --host https://gitea.example.com/api/packages/{owner}/rubygems {package_name} -``` - -| 参数 | 描述 | -| -------------- | -------------- | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包名称 | - -例如: - -```shell -gem install --host https://gitea.example.com/api/packages/testuser/rubygems test_package -``` - -## 支持的命令 - -``` -gem install -bundle install -gem push -``` diff --git a/docs/content/usage/packages/storage.en-us.md b/docs/content/usage/packages/storage.en-us.md deleted file mode 100644 index f437412dcc..0000000000 --- a/docs/content/usage/packages/storage.en-us.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -date: "2022-11-01T00:00:00+00:00" -title: "Storage" -slug: "storage" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Storage" - sidebar_position: 2 - identifier: "storage" ---- - -# Storage - -This document describes the storage of the package registry and how it can be managed. - -## Deduplication - -The package registry has a build-in deduplication of uploaded blobs. -If two identical files are uploaded only one blob is saved on the filesystem. -This ensures no space is wasted for duplicated files. - -If two packages are uploaded with identical files, both packages will display the same size but on the filesystem they require only half of the size. -Whenever a package gets deleted, only the references to the underlying blobs are removed. -The blobs get not removed at this moment, so they still require space on the filesystem. -When a new package gets uploaded the existing blobs may get referenced again. - -These unreferenced blobs get deleted by a [clean up job](administration/config-cheat-sheet.md#cron---cleanup-expired-packages-croncleanup_packages). -The config setting `OLDER_THAN` configures how long unreferenced blobs are kept before they get deleted. - -## Cleanup Rules - -Package registries can become large over time without cleanup. -It's recommended to delete unnecessary packages and set up cleanup rules to automatically manage the package registry usage. -Every package owner (user or organization) manages the cleanup rules which are applied to their packages. - -|Setting|Description| -|-|-| -|Enabled|Turn the cleanup rule on or off.| -|Type|Every rule manages a specific package type.| -|Apply pattern to full package name|If enabled, the patterns below are applied to the full package name (`package/version`). Otherwise only the version (`version`) is used.| -|Keep the most recent|How many versions to *always* keep for each package.| -|Keep versions matching|The regex pattern that determines which versions to keep. An empty pattern keeps no version while `.+` keeps all versions. The container registry will always keep the `latest` version even if not configured.| -|Remove versions older than|Remove only versions older than the selected days.| -|Remove versions matching|The regex pattern that determines which versions to remove. An empty pattern or `.+` leads to the removal of every package if no other setting tells otherwise.| - -Every cleanup rule can show a preview of the affected packages. -This can be used to check if the cleanup rules is proper configured. - -### Regex examples - -Regex patterns are automatically surrounded with `\A` and `\z` anchors. -Do not include any `\A`, `\z`, `^` or `$` token in the regex patterns as they are not necessary. -The patterns are case-insensitive which matches the behaviour of the package registry in Gitea. - -|Pattern|Description| -|-|-| -|`.*`|Match every possible version.| -|`v.+`|Match versions that start with `v`.| -|`release`|Match only the version `release`.| -|`release.*`|Match versions that are either named or start with `release`.| -|`.+-temp-.+`|Match versions that contain `-temp-`.| -|`v.+\|release`|Match versions that either start with `v` or are named `release`.| -|`package/v.+\|other/release`|Match versions of the package `package` that start with `v` or the version `release` of the package `other`. This needs the setting *Apply pattern to full package name* enabled.| - -### How the cleanup rules work - -The cleanup rules are part of the [clean up job](administration/config-cheat-sheet.md#cron---cleanup-expired-packages-croncleanup_packages) and run periodically. - -The cleanup rule: - -1. Collects all packages of the package type for the owners registry. -2. For every package it collects all versions. -3. Excludes from the list the # versions based on the *Keep the most recent* value. -4. Excludes from the list any versions matching the *Keep versions matching* value. -5. Excludes from the list the versions more recent than the *Remove versions older than* value. -6. Excludes from the list any versions not matching the *Remove versions matching* value. -7. Deletes the remaining versions. diff --git a/docs/content/usage/packages/storage.zh-cn.md b/docs/content/usage/packages/storage.zh-cn.md deleted file mode 100644 index 3832e80c98..0000000000 --- a/docs/content/usage/packages/storage.zh-cn.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -date: "2022-11-01T00:00:00+00:00" -title: "存储" -slug: "storage" -sidebar_position: 5 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Storage" - sidebar_position: 2 - identifier: "storage" ---- - -# 存储 - -本文档描述了软件包注册表的存储方式以及如何管理存储。 - -## 去重 - -软件包注册表具有内置的去重功能,可以对上传的 Blob 进行去重处理。 -如果上传了两个相同的文件,只会在文件系统上保存一个 Blob。 -这样可以确保不会浪费空间用于重复的文件。 - -如果上传了两个具有相同文件的软件包,这两个软件包将显示相同的大小,但在文件系统上,它们只需要一半的大小。 -每当删除一个软件包时,只会删除对底层 Blob 的引用。 -此时,Blob 不会被删除,因此它们仍然占用文件系统上的空间。 -当上传新的软件包时,现有的 Blob 可能会再次被引用。 - -这些无引用的 Blob 会在一个清理任务中被删除。 -配置设置 `OLDER_THAN` 可以配置无引用的 Blob 在被删除之前保留的时间。 - -## 清理规则 - -软件包注册表可能会随着时间的推移而变得很大,如果不进行清理的话。 -建议删除不必要的软件包并设置清理规则以自动管理软件包注册表的使用情况。 -每个软件包所有者(用户或组织)都可以管理应用于其软件包的清理规则。 - -| 设置 | 描述 | -| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| 启用 | 打开或关闭清理规则。 | -| 类型 | 每个规则管理特定的软件包类型。 | -| 将模式应用于完整的软件包名称 | 如果启用,则应用以下模式到完整的软件包名称(`package/version`),否则只使用版本号(`version`)。 | -| 保留最近的版本数 | 对于每个软件包要始终保留的版本数量。 | -| 保留与以下模式匹配的版本 | 确定要保留哪些版本的正则表达式模式。空模式表示不保留任何版本,而 `.+` 表示保留所有版本。即使未配置,容器注册表也始终保留 `latest` 版本。 | -| 删除早于多少天的版本 | 仅删除早于所选天数的版本。 | -| 删除与以下模式匹配的版本 | 确定要删除哪些版本的正则表达式模式。空模式或 `.+` 表示如果没有其他设置指定,则删除所有软件包。 | - -每个清理规则都可以显示受影响的软件包的预览。 -这可以用来检查清理规则是否正确配置。 - -### 正则表达式示例 - -正则表达式模式会自动使用 `\A` 和 `\z` 锚点进行包围。 -不要在正则表达式模式中包含任何 `\A`、`\z`、`^` 或 `$` 标记,因为它们不是必要的。 -模式是不区分大小写的,与 Gitea 中的软件包注册表的行为相匹配。 - -| Pattern | Description | -| ---------------------------- | ------------------------------------------------------------------------------------------------------------- | -| `.*` | 匹配任何可能的版本。 | -| `v.+` | 匹配以 `v` 开头的版本。 | -| `release` | 仅匹配版本号为 `release`。 | -| `release.*` | 匹配以 `release` 命名或以 `release` 开头的版本。 | -| `.+-temp-.+` | 匹配包含 `-temp-` 的版本。 | -| `v.+\|release` | 匹配以 `v` 开头的版本或版本号为 `release`。 | -| `package/v.+\|other/release` | 匹配以 `v` 开头的 package 的版本或 `other` 的版本号为 `release`。需要启用*将模式应用于完整的软件包名称*设置。 | - -### 清理规则的工作原理 - -清理规则是清理任务的一部分,定期运行。 - -清理规则: - -1. 收集所有属于所有者注册表的特定软件包类型的软件包。 -2. 对于每个软件包,收集所有版本。 -3. 根据 *保留最近的版本数* 的值,从列表中排除版本。 -4. 根据 *保留与以下模式匹配的版本* 的值,从列表中排除任何版本。 -5. 根据 *删除早于多少天的版本* 的值,从列表中排除比这个值更近的版本。 -6. 根据 *删除与以下模式匹配的版本* 的值,从列表中排除任何不匹配的版本。 -7. 删除剩余的版本。 diff --git a/docs/content/usage/packages/swift.en-us.md b/docs/content/usage/packages/swift.en-us.md deleted file mode 100644 index 38eb155641..0000000000 --- a/docs/content/usage/packages/swift.en-us.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -date: "2023-01-10T00:00:00+00:00" -title: "Swift Package Registry" -slug: "swift" -sidebar_position: 95 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Swift" - sidebar_position: 95 - identifier: "swift" ---- - -# Swift Package Registry - -Publish [Swift](https://www.swift.org/) packages for your user or organization. - -## Requirements - -To work with the Swift package registry, you need to use [swift](https://www.swift.org/getting-started/) to consume and a HTTP client (like `curl`) to publish packages. - -## Configuring the package registry - -To register the package registry and provide credentials, execute: - -```shell -swift package-registry set https://gitea.example.com/api/packages/{owner}/swift -swift package-registry login https://gitea.example.com/api/packages/{owner}/swift --username {username} --password {password} -``` - -| Placeholder | Description | -| ------------ | ----------- | -| `owner` | The owner of the package. | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | - -The login is optional and only needed if the package registry is private. - -## Publish a package - -First you have to pack the contents of your package: - -```shell -swift package archive-source -``` - -To publish the package perform a HTTP PUT request with the package content in the request body. - -```shell --user your_username:your_password_or_token \ -curl -X PUT --user {username}:{password} \ - -H "Accept: application/vnd.swift.registry.v1+json" \ - -F source-archive=@/path/to/package.zip \ - -F metadata={metadata} \ - https://gitea.example.com/api/packages/{owner}/swift/{scope}/{name}/{version} -``` - -| Placeholder | Description | -| ----------- | ----------- | -| `username` | Your Gitea username. | -| `password` | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. | -| `owner` | The owner of the package. | -| `scope` | The package scope. | -| `name` | The package name. | -| `version` | The package version. | -| `metadata` | (Optional) The metadata of the package. JSON encoded subset of https://schema.org/SoftwareSourceCode | - -You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package file with the same combination of parameters exists already. | - -## Install a package - -To install a Swift package from the package registry, add it in the `Package.swift` file dependencies list: - -``` -dependencies: [ - .package(id: "{scope}.{name}", from:"{version}") -] -``` - -| Parameter | Description | -| ----------- | ----------- | -| `scope` | The package scope. | -| `name` | The package name. | -| `version` | The package version. | - -Afterwards execute the following command to install it: - -```shell -swift package resolve -``` diff --git a/docs/content/usage/packages/swift.zh-cn.md b/docs/content/usage/packages/swift.zh-cn.md deleted file mode 100644 index 595a705e79..0000000000 --- a/docs/content/usage/packages/swift.zh-cn.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -date: "2023-01-10T00:00:00+00:00" -title: "Swift 软件包注册表" -slug: "swift" -sidebar_position: 95 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Swift" - sidebar_position: 95 - identifier: "swift" ---- - -# Swift 软件包注册表 - -为您的用户或组织发布 [Swift](https://www.swift.org/) 软件包。 - -## 要求 - -要使用 Swift 软件包注册表,您需要使用 [swift](https://www.swift.org/getting-started/) 消费软件包,并使用 HTTP 客户端(如 `curl`)发布软件包。 - -## 配置软件包注册表 - -要注册软件包注册表并提供凭据,请执行以下命令: - -```shell -swift package-registry set https://gitea.example.com/api/packages/{owner}/swift -login {username} -password {password} -``` - -| 占位符 | 描述 | -| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `owner` | 软件包的所有者。 | -| `username` | 您的 Gitea 用户名。 | -| `password` | 您的 Gitea 密码。如果您使用两步验证或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)代替密码。 | - -登录是可选的,只有在软件包注册表是私有的情况下才需要。 - -## 发布软件包 - -首先,您需要打包软件包的内容: - -```shell -swift package archive-source -``` - -要发布软件包,请执行一个带有软件包内容的 HTTP `PUT` 请求,将内容放在请求正文中。 - -```shell --user your_username:your_password_or_token \ -curl -X PUT --user {username}:{password} \ - -H "Accept: application/vnd.swift.registry.v1+json" \ - -F source-archive=@/path/to/package.zip \ - -F metadata={metadata} \ - https://gitea.example.com/api/packages/{owner}/swift/{scope}/{name}/{version} -``` - -| 占位符 | 描述 | -| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `username` | 您的 Gitea 用户名。 | -| `password` | 您的 Gitea 密码。如果您使用两步验证或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)代替密码。 | -| `owner` | 软件包的所有者。 | -| `scope` | 软件包的作用域。 | -| `name` | 软件包的名称。 | -| `version` | 软件包的版本。 | -| `metadata` | (可选)软件包的元数据。以 JSON 编码的子集,格式参考 https://schema.org/SoftwareSourceCode | - -如果已经存在相同名称和版本的软件包,则无法发布软件包。您必须首先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装 Swift 软件包,请将其添加到 `Package.swift` 文件的依赖项列表中: - -``` -dependencies: [ - .package(id: "{scope}.{name}", from:"{version}") -] -``` - -| 参数 | 描述 | -| --------- | -------------- | -| `scope` | 软件包的作用域 | -| `name` | 软件包的名称 | -| `version` | 软件包的版本 | - -之后,执行以下命令来安装它: - -```shell -swift package resolve -``` diff --git a/docs/content/usage/packages/vagrant.en-us.md b/docs/content/usage/packages/vagrant.en-us.md deleted file mode 100644 index baa9c2b83e..0000000000 --- a/docs/content/usage/packages/vagrant.en-us.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -date: "2022-08-23T00:00:00+00:00" -title: "Vagrant Package Registry" -slug: "vagrant" -sidebar_position: 120 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Vagrant" - sidebar_position: 120 - identifier: "vagrant" ---- - -# Vagrant Package Registry - -Publish [Vagrant](https://www.vagrantup.com/) packages for your user or organization. - -## Requirements - -To work with the Vagrant package registry, you need [Vagrant](https://www.vagrantup.com/downloads) and a tool to make HTTP requests like `curl`. - -## Publish a package - -Publish a Vagrant box by performing a HTTP PUT request to the registry: - -``` -PUT https://gitea.example.com/api/packages/{owner}/vagrant/{package_name}/{package_version}/{provider}.box -``` - -| Parameter | Description | -| ----------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | -| `package_version` | The package version, semver compatible. | -| `provider` | One of the [supported provider names](https://www.vagrantup.com/docs/providers). | - -Example for uploading a Hyper-V box: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/your/vagrant.box \ - https://gitea.example.com/api/packages/testuser/vagrant/test_system/1.0.0/hyperv.box -``` - -If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. - -You cannot publish a box if a box of the same name, version and provider already exists. You must delete the existing package first. - -The server responds with the following HTTP Status codes. - -| HTTP Status Code | Meaning | -| ----------------- | ------- | -| `201 Created` | The package has been published. | -| `400 Bad Request` | The package is invalid. | -| `409 Conflict` | A package with the same combination of parameters exists already. | - -## Install a package - -To install a box from the package registry, execute the following command: - -```shell -vagrant box add "https://gitea.example.com/api/packages/{owner}/vagrant/{package_name}" -``` - -| Parameter | Description | -| -------------- | ----------- | -| `owner` | The owner of the package. | -| `package_name` | The package name. | - -For example: - -```shell -vagrant box add "https://gitea.example.com/api/packages/testuser/vagrant/test_system" -``` - -This will install the latest version of the package. To add a specific version, use the `--box-version` parameter. -If the registry is private you can pass your [personal access token](development/api-usage.md#authentication) in the `VAGRANT_CLOUD_TOKEN` environment variable. - -## Supported commands - -``` -vagrant box add -``` diff --git a/docs/content/usage/packages/vagrant.zh-cn.md b/docs/content/usage/packages/vagrant.zh-cn.md deleted file mode 100644 index 67d79ad3cc..0000000000 --- a/docs/content/usage/packages/vagrant.zh-cn.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -date: "2022-08-23T00:00:00+00:00" -title: "Vagrant 软件包注册表" -slug: "vagrant" -sidebar_position: 120 -draft: false -toc: false -menu: - sidebar: - parent: "packages" - name: "Vagrant" - sidebar_position: 120 - identifier: "vagrant" ---- - -# Vagrant 软件包注册表 - -为您的用户或组织发布 [Vagrant](https://www.vagrantup.com/) 软件包。 - -## 要求 - -要使用 Vagrant 软件包注册表,您需要安装 [Vagrant](https://www.vagrantup.com/downloads) 并使用类似于 `curl` 的工具进行 HTTP 请求。 - -## 发布软件包 - -通过执行 HTTP PUT 请求将 Vagrant box 发布到注册表: - -``` -PUT https://gitea.example.com/api/packages/{owner}/vagrant/{package_name}/{package_version}/{provider}.box -``` - -| 参数 | 描述 | -| ----------------- | ------------------------------------------------------------------ | -| `owner` | 软件包的所有者 | -| `package_name` | 软件包的名称 | -| `package_version` | 软件包的版本,兼容 semver 格式 | -| `provider` | [支持的提供程序名称](https://www.vagrantup.com/docs/providers)之一 | - -上传 Hyper-V box 的示例: - -```shell -curl --user your_username:your_password_or_token \ - --upload-file path/to/your/vagrant.box \ - https://gitea.example.com/api/packages/testuser/vagrant/test_system/1.0.0/hyperv.box -``` - -如果已经存在相同名称、版本和提供程序的软件包,则无法发布软件包。您必须首先删除现有的软件包。 - -## 安装软件包 - -要从软件包注册表安装软件包,请执行以下命令: - -```shell -vagrant box add "https://gitea.example.com/api/packages/{owner}/vagrant/{package_name}" -``` - -| 参数 | 描述 | -| -------------- | --------------- | -| `owner` | 软件包的所有者. | -| `package_name` | 软件包的名称 | - -例如: - -```shell -vagrant box add "https://gitea.example.com/api/packages/testuser/vagrant/test_system" -``` - -这将安装软件包的最新版本。要添加特定版本,请使用` --box-version` 参数。 -如果注册表是私有的,您可以将您的[个人访问令牌](development/api-usage.md#通过-api-认证)传递给 `VAGRANT_CLOUD_TOKEN` 环境变量。 - -## 支持的命令 - -``` -vagrant box add -``` diff --git a/docs/content/usage/permissions.en-us.md b/docs/content/usage/permissions.en-us.md deleted file mode 100644 index e4bef138ab..0000000000 --- a/docs/content/usage/permissions.en-us.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -date: "2021-12-13:10:10+08:00" -title: "Permissions" -slug: "permissions" -sidebar_position: 14 -toc: false -draft: false -aliases: - - /en-us/permissions -menu: - sidebar: - parent: "usage" - name: "Permissions" - sidebar_position: 14 - identifier: "permissions" ---- - -# Permissions - -Gitea supports permissions for repository so that you can give different access for different people. At first, we need to know about `Unit`. - -## Unit - -In Gitea, we call a sub module of a repository `Unit`. Now we have following possible units. - -| Name | Description | Permissions | -| --------------- | ---------------------------------------------------- | ----------- | -| Code | Access source code, files, commits and branches. | Read Write | -| Issues | Organize bug reports, tasks and milestones. | Read Write | -| PullRequests | Enable pull requests and code reviews. | Read Write | -| Releases | Track project versions and downloads. | Read Write | -| Wiki | Write and share documentation with collaborators. | Read Write | -| ExternalWiki | Link to an external wiki | Read | -| ExternalTracker | Link to an external issue tracker | Read | -| Projects | The URL to the template repository | Read Write | -| Packages | Packages which linked to this repository | Read Write | -| Actions | Review actions logs or restart/cacnel pipelines | Read Write | -| Settings | Manage the repository | Admin | - -With different permissions, people could do different things with these units. - -| Name | Read | Write | Admin | -| --------------- | ------------------------------------------------- | ---------------------------- | ------------------------- | -| Code | View code trees, files, commits, branches and etc. | Push codes. | - | -| Issues | View issues and create new issues. | Add labels, assign, close | - | -| PullRequests | View pull requests and create new pull requests. | Add labels, assign, close | - | -| Releases | View releases and download files. | Create/Edit releases | - | -| Wiki | View wiki pages. Clone the wiki repository. | Create/Edit wiki pages, push | - | -| ExternalWiki | Link to an external wiki | - | - | -| ExternalTracker | Link to an external issue tracker | - | - | -| Projects | View the columns of projects | Change issues across columns | - | -| Packages | View the packages | Upload/Delete packages | - | -| Actions | View the Actions logs | Approve / Cancel / Restart | - | -| Settings | - | - | Manage the repository | - -And there are some differences for permissions between individual repositories and organization repositories. - -## Individual Repository - -For individual repositories, the creators are the only owners of repositories and have no limit to change anything of this -repository or delete it. Repositories owners could add collaborators to help maintain the repositories. Collaborators could have `Read`, `Write` and `Admin` permissions. - -For a private repository, the experience is similar to visiting an anonymous public repository. You have access to all the available content within the repository, including the ability to clone the code, create issues, respond to issue comments, submit pull requests, and more. If you have 'Write' permission, you can push code to specific branches of the repository, provided it's permitted by the branch protection rules. Additionally, you can make changes to the wiki pages. With 'Admin' permission, you have the ability to modify the repository's settings. - -But you cannot delete or transfer this repository if you are not that repository's owner. - -## Organization Repository - -For individual repositories, the owner is the user who created it. For organization repositories, the owners are the members of the owner team on this organization. All the permissions depends on the team permission settings. - -### Owner Team - -The owner team will be created when the organization is created, and the creator will become the first member of the owner team. The owner team cannot be deleted and there is at least one member. - -### Admin Team - -When creating teams, there are two types of teams. One is the admin team, another is the general team. An admin team can be created to manage some of the repositories, whose members can do anything with these repositories. Only members of the owner or admin team can create a new team. - -### General Team - -A general team in an organization has unit permissions settings. It can have members and repositories scope. - -- A team could access all the repositories in this organization or special repositories. -- A team could also be allowed to create new repositories or not. - -The General team can be created to do the operations allowed by their permissions. One member could join multiple teams. diff --git a/docs/content/usage/permissions.zh-cn.md b/docs/content/usage/permissions.zh-cn.md deleted file mode 100644 index 0c748aef96..0000000000 --- a/docs/content/usage/permissions.zh-cn.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "权限" -slug: "permissions" -sidebar_position: 14 -toc: false -draft: false -aliases: - - /zh-cn/permissions -menu: - sidebar: - parent: "usage" - name: "权限" - sidebar_position: 14 - identifier: "permissions" ---- - -# 权限 - -Gitea 支持对仓库进行权限管理,这样您就可以为不同的人员提供不同的访问权限。首先,我们需要了解 `单元(Unit)`。 - -## 单元(Unit) - -在 Gitea 中,我们将仓库的子模块称为 `单元(Unit)`。现在我们有以下几个单元。 - -| 名称 | 描述 | 权限 | -| ----------------- | --------------------------------------------------- | ------------ | -| 代码 | 访问源代码、文件、提交和分支。 | 读取 写入 | -| 工单 | 组织缺陷报告、任务和里程碑。 | 读取 写入 | -| 合并请求 | 启用合并请求和代码审核。 | 读取 写入 | -| 发布 | 跟踪项目版本和下载。 | 读取 写入 | -| 百科 | 与协作者编写和共享文档。 | 读取 写入 | -| 外部百科 | 链接到外部维基。 | 读取 | -| 外部工单跟踪器 | 链接到外部工单跟踪器。 | 读取 | -| 项目 | 模板仓库的 URL。 | 读取 写入 | -| 包 | 链接到仓库 | 读取 写入 | -| Actions | 审查Actions日志或重启/取消工作流 | 读取 写入 | -| 设置 | 管理仓库。 | 管理员 | - -通过不同的权限,用户可以在这些单元上执行不同的操作。 - -| 名称 | 读取 | 写入 | 管理员 | -| ----------------- | -------------------------------------------------- | ------------------------------ | ------------------------- | -| 代码 | 查看代码树、文件、提交、分支等。 | 推送代码。 | - | -| 工单 | 查看工单并创建新工单。 | 添加标签、分配、关闭工单。 | - | -| 合并请求 | 查看合并请求并创建新合并请求。 | 添加标签、分配、关闭合并请求。 | - | -| 发布 | 查看发布和下载文件。 | 创建/编辑发布。 | - | -| 百科 | 查看百科页面。克隆百科仓库。 | 创建/编辑百科页面,推送更改。 | - | -| 外部百科 | 链接到外部百科。 | - | - | -| 外部工单跟踪器 | 链接到外部工单跟踪器。 | - | - | -| 项目 | 查看面板。 | 在面板之间移动工单。 | - | -| 包 | 查看包 | 上传/删除包 | - | -| Actions | 查看 Actions日志 | 同意 / 取消 / 重启 | - | -| 设置 | - | - | 管理仓库 | - -个人仓库和组织仓库之间的权限存在一些差异。 - -## 个人仓库 - -对于个人仓库,创建者是仓库的唯一所有者,对于该仓库的任何更改或删除没有限制。 -仓库所有者可以添加协作者来帮助维护仓库。协作者可以拥有 `读取(Read)`、`写入(Write)` 和 `管理员(Admin)` 权限。 - -访问私有仓库的体验与访问匿名公共仓库类似。您可以访问仓库中的所有可用内容,包括克隆代码、创建工单、回复工单评论、提交拉取请求等。如果你有 "写"权限,只要分支保护规则允许,你就可以向仓库的特定分支推送代码。此外,你还可以修改百科页面。有了 "管理"权限,你就可以修改仓库的设置。 - -但如果你不是该仓库的所有者,就不能删除或转移该仓库。 - -## 组织仓库 - -对于个人仓库,所有者是创建它的用户。而对于组织仓库,所有者是该组织中的所有者团队成员。对该组织仓库的所有权限都取决于团队权限设置。 - -### 所有者团队 - -创建组织时将自动创建所有者团队,创建者将成为所有者团队的第一名成员。所有者团队不可删除,且至少有一名成员。 - -### 管理员团队 - -创建团队时,有两种类型的团队。一种是管理员团队,另一种是普通团队。可以创建一个管理员团队来管理某些版本库,其成员可以对这些版本库做任何事情。只有所有者或管理员团队的成员才能创建新团队。 - -### 普通团队 - -组织中的普通团队具有可以根据`单元(Unit)`进行权限设置。它可以有成员和存储库范围。 - -- 一个团队可以访问所属组织的所有仓库或特殊仓库。 -- 也可以设置该团队是否有创建新仓库的权限。 - -可以通过创建 "普通团队",并通过权限控制对其行为进行限制。一名成员可以加入多个团队。 diff --git a/docs/content/usage/profile-readme.en-us.md b/docs/content/usage/profile-readme.en-us.md deleted file mode 100644 index 316a735a1c..0000000000 --- a/docs/content/usage/profile-readme.en-us.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -date: "2023-03-02T21:00:00+05:00" -title: "Profile READMEs" -slug: "profile-readme" -sidebar_position: 12 -toc: false -draft: false -menu: - sidebar: - parent: "usage" - name: "Profile READMEs" - sidebar_position: 12 - identifier: "profile-readme" ---- - -# Profile READMEs - -To display a Markdown file in your Gitea user or organization profile page, create a repository named `.profile` and add a new file named `README.md` to it. -Gitea will automatically display the contents of the file on your profile, in a new "Overview" above your repositories. - -Making the `.profile` repository private will hide the Profile README. - -Example of user with `.profile/README.md`: - -![profile readme screenshot](/images/usage/profile-readme.png) diff --git a/docs/content/usage/profile-readme.zh-cn.md b/docs/content/usage/profile-readme.zh-cn.md deleted file mode 100644 index b69d4aa921..0000000000 --- a/docs/content/usage/profile-readme.zh-cn.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "个人资料 README" -slug: "profile-readme" -sidebar_position: 12 -toc: false -draft: false -menu: - sidebar: - parent: "usage" - name: "个人资料 README" - sidebar_position: 12 - identifier: "profile-readme" ---- - -# 个人资料 README - -要在您的 Gitea 个人资料页面显示一个 Markdown 文件,只需创建一个名为 `.profile` 的仓库,并编辑其中的 `README.md` 文件。Gitea 将自动获取该文件并在您的仓库上方显示。 - -注意:您可以将此仓库设为私有。这样可以隐藏您的源文件,使其对公众不可见,并允许您将某些文件设为私有。但是,README.md 文件将是您个人资料上唯一存在的文件。如果您希望完全私有化 .profile 仓库,则需删除或重命名 README.md 文件。 - -用户示例 `.profile/README.md`: - -![个人资料自述文件截图](/images/usage/profile-readme.png) diff --git a/docs/content/usage/protected-tags.en-us.md b/docs/content/usage/protected-tags.en-us.md deleted file mode 100644 index b25cbdbb2e..0000000000 --- a/docs/content/usage/protected-tags.en-us.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -date: "2021-05-14T00:00:00-00:00" -title: "Protected tags" -slug: "protected-tags" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /en-us/protected-tags -menu: - sidebar: - parent: "usage" - name: "Protected tags" - sidebar_position: 45 - identifier: "protected-tags" ---- - -# Protected tags - -Protected tags allow control over who has permission to create or update Git tags. Each rule allows you to match either an individual tag name, or use an appropriate pattern to control multiple tags at once. - -## Setting up protected tags - -To protect a tag, you need to follow these steps: - -1. Go to the repository’s **Settings** > **Tags** page. -1. Type a pattern to match a name. You can use a single name, a [glob pattern](https://pkg.go.dev/github.com/gobwas/glob#Compile) or a regular expression. -1. Choose the allowed users and/or teams. If you leave these fields empty no one is allowed to create or modify this tag. -1. Select **Save** to save the configuration. - -## Pattern protected tags - -The pattern uses [glob](https://pkg.go.dev/github.com/gobwas/glob#Compile) or regular expressions to match a tag name. For regular expressions you need to enclose the pattern in slashes. - -Examples: - -| Type | Pattern Protected Tag | Possible Matching Tags | -| ----- | ------------------------ | --------------------------------------- | -| Glob | `v*` | `v`, `v-1`, `version2` | -| Glob | `v[0-9]` | `v0`, `v1` up to `v9` | -| Glob | `*-release` | `2.1-release`, `final-release` | -| Glob | `gitea` | only `gitea` | -| Glob | `*gitea*` | `gitea`, `2.1-gitea`, `1_gitea-release` | -| Glob | `{v,rel}-*` | `v-`, `v-1`, `v-final`, `rel-`, `rel-x` | -| Glob | `*` | matches all possible tag names | -| Regex | `/\Av/` | `v`, `v-1`, `version2` | -| Regex | `/\Av[0-9]\z/` | `v0`, `v1` up to `v9` | -| Regex | `/\Av\d+\.\d+\.\d+\z/` | `v1.0.17`, `v2.1.0` | -| Regex | `/\Av\d+(\.\d+){0,2}\z/` | `v1`, `v2.1`, `v1.2.34` | -| Regex | `/-release\z/` | `2.1-release`, `final-release` | -| Regex | `/gitea/` | `gitea`, `2.1-gitea`, `1_gitea-release` | -| Regex | `/\Agitea\z/` | only `gitea` | -| Regex | `/^gitea$/` | only `gitea` | -| Regex | `/\A(v\|rel)-/` | `v-`, `v-1`, `v-final`, `rel-`, `rel-x` | -| Regex | `/.+/` | matches all possible tag names | diff --git a/docs/content/usage/protected-tags.zh-cn.md b/docs/content/usage/protected-tags.zh-cn.md deleted file mode 100644 index 0529bf7932..0000000000 --- a/docs/content/usage/protected-tags.zh-cn.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "受保护的标签" -slug: "protected-tags" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /zh-cn/protected-tags -menu: - sidebar: - parent: "usage" - name: "受保护的标签" - sidebar_position: 45 - identifier: "protected-tags" ---- - -# 受保护的标签 - -受保护的标签允许控制谁有权限创建或更新 Git 标签。每个规则可以匹配单个标签名称,或者使用适当的模式来同时控制多个标签。 - -## 设置受保护的标签 - -要保护一个标签,你需要按照以下步骤进行操作: - -1. 进入仓库的**设置** > **标签**页面。 -2. 输入一个用于匹配名称的模式。你可以使用单个名称、[glob 模式](https://pkg.go.dev/github.com/gobwas/glob#Compile) 或正则表达式。 -3. 选择允许的用户和/或团队。如果将这些字段留空,则不允许任何人创建或修改此标签。 -4. 选择**保存**以保存配置。 - -## 模式受保护的标签 - -该模式使用 [glob](https://pkg.go.dev/github.com/gobwas/glob#Compile) 或正则表达式来匹配标签名称。对于正则表达式,你需要将模式括在斜杠中。 - -示例: - -| 类型 | 模式受保护的标签 | 可能匹配的标签 | -| ----- | ------------------------ | --------------------------------------- | -| Glob | `v*` | `v`,`v-1`,`version2` | -| Glob | `v[0-9]` | `v0`,`v1` 到 `v9` | -| Glob | `*-release` | `2.1-release`,`final-release` | -| Glob | `gitea` | 仅限 `gitea` | -| Glob | `*gitea*` | `gitea`,`2.1-gitea`,`1_gitea-release` | -| Glob | `{v,rel}-*` | `v-`,`v-1`,`v-final`,`rel-`,`rel-x` | -| Glob | `*` | 匹配所有可能的标签名称 | -| Regex | `/\Av/` | `v`,`v-1`,`version2` | -| Regex | `/\Av[0-9]\z/` | `v0`,`v1` 到 `v9` | -| Regex | `/\Av\d+\.\d+\.\d+\z/` | `v1.0.17`,`v2.1.0` | -| Regex | `/\Av\d+(\.\d+){0,2}\z/` | `v1`,`v2.1`,`v1.2.34` | -| Regex | `/-release\z/` | `2.1-release`,`final-release` | -| Regex | `/gitea/` | `gitea`,`2.1-gitea`,`1_gitea-release` | -| Regex | `/\Agitea\z/` | 仅限 `gitea` | -| Regex | `/^gitea$/` | 仅限 `gitea` | -| Regex | `/\A(v\|rel)-/` | `v-`,`v-1`,`v-final`,`rel-`,`rel-x` | -| Regex | `/.+/` | 匹配所有可能的标签名称 | diff --git a/docs/content/usage/pull-request.en-us.md b/docs/content/usage/pull-request.en-us.md deleted file mode 100644 index 0176d0af97..0000000000 --- a/docs/content/usage/pull-request.en-us.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -date: "2018-06-01T19:00:00+02:00" -title: "Pull Request" -slug: "pull-request" -sidebar_position: 13 -toc: false -draft: false -aliases: - - /en-us/pull-request -menu: - sidebar: - parent: "usage" - name: "Pull Request" - sidebar_position: 13 - identifier: "pull-request" ---- - -# Pull Request - -A Pull Request (PR) is a way to propose changes to a repository. -It is a request to merge one branch into another, accompanied by a description of the changes that were made. -Pull Requests are commonly used as a way for contributors to propose changes and for maintainers to review and merge those changes. - -## Creating a pull request - -To create a PR, you'll need to follow these steps: - -1. **Fork the repository** - If you don't have permission to make changes to the repository directly, you'll need to fork the repository to your own account. -This creates a copy of the repository that you can make changes to. - -2. **Create a branch (optional)** - Create a new branch on your forked repository that contains the changes you want to propose. -Give the branch a descriptive name that indicates what the changes are for. - -3. **Make your changes** - Make the changes you want, commit, and push them to your forked repository. - -4. **Create the PR** - Go to the original repository and go to the "Pull Requests" tab. Click the "New Pull Request" button and select your new branch as the source branch. -Enter a descriptive title and description for your Pull Request and click "Create Pull Request". - -## Reviewing a pull request - -When a PR is created, it triggers a review process. The maintainers of the repository are notified of the PR and can review the changes that were made. -They can leave comments, request changes, or approve the changes. - -If the maintainers request changes, you'll need to make those changes in your branch and push the changes to your forked repository. -The PR will be updated automatically with the new changes. - -If the maintainers approve the changes, they can merge the PR into the repository. - -## Closing a pull request - -If you decide that you no longer want to merge a PR, you can close it. -To close a PR, go to the open PR and click the "Close Pull Request" button. This will close the PR without merging it. - -## "Work In Progress" pull requests - -Marking a pull request as being a work in progress will prevent that pull request from being accidentally merged. -To mark a pull request as being a work in progress, you must prefix its title by `WIP:` or `[WIP]` (case insensitive). -Those values are configurable in your `app.ini` file: - -```ini -[repository.pull-request] -WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP] -``` - -The first value of the list will be used in helpers. - -## Pull Request Templates - -You can find more information about pull request templates at the page [Issue and Pull Request templates](usage/issue-pull-request-templates.md). diff --git a/docs/content/usage/pull-request.zh-cn.md b/docs/content/usage/pull-request.zh-cn.md deleted file mode 100644 index a8f00dbd39..0000000000 --- a/docs/content/usage/pull-request.zh-cn.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -date: "2018-06-01T19:00:00+02:00" -title: "合并请求" -slug: "pull-request" -sidebar_position: 13 -toc: false -draft: false -aliases: - - /zh-cn/pull-request -menu: - sidebar: - parent: "usage" - name: "Pull Request" - sidebar_position: 13 - identifier: "pull-request" ---- - -# 合并请求 - -合并请求(PR)是一种提出对仓库进行更改的方式。 -它是一种将一个分支合并到另一个分支的请求,附带有对所做更改的描述。 -合并请求通常用作贡献者对仓库贡献代码的方式,仓库的维护者可以通过对合并请求进行审查来决定是否接受这些更改。 - -## 创建合并请求 - -要创建合并请求,您需要遵循以下步骤: - -1. **Fork 仓库** - 如果您没有直接对仓库进行更改的权限,您需要将仓库 fork 到您自己的账户中。 -这将创建一个您可以对其进行更改的仓库副本。 - -2. **创建分支(可选)** - 在 fork 的仓库中创建一个新分支,该分支包含您要提出的更改。 -给分支取一个描述性的名称,以指示更改的内容。 - -3. **进行更改** - 进行您想要的更改,提交并将其推送到 fork 的仓库中。 - -4. **创建合并请求** - 转到原始仓库并转到“合并请求”选项卡。单击“新建合并请求”按钮,并将您的新分支选择为源分支。 -为您的合并请求输入描述性标题和描述,然后单击“创建合并请求”。 - -## 评审合并请求 - -创建合并请求后,将触发评审流程。仓库的维护者将收到合并请求的通知,并可以审查所做的更改。 -他们可以留下评论、请求更改或批准更改。 - -如果维护者请求更改,您需要在分支中进行这些更改,并将更改推送到 fork 的仓库中。 -合并请求将自动使用新更改进行更新。 - -如果维护者批准更改,他们可以将合并请求合并到仓库中。 - -## 关闭合并请求 - -如果您不接受该合并请求,您可以关闭它。 -要关闭合并请求,请转到打开的合并请求并单击“关闭合并请求”按钮。这将关闭合并请求并且不会将其合并。 - -## 使用“Work In Progress”标记 - -在合并请求中使用“Work In Progress”标记可以防止合并请求被意外合并。 -要将合并请求标记为“Work In Progress”,您必须在其标题中添加前缀`WIP:`或`[WIP]`(不区分大小写)。 -标记前缀可以在您的`app.ini`文件中进行配置: - -``` -[repository.pull-request] -WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP] -``` - -列表的第一个值将用于 helpers 程序。 - -## 合并请求模板 - -有关合并请求模板的更多信息请您移步 : [工单与合并请求模板](usage/issue-pull-request-templates.md) diff --git a/docs/content/usage/push.en-us.md b/docs/content/usage/push.en-us.md deleted file mode 100644 index d88dc1a2a9..0000000000 --- a/docs/content/usage/push.en-us.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -date: "2020-07-06T16:00:00+02:00" -title: "Push" -slug: "push" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /en-us/push-to-create - - /en-us/push-options -menu: - sidebar: - parent: "usage" - name: "Push" - sidebar_position: 15 - identifier: "push" ---- - -There are some additional features when pushing commits to Gitea server. - -# Open PR through Push - -When you push commits to a non-default branch for the first time, -you will receive a link you can click on to visit the compare page of your branch compared to your main branch. -From there, it's easy to create a pull request, even if you want to target another branch. - -![Gitea Push Hint](/gitea-push-hint.png) - -# Push Options - -In Gitea `1.13`, support for some [push options](https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt) -were added. - -## Supported Options - -- `repo.private` (true|false) - Change the repository's visibility. - - This is particularly useful when combined with push-to-create. - -- `repo.template` (true|false) - Change whether the repository is a template. - -Example of changing a repository's visibility to public: - -```shell -git push -o repo.private=false -u origin main -``` - -# Push To Create - -Push to create is a feature that allows you to push to a repository that does not exist yet in Gitea. This is useful for automation and for allowing users to create repositories without having to go through the web interface. This feature is disabled by default. - -## Enabling Push To Create - -In the `app.ini` file, set `ENABLE_PUSH_CREATE_USER` to `true` and `ENABLE_PUSH_CREATE_ORG` to `true` if you want to allow users to create repositories in their own user account and in organizations they are a member of respectively. Restart Gitea for the changes to take effect. You can read more about these two options in the [Configuration Cheat Sheet](administration/config-cheat-sheet.md#repository-repository). - -## Using Push To Create - -Assuming you have a git repository in the current directory, you can push to a repository that does not exist yet in Gitea by running the following command: - -```shell -# Add the remote you want to push to -git remote add origin git@{domain}:{username}/{repo name that does not exist yet}.git - -# push to the remote -git push -u origin main -``` - -This assumes you are using an SSH remote, but you can also use HTTPS remotes as well. - -Push-to-create will default to the visibility defined by `DEFAULT_PUSH_CREATE_PRIVATE` in `app.ini`. diff --git a/docs/content/usage/push.zh-cn.md b/docs/content/usage/push.zh-cn.md deleted file mode 100644 index f9fd687cc1..0000000000 --- a/docs/content/usage/push.zh-cn.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "推送" -slug: "push" -sidebar_position: 15 -toc: false -draft: false -aliases: - - /zh-cn/push-to-create - - /zh-cn/push-options -menu: - sidebar: - parent: "usage" - name: "推送" - sidebar_position: 15 - identifier: "push" ---- - -在将提交推送到 Gitea 服务器时,还有一些额外的功能。 - -# 通过推送打开 PR - -当您第一次将提交推送到非默认分支时,您将收到一个链接,您可以单击该链接访问分支与主分支的比较页面。 -从那里,您可以轻松创建一个拉取请求,即使您想要将其目标指向另一个分支。 - -![Gitea 推送提示](/gitea-push-hint.png) - -# 推送选项 - -在 Gitea `1.13` 版本中,添加了对一些 [推送选项](https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt) 的支持。 - -## 支持的选项 - -- `repo.private` (true|false) - 更改仓库的可见性。 - - 这在与 push-to-create 结合使用时特别有用。 - -- `repo.template` (true|false) - 更改仓库是否为模板。 - -将仓库的可见性更改为公开的示例: - -```shell -git push -o repo.private=false -u origin main -``` - -# 推送创建 - -推送创建是一项功能,允许您将提交推送到在 Gitea 中尚不存在的仓库。这对于自动化和允许用户创建仓库而无需通过 Web 界面非常有用。此功能默认处于禁用状态。 - -## 启用推送创建 - -在 `app.ini` 文件中,将 `ENABLE_PUSH_CREATE_USER` 设置为 `true`,如果您希望允许用户在自己的用户帐户和所属的组织中创建仓库,将 `ENABLE_PUSH_CREATE_ORG` 设置为 `true`。重新启动 Gitea 以使更改生效。您可以在 [配置速查表](administration/config-cheat-sheet.md#repository-repository) 中了解有关这两个选项的更多信息。 - -## 使用推送创建 - -假设您在当前目录中有一个 git 仓库,您可以通过运行以下命令将提交推送到在 Gitea 中尚不存在的仓库: - -```shell -# 添加要推送到的远程仓库 -git remote add origin git@{domain}:{username}/{尚不存在的仓库名称}.git - -# 推送到远程仓库 -git push -u origin main -``` - -这假设您使用的是 SSH 远程,但您也可以使用 HTTPS 远程。 - -推送创建将默认使用 `app.ini` 中定义的可见性 `DEFAULT_PUSH_CREATE_PRIVATE`。 diff --git a/docs/content/usage/repo-mirror.en-us.md b/docs/content/usage/repo-mirror.en-us.md deleted file mode 100644 index 9d23159890..0000000000 --- a/docs/content/usage/repo-mirror.en-us.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -date: "2021-05-13T00:00:00-00:00" -title: "Repository Mirror" -slug: "repo-mirror" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /en-us/repo-mirror -menu: - sidebar: - parent: "usage" - name: "Repository Mirror" - sidebar_position: 45 - identifier: "repo-mirror" ---- - -# Repository Mirror - -Repository mirroring allows for the mirroring of repositories to and from external sources. You can use it to mirror branches, tags, and commits between repositories. - -## Use cases - -The following are some possible use cases for repository mirroring: - -- You migrated to Gitea but still need to keep your project in another source. In that case, you can simply set it up to mirror to Gitea (pull) and all the essential history of commits, tags, and branches are available in your Gitea instance. -- You have old projects in another source that you don’t use actively anymore, but don’t want to remove for archiving purposes. In that case, you can create a push mirror so that your active Gitea repository can push its changes to the old location. - -## Pulling from a remote repository - -For an existing remote repository, you can set up pull mirroring as follows: - -1. Select **New Migration** in the **Create...** menu on the top right. -2. Select the remote repository service. -3. Enter a repository URL. -4. If the repository needs authentication fill in your authentication information. -5. Check the box **This repository will be a mirror**. -6. Select **Migrate repository** to save the configuration. - -The repository now gets mirrored periodically from the remote repository. You can force a sync by selecting **Synchronize Now** in the repository settings. - -:exclamation::exclamation: **NOTE:** You can only set up pull mirroring for repos that don't exist yet on your instance. Once the repo is created, you can't convert it into a pull mirror anymore. :exclamation::exclamation: - -## Pushing to a remote repository - -For an existing repository, you can set up push mirroring as follows: - -1. In your repository, go to **Settings** > **Repository**, and then the **Mirror Settings** section. -2. Enter a repository URL. -3. If the repository needs authentication expand the **Authorization** section and fill in your authentication information. Note that the requested **password** can also be your access token. -4. Select **Add Push Mirror** to save the configuration. - -The repository now gets mirrored periodically to the remote repository. You can force a sync by selecting **Synchronize Now**. In case of an error a message displayed to help you resolve it. - -:exclamation::exclamation: **NOTE:** This will force push to the remote repository. This will overwrite any changes in the remote repository! :exclamation::exclamation: - -### Setting up a push mirror from Gitea to GitHub - -To set up a mirror from Gitea to GitHub, you need to follow these steps: - -1. Create a [GitHub personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the *public_repo* box checked. Also check the **workflow** checkbox in case your repo uses GitHub Actions for continuous integration. -2. Create a repository with that name on GitHub. Unlike Gitea, GitHub does not support creating repositories by pushing to the remote. You can also use an existing remote repo if it has the same commit history as your Gitea repo. -3. In the settings of your Gitea repo, fill in the **Git Remote Repository URL**: `https://github.com/<your_github_group>/<your_github_project>.git`. -4. Fill in the **Authorization** fields with your GitHub username and the personal access token as **Password**. -5. (Optional, available on Gitea 1.18+) Select `Sync when new commits are pushed` so that the mirror will be updated as well as soon as there are changes. You can also disable the periodic sync if you like. -6. Select **Add Push Mirror** to save the configuration. - -The repository pushes shortly thereafter. To force a push, select the **Synchronize Now** button. - -### Setting up a push mirror from Gitea to GitLab - -To set up a mirror from Gitea to GitLab, you need to follow these steps: - -1. Create a [GitLab personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with *write_repository* scope. -2. Fill in the **Git Remote Repository URL**: `https://<destination host>/<your_gitlab_group_or_name>/<your_gitlab_project>.git`. -3. Fill in the **Authorization** fields with `oauth2` as **Username** and your GitLab personal access token as **Password**. -4. Select **Add Push Mirror** to save the configuration. - -The repository pushes shortly thereafter. To force a push, select the **Synchronize Now** button. - -### Setting up a push mirror from Gitea to Bitbucket - -To set up a mirror from Gitea to Bitbucket, you need to follow these steps: - -1. Create a [Bitbucket app password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/) with the *Repository Write* box checked. -2. Fill in the **Git Remote Repository URL**: `https://bitbucket.org/<your_bitbucket_group_or_name>/<your_bitbucket_project>.git`. -3. Fill in the **Authorization** fields with your Bitbucket username and the app password as **Password**. -4. Select **Add Push Mirror** to save the configuration. - -The repository pushes shortly thereafter. To force a push, select the **Synchronize Now** button. - -### Mirror an existing ssh repository - -Currently Gitea supports no ssh push mirrors. You can work around this by adding a `post-receive` hook to your Gitea repository that pushes manually. - -1. Make sure the user running Gitea has access to the git repo you are trying to mirror to from shell. -2. On the web interface at the repository settings > git hooks add a post-receive hook for the mirror. I.e. - -``` -#!/usr/bin/env bash -git push --mirror --quiet git@github.com:username/repository.git &>/dev/null & -echo "GitHub mirror initiated .." -``` diff --git a/docs/content/usage/repo-mirror.zh-cn.md b/docs/content/usage/repo-mirror.zh-cn.md deleted file mode 100644 index b74a1b62ad..0000000000 --- a/docs/content/usage/repo-mirror.zh-cn.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "仓库镜像" -slug: "repo-mirror" -sidebar_position: 45 -toc: false -draft: false -aliases: - - /zh-cn/repo-mirror -menu: - sidebar: - parent: "usage" - name: "仓库镜像" - sidebar_position: 45 - identifier: "repo-mirror" ---- - -# 仓库镜像 - -仓库镜像允许将仓库与外部源之间进行镜像。您可以使用它在仓库之间镜像分支、标签和提交。 - -## 使用场景 - -以下是一些仓库镜像的可能使用场景: - -- 您迁移到了 Gitea,但仍需要在其他源中保留您的项目。在这种情况下,您可以简单地设置它以进行镜像到 Gitea(拉取),这样您的 Gitea 实例中就可以获取到所有必要的提交历史、标签和分支。 -- 您在其他源中有一些旧项目,您不再主动使用,但出于归档目的不想删除。在这种情况下,您可以创建一个推送镜像,以便您的活跃的 Gitea 仓库可以将其更改推送到旧位置。 - -## 从远程仓库拉取 - -对于现有的远程仓库,您可以按照以下步骤设置拉取镜像: - -1. 在右上角的“创建...”菜单中选择“迁移外部仓库”。 -2. 选择远程仓库服务。 -3. 输入仓库的 URL。 -4. 如果仓库需要身份验证,请填写您的身份验证信息。 -5. 选中“该仓库将是一个镜像”复选框。 -6. 选择“迁移仓库”以保存配置。 - -现在,该仓库会定期从远程仓库进行镜像。您可以通过在仓库设置中选择“立即同步”来强制进行同步。 - -:exclamation::exclamation: **注意:**您只能为尚不存在于您的实例上的仓库设置拉取镜像。一旦仓库创建成功,您就无法再将其转换为拉取镜像。:exclamation::exclamation: - -## 推送到远程仓库 - -对于现有的仓库,您可以按照以下步骤设置推送镜像: - -1. 在仓库中,转到**设置** > **仓库**,然后进入**镜像设置**部分。 -2. 输入一个仓库的 URL。 -3. 如果仓库需要身份验证,请展开**授权**部分并填写您的身份验证信息。请注意,所请求的**密码**也可以是您的访问令牌。 -4. 选择**添加推送镜像**以保存配置。 - -该仓库现在会定期镜像到远程仓库。您可以通过选择**立即同步**来强制同步。如果出现错误,会显示一条消息帮助您解决问题。 - -:exclamation::exclamation: **注意:** 这将强制推送到远程仓库。这将覆盖远程仓库中的任何更改! :exclamation::exclamation: - -### 从 Gitea 向 GitHub 设置推送镜像 - -要从 Gitea 设置镜像到 GitHub,您需要按照以下步骤进行操作: - -1. 创建一个具有选中 *public_repo* 选项的 [GitHub 个人访问令牌](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)。 -2. 在 GitHub 上创建一个同名的仓库。与 Gitea 不同,GitHub 不支持通过推送到远程来创建仓库。如果您的现有远程仓库与您的 Gitea 仓库具有相同的提交历史,您也可以使用现有的远程仓库。 -3. 在您的 Gitea 仓库设置中,填写**Git 远程仓库 URL**:`https://github.com/<your_github_group>/<your_github_project>.git`。 -4. 使用您的 GitHub 用户名填写**授权**字段,并将个人访问令牌作为**密码**。 -5. (可选,适用于 Gitea 1.18+)选择`当推送新提交时同步`,这样一旦有更改,镜像将会及时更新。如果您愿意,您还可以禁用定期同步。 -6. 选择**添加推送镜像**以保存配置。 - -仓库会很快进行推送。要强制推送,请选择**立即同步**按钮。 - -### 从 Gitea 向 GitLab 设置推送镜像 - -要从 Gitea 设置镜像到 GitLab,您需要按照以下步骤进行操作: - -1. 创建具有 *write_repository* 作用域的 [GitLab 个人访问令牌](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)。 -2. 填写**Git 远程仓库 URL**:`https://<destination host>/<your_gitlab_group_or_name>/<your_gitlab_project>.git`。 -3. 在**授权**字段中填写 `oauth2` 作为**用户名**,并将您的 GitLab 个人访问令牌作为**密码**。 -4. 选择**添加推送镜像**以保存配置。 - -仓库会很快进行推送。要强制推送,请选择**立即同步**按钮。 - -### 从 Gitea 向 Bitbucket 设置推送镜像 - -要从 Gitea 设置镜像到 Bitbucket,您需要按照以下步骤进行操作: - -1. 创建一个具有选中 *Repository Write* 选项的 [Bitbucket 应用密码](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)。 -2. 填写**Git 远程仓库 URL**:`https://bitbucket.org/<your_bitbucket_group_or_name>/<your_bitbucket_project>.git`。 -3. 使用您的 Bitbucket 用户名填写**授权**字段,并将应用密码作为**密码**。 -4. 选择**添加推送镜像**以保存配置。 - -仓库会很快进行推送。要强制推送,请选择**立即同步**按钮。 - -### 镜像现有的 ssh 仓库 - -当前,Gitea 不支持从 ssh 仓库进行镜像。如果您想要镜像一个 ssh 仓库,您需要将其转换为 http 仓库。您可以使用以下命令将现有的 ssh 仓库转换为 http 仓库: - -1. 确保运行 gitea 的用户有权限访问您试图从 shell 镜像到的 git 仓库。 -2. 在 Web 界面的版本库设置 > git 钩子中为镜像添加一个接收后钩子。 - -``` -#!/usr/bin/env bash -git push --mirror --quiet git@github.com:username/repository.git &>/dev/null & -echo "GitHub mirror initiated .." -``` diff --git a/docs/content/usage/template-repositories.en-us.md b/docs/content/usage/template-repositories.en-us.md deleted file mode 100644 index e57ed85cc9..0000000000 --- a/docs/content/usage/template-repositories.en-us.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -date: "2019-11-28:00:00+02:00" -title: "Template Repositories" -slug: "template-repositories" -sidebar_position: 14 -toc: false -draft: false -aliases: - - /en-us/template-repositories -menu: - sidebar: - parent: "usage" - name: "Template Repositories" - sidebar_position: 14 - identifier: "template-repositories" ---- - -# Template Repositories - -Gitea (starting with version `1.11.0`) supports creating template repositories -which can be used to generate repositories based on the template, complete with -variable expansion of certain pre-defined variables. - -All files in the template repository are included in a generated repository from the -template except for the `.gitea/template` file. The `.gitea/template` file tells -Gitea which files are subject to the variable expansion when creating a -repository from the template. - -Gitea uses [gobwas/glob](https://github.com/gobwas/glob) for its glob syntax. It closely resembles a traditional `.gitignore`, however there may be slight differences. - -## Example `.gitea/template` file - -All paths are relative to the base of the repository - -```gitignore -# Expand all .go files, anywhere in the repository -**.go - -# All text files in the text directory -text/*.txt - -# A specific file -a/b/c/d.json - -# Batch files in both upper or lower case can be matched -**.[bB][aA][tT] -``` - -## Variable Expansion - -In any file matched by the above globs, certain variables will be expanded. - -Matching filenames and paths can also be expanded, and are conservatively sanitized to support cross-platform filesystems. - -All variables must be of the form `$VAR` or `${VAR}`. To escape an expansion, use a double `$$`, such as `$$VAR` or `$${VAR}` - -| Variable | Expands To | Transformable | -| -------------------- | --------------------------------------------------- | ------------- | -| REPO_NAME | The name of the generated repository | ✓ | -| TEMPLATE_NAME | The name of the template repository | ✓ | -| REPO_DESCRIPTION | The description of the generated repository | ✘ | -| TEMPLATE_DESCRIPTION | The description of the template repository | ✘ | -| REPO_OWNER | The owner of the generated repository | ✓ | -| TEMPLATE_OWNER | The owner of the template repository | ✓ | -| REPO_LINK | The URL to the generated repository | ✘ | -| TEMPLATE_LINK | The URL to the template repository | ✘ | -| REPO_HTTPS_URL | The HTTP(S) clone link for the generated repository | ✘ | -| TEMPLATE_HTTPS_URL | The HTTP(S) clone link for the template repository | ✘ | -| REPO_SSH_URL | The SSH clone link for the generated repository | ✘ | -| TEMPLATE_SSH_URL | The SSH clone link for the template repository | ✘ | - -## Transformers :robot: - -Gitea `1.12.0` adds a few transformers to some of the applicable variables above. - -For example, to get `REPO_NAME` in `PASCAL`-case, your template would use `${REPO_NAME_PASCAL}` - -Feeding `go-sdk` to the available transformers yields... - -| Transformer | Effect | -| ----------- | ------ | -| SNAKE | go_sdk | -| KEBAB | go-sdk | -| CAMEL | goSdk | -| PASCAL | GoSdk | -| LOWER | go-sdk | -| UPPER | GO-SDK | -| TITLE | Go-Sdk | diff --git a/docs/content/usage/template-repositories.zh-cn.md b/docs/content/usage/template-repositories.zh-cn.md deleted file mode 100644 index 885b2f4ec8..0000000000 --- a/docs/content/usage/template-repositories.zh-cn.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -date: "2023-05-23T09:00:00+08:00" -title: "模板仓库" -slug: "template-repositories" -sidebar_position: 14 -toc: false -draft: false -aliases: - - /zh-cn/template-repositories -menu: - sidebar: - parent: "usage" - name: "模板仓库" - sidebar_position: 14 - identifier: "template-repositories" ---- - -# 模板仓库 - -Gitea `1.11.0` 及以上版本引入了模板仓库,并且其中一个实现的功能是自动展开模板文件中的特定变量。 - -要告诉 Gitea 哪些文件需要展开,您必须在模板仓库的 `.gitea` 目录中包含一个 `template` 文件。 - -Gitea 使用 [gobwas/glob](https://github.com/gobwas/glob) 作为其 glob 语法。它与传统的 `.gitignore` 语法非常相似,但可能存在细微的差异。 - -## `.gitea/template` 文件示例 - -所有路径都是相对于仓库的根目录 - -```gitignore -# 仓库中的所有 .go 文件 -**.go - -# text 目录中的所有文本文件 -text/*.txt - -# 特定文件 -a/b/c/d.json - -# 匹配批处理文件的大小写变体 -**.[bB][aA][tT] -``` - -**注意:** 当从模板生成仓库时,`.gitea` 目录中的 `template` 文件将被删除。 - -## 参数展开 - -在与上述通配符匹配的任何文件中,将会扩展某些变量。 - -文件名和路径的匹配也可以被扩展,并且会经过谨慎的清理处理,以支持跨平台的文件系统。 - -所有变量都必须采用`$VAR`或`${VAR}`的形式。要转义扩展,使用双重`$$`,例如`$$VAR`或`$${VAR}`。 - -| 变量 | 扩展为 | 可转换 | -| -------------------- | --------------------------------------------------- | ------------- | -| REPO_NAME | 生成的仓库名称 | ✓ | -| TEMPLATE_NAME | 模板仓库名称 | ✓ | -| REPO_DESCRIPTION | 生成的仓库描述 | ✘ | -| TEMPLATE_DESCRIPTION | 模板仓库描述 | ✘ | -| REPO_OWNER | 生成的仓库所有者 | ✓ | -| TEMPLATE_OWNER | 模板仓库所有者 | ✓ | -| REPO_LINK | 生成的仓库链接 | ✘ | -| TEMPLATE_LINK | 模板仓库链接 | ✘ | -| REPO_HTTPS_URL | 生成的仓库的 HTTP(S) 克隆链接 | ✘ | -| TEMPLATE_HTTPS_URL | 模板仓库的 HTTP(S) 克隆链接 | ✘ | -| REPO_SSH_URL | 生成的仓库的 SSH 克隆链接 | ✘ | -| TEMPLATE_SSH_URL | 模板仓库的 SSH 克隆链接 | ✘ | - -## 转换器 :robot: - -Gitea `1.12.0` 添加了一些转换器以应用于上述适用的变量。 - -例如,要以 `PASCAL`-case 获取 `REPO_NAME`,你的模板应使用 `${REPO_NAME_PASCAL}` - -将 `go-sdk` 传递给可用的转换器的效果如下... - -| 转换器 | 效果 | -| ----------- | ------------ | -| SNAKE | go_sdk | -| KEBAB | go-sdk | -| CAMEL | goSdk | -| PASCAL | GoSdk | -| LOWER | go-sdk | -| UPPER | GO-SDK | -| TITLE | Go-Sdk | diff --git a/docs/content/usage/webhooks.en-us.md b/docs/content/usage/webhooks.en-us.md deleted file mode 100644 index 684911f83a..0000000000 --- a/docs/content/usage/webhooks.en-us.md +++ /dev/null @@ -1,196 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Webhooks" -slug: "webhooks" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /en-us/webhooks -menu: - sidebar: - parent: "usage" - name: "Webhooks" - sidebar_position: 30 - identifier: "webhooks" ---- - -# Webhooks - -Gitea supports webhooks for repository events. This can be configured in the settings -page `/:username/:reponame/settings/hooks` by a repository admin. Webhooks can also be configured on a per-organization and whole system basis. -All event pushes are POST requests. The methods currently supported are: - -- Gitea (can also be a GET request) -- Gogs -- Slack -- Discord -- Dingtalk -- Telegram -- Microsoft Teams -- Feishu -- Wechatwork -- Packagist - -### Event information - -**WARNING**: The `secret` field in the payload is deprecated as of Gitea 1.13.0 and will be removed in 1.14.0: https://github.com/go-gitea/gitea/issues/11755 - -The following is an example of event information that will be sent by Gitea to -a Payload URL: - -``` -X-GitHub-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-GitHub-Event: push -X-Gogs-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-Gogs-Event: push -X-Gitea-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-Gitea-Event: push -``` - -```json -{ - "secret": "3gEsCfjlV2ugRwgpU#w1*WaW*wa4NXgGmpCfkbG3", - "ref": "refs/heads/develop", - "before": "28e1879d029cb852e4844d9c718537df08844e03", - "after": "bffeb74224043ba2feb48d137756c8a9331c449a", - "compare_url": "http://localhost:3000/gitea/webhooks/compare/28e1879d029cb852e4844d9c718537df08844e03...bffeb74224043ba2feb48d137756c8a9331c449a", - "commits": [ - { - "id": "bffeb74224043ba2feb48d137756c8a9331c449a", - "message": "Webhooks Yay!", - "url": "http://localhost:3000/gitea/webhooks/commit/bffeb74224043ba2feb48d137756c8a9331c449a", - "author": { - "name": "Gitea", - "email": "someone@gitea.io", - "username": "gitea" - }, - "committer": { - "name": "Gitea", - "email": "someone@gitea.io", - "username": "gitea" - }, - "timestamp": "2017-03-13T13:52:11-04:00" - } - ], - "repository": { - "id": 140, - "owner": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - }, - "name": "webhooks", - "full_name": "gitea/webhooks", - "description": "", - "private": false, - "fork": false, - "html_url": "http://localhost:3000/gitea/webhooks", - "ssh_url": "ssh://gitea@localhost:2222/gitea/webhooks.git", - "clone_url": "http://localhost:3000/gitea/webhooks.git", - "website": "", - "stars_count": 0, - "forks_count": 1, - "watchers_count": 1, - "open_issues_count": 7, - "default_branch": "master", - "created_at": "2017-02-26T04:29:06-05:00", - "updated_at": "2017-03-13T13:51:58-04:00" - }, - "pusher": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - }, - "sender": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - } -} -``` - -### Example - -This is an example of how to use webhooks to run a php script upon push requests to the repository. -In your repository Settings, under Webhooks, Setup a Gitea webhook as follows: - -- Target URL: http://mydomain.com/webhook.php -- HTTP Method: POST -- POST Content Type: application/json -- Secret: 123 -- Trigger On: Push Events -- Active: Checked - -Now on your server create the php file webhook.php - -``` -<?php - -$secret_key = '123'; - -// check for POST request -if ($_SERVER['REQUEST_METHOD'] != 'POST') { - error_log('FAILED - not POST - '. $_SERVER['REQUEST_METHOD']); - exit(); -} - -// get content type -$content_type = isset($_SERVER['CONTENT_TYPE']) ? strtolower(trim($_SERVER['CONTENT_TYPE'])) : ''; - -if ($content_type != 'application/json') { - error_log('FAILED - not application/json - '. $content_type); - exit(); -} - -// get payload -$payload = trim(file_get_contents("php://input")); - -if (empty($payload)) { - error_log('FAILED - no payload'); - exit(); -} - -// get header signature -$header_signature = isset($_SERVER['HTTP_X_GITEA_SIGNATURE']) ? $_SERVER['HTTP_X_GITEA_SIGNATURE'] : ''; - -if (empty($header_signature)) { - error_log('FAILED - header signature missing'); - exit(); -} - -// calculate payload signature -$payload_signature = hash_hmac('sha256', $payload, $secret_key, false); - -// check payload signature against header signature -if ($header_signature !== $payload_signature) { - error_log('FAILED - payload signature'); - exit(); -} - -// convert json to array -$decoded = json_decode($payload, true); - -// check for json decode errors -if (json_last_error() !== JSON_ERROR_NONE) { - error_log('FAILED - json decode - '. json_last_error()); - exit(); -} - -// success, do something -``` - -There is a Test Delivery button in the webhook settings that allows to test the configuration as well as a list of the most Recent Deliveries. - -### Authorization header - -**With 1.19**, Gitea hooks can be configured to send an [authorization header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) to the webhook target. diff --git a/docs/content/usage/webhooks.zh-cn.md b/docs/content/usage/webhooks.zh-cn.md deleted file mode 100644 index dfc709940e..0000000000 --- a/docs/content/usage/webhooks.zh-cn.md +++ /dev/null @@ -1,194 +0,0 @@ ---- -date: "2016-12-01T16:00:00+02:00" -title: "Webhooks" -slug: "webhooks" -sidebar_position: 30 -toc: false -draft: false -aliases: - - /zh-cn/webhooks -menu: - sidebar: - parent: "usage" - name: "Webhooks" - sidebar_position: 30 - identifier: "webhooks" ---- - -# Webhooks - -Gitea支持用于仓库事件的Webhooks。这可以在仓库管理员在设置页面 `/:username/:reponame/settings/hooks` 中进行配置。Webhooks还可以基于组织和整个系统进行配置。 -所有事件推送都是 POST 请求。目前支持: - -- Gitea (也可以是 GET 请求) -- Gogs -- Slack -- Discord -- Dingtalk(钉钉) -- Telegram -- Microsoft Teams -- Feishu -- Wechatwork(企业微信) -- Packagist - -### 事件信息 - -**警告**:自 Gitea 1.13.0 版起,payload 中的 `secret` 字段已被弃用,并将在 1.14.0 版中移除:https://github.com/go-gitea/gitea/issues/11755 - -以下是 Gitea 将发送给 payload URL的事件信息示例: - -``` -X-GitHub-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-GitHub-Event: push -X-Gogs-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-Gogs-Event: push -X-Gitea-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473 -X-Gitea-Event: push -``` - -```json -{ - "secret": "3gEsCfjlV2ugRwgpU#w1*WaW*wa4NXgGmpCfkbG3", - "ref": "refs/heads/develop", - "before": "28e1879d029cb852e4844d9c718537df08844e03", - "after": "bffeb74224043ba2feb48d137756c8a9331c449a", - "compare_url": "http://localhost:3000/gitea/webhooks/compare/28e1879d029cb852e4844d9c718537df08844e03...bffeb74224043ba2feb48d137756c8a9331c449a", - "commits": [ - { - "id": "bffeb74224043ba2feb48d137756c8a9331c449a", - "message": "Webhooks Yay!", - "url": "http://localhost:3000/gitea/webhooks/commit/bffeb74224043ba2feb48d137756c8a9331c449a", - "author": { - "name": "Gitea", - "email": "someone@gitea.io", - "username": "gitea" - }, - "committer": { - "name": "Gitea", - "email": "someone@gitea.io", - "username": "gitea" - }, - "timestamp": "2017-03-13T13:52:11-04:00" - } - ], - "repository": { - "id": 140, - "owner": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - }, - "name": "webhooks", - "full_name": "gitea/webhooks", - "description": "", - "private": false, - "fork": false, - "html_url": "http://localhost:3000/gitea/webhooks", - "ssh_url": "ssh://gitea@localhost:2222/gitea/webhooks.git", - "clone_url": "http://localhost:3000/gitea/webhooks.git", - "website": "", - "stars_count": 0, - "forks_count": 1, - "watchers_count": 1, - "open_issues_count": 7, - "default_branch": "master", - "created_at": "2017-02-26T04:29:06-05:00", - "updated_at": "2017-03-13T13:51:58-04:00" - }, - "pusher": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - }, - "sender": { - "id": 1, - "login": "gitea", - "full_name": "Gitea", - "email": "someone@gitea.io", - "avatar_url": "https://localhost:3000/avatars/1", - "username": "gitea" - } -} -``` - -### 示例 - -这是一个示例,演示如何使用 Webhooks 在推送请求到达仓库时运行一个 php 脚本。 -在你的仓库设置中,在 Webhooks 下,设置一个如下的 Gitea webhook: - -- 目标 URL:http://mydomain.com/webhook.php -- HTTP 方法:POST -- POST Content Type:application/json -- Secret:123 -- 触发条件:推送事件 -- 激活:勾选 - -现在在你的服务器上创建 php 文件 webhook.php。 - -``` -<?php - -$secret_key = '123'; - -// check for POST request -if ($_SERVER['REQUEST_METHOD'] != 'POST') { - error_log('FAILED - not POST - '. $_SERVER['REQUEST_METHOD']); - exit(); -} - -// get content type -$content_type = isset($_SERVER['CONTENT_TYPE']) ? strtolower(trim($_SERVER['CONTENT_TYPE'])) : ''; - -if ($content_type != 'application/json') { - error_log('FAILED - not application/json - '. $content_type); - exit(); -} - -// get payload -$payload = trim(file_get_contents("php://input")); - -if (empty($payload)) { - error_log('FAILED - no payload'); - exit(); -} - -// get header signature -$header_signature = isset($_SERVER['HTTP_X_GITEA_SIGNATURE']) ? $_SERVER['HTTP_X_GITEA_SIGNATURE'] : ''; - -if (empty($header_signature)) { - error_log('FAILED - header signature missing'); - exit(); -} - -// calculate payload signature -$payload_signature = hash_hmac('sha256', $payload, $secret_key, false); - -// check payload signature against header signature -if ($header_signature !== $payload_signature) { - error_log('FAILED - payload signature'); - exit(); -} - -// convert json to array -$decoded = json_decode($payload, true); - -// check for json decode errors -if (json_last_error() !== JSON_ERROR_NONE) { - error_log('FAILED - json decode - '. json_last_error()); - exit(); -} - -// success, do something -``` - -在 Webhook 设置中有一个“测试推送(Test Delivery)”按钮,可以测试配置,还有一个“最近推送记录(Recent Deliveries)”的列表。 - -### 授权头(Authorization header) - -**从1.19版本开始**,Gitea 的 Webhook 可以配置为向 Webhook 目标发送一个 [授权头(authorization header)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization)。 |