mirror of
https://gitea.com/gitea/docs.git
synced 2026-09-20 04:58:52 +00:00
docs: update zh-tw (#197)
Signed-off-by: appleboy <[email protected]> Reviewed-on: https://gitea.com/gitea/docs/pulls/197 Co-authored-by: appleboy <[email protected]> Co-committed-by: appleboy <[email protected]>
This commit is contained in:
@@ -4,39 +4,39 @@ slug: "overview"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Overview
|
||||
# 概述
|
||||
|
||||
Starting with Gitea **1.19**, Gitea Actions are available as a built-in CI/CD solution.
|
||||
從 Gitea **1.19** 開始,Gitea Actions 作為內建的 CI/CD 解決方案可用。
|
||||
|
||||
## 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:
|
||||
它類似並兼容於 [GitHub Actions](https://github.com/features/actions),其名稱也受其啟發。
|
||||
為了避免混淆,我們在這裡澄清拼寫:
|
||||
|
||||
- "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".
|
||||
- "Gitea Actions"(帶有 "s",兩個詞首字母大寫)是 Gitea 功能的名稱。
|
||||
- "GitHub Actions" 是 GitHub 功能的名稱。
|
||||
- "Actions" 可能指上述任何一個,取決於上下文。在本文檔中,它指的是 "Gitea Actions"。
|
||||
- "action" 或 "actions" 指的是一些腳本/插件,如 "actions/checkout@v4" 或 "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).
|
||||
就像其他 CI/CD 解決方案一樣,Gitea 不會自己運行作業,而是將作業委派給 runners。
|
||||
Gitea Actions 的 runner 稱為 [act runner](https://gitea.com/gitea/act_runner),它是一個獨立的程序,也是用 Go 編寫的。
|
||||
它基於 [nektos/act](http://github.com/nektos/act) 的 [fork](https://gitea.com/gitea/act)。
|
||||
|
||||
Because the runner is deployed independently, there could be potential security issues.
|
||||
To avoid them, please follow two simple rules:
|
||||
由於 runner 是獨立部署的,可能會有潛在的安全問題。
|
||||
為了避免這些問題,請遵循兩個簡單的規則:
|
||||
|
||||
- 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.
|
||||
- 不要為你不信任的倉庫、組織或實例使用你不信任的 runner。
|
||||
- 不要為你不信任的倉庫、組織或實例提供 runner。
|
||||
|
||||
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.
|
||||
對於內部使用的 Gitea 實例,如企業或個人使用的實例,這兩個規則都不是問題,它們自然如此。
|
||||
然而,對於公共 Gitea 實例,如 [gitea.com](https://gitea.com),在添加或使用 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).
|
||||
Gitea Actions 仍在開發中,因此可能會有一些錯誤和缺失的功能。
|
||||
在穩定之前(v1.20 或更高版本),可能會進行重大更改。
|
||||
|
||||
If the situation changes, we will update it here.
|
||||
So please refer to the content here when you find outdated articles elsewhere.
|
||||
如果情況發生變化,我們會在這裡更新。
|
||||
因此,當你在其他地方找到過時的文章時,請參考這裡的內容。
|
||||
|
||||
+55
-55
@@ -4,92 +4,92 @@ slug: "quickstart"
|
||||
sidebar_position: 10
|
||||
---
|
||||
|
||||
# Quick Start
|
||||
# 快速開始
|
||||
|
||||
This page will guide you through the process of using Gitea Actions.
|
||||
本頁將引導你使用 Gitea Actions 的過程。
|
||||
|
||||
## Set up Gitea
|
||||
## 設置 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.
|
||||
首先,你需要一個 Gitea 實例。
|
||||
你可以按照 [文檔](installation/from-package.md) 設置一個新實例或升級現有實例。
|
||||
無論你如何安裝或運行 Gitea,只要其版本是 1.19.0 或更高版本即可。
|
||||
|
||||
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:
|
||||
從 1.21.0 開始,Actions 默認啟用。如果你使用的是 1.21.0 之前的版本,你需要在配置文件中添加以下內容以啟用它:
|
||||
|
||||
```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).
|
||||
如果你想了解更多或在配置過程中遇到任何問題,請參考 [配置備忘單](../../administration/config-cheat-sheet.md#actions-actions)。
|
||||
|
||||
### Set up runner
|
||||
### 設置 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.
|
||||
Gitea Actions 需要 [act runner](https://gitea.com/gitea/act_runner) 來運行作業。
|
||||
為了避免消耗過多資源並影響 Gitea 實例,建議在與 Gitea 實例不同的機器上啟動 runners。
|
||||
|
||||
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.
|
||||
你可以使用 [預構建的二進位文件](http://dl.gitea.com/act_runner) 或 [docker 映像](https://hub.docker.com/r/gitea/act_runner/tags) 設置 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.
|
||||
在進一步操作之前,我們建議使用預構建的二進位文件作為命令行運行它,以確保它適用於你的環境,特別是如果你在本地主機上運行 runner。
|
||||
如果出現問題,這樣也更容易調試。
|
||||
|
||||
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.
|
||||
runner 可以在隔離的 Docker 容器中運行作業,因此你需要確保已安裝 Docker 並且 Docker 守護進程正在運行。
|
||||
雖然這不是絕對必要的,因為 runner 也可以直接在主機上運行作業,這取決於你如何配置它。
|
||||
然而,建議使用 Docker 來運行作業,因為這樣更安全且更易於管理。
|
||||
|
||||
Before running a runner, you should first register it to your Gitea instance using the following command:
|
||||
在運行 runner 之前,你應該首先使用以下命令將其註冊到你的 Gitea 實例:
|
||||
|
||||
```bash
|
||||
./act_runner register --no-interactive --instance <instance> --token <token>
|
||||
```
|
||||
|
||||
There are two arguments required, `instance` and `token`.
|
||||
需要兩個參數,`instance` 和 `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.
|
||||
`instance` 指的是你的 Gitea 實例的地址,如 `http://192.168.8.8:3000` 或 `https://gitea.com`。
|
||||
runner 和作業容器(由 runner 啟動以執行作業)將連接到此地址。
|
||||
這意味著它可能與你的 Gitea 實例的 `ROOT_URL` 不同,後者是為網頁訪問配置的。
|
||||
使用回環地址如 `127.0.0.1` 或 `localhost` 總是個壞主意。
|
||||
如果你不確定使用哪個地址,通常 LAN 地址是正確的選擇。
|
||||
|
||||
`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':
|
||||
`token` 用於身份驗證和識別,如 `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`。
|
||||
每個令牌可以用來創建多個 runners,直到使用重置鏈接替換為新令牌。
|
||||
你可以從以下位置獲取不同級別的令牌來創建相應級別的 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`.
|
||||
- 實例級別:管理員設置頁面,如 `<your_gitea.com>/admin/actions/runners`。
|
||||
- 組織級別:組織設置頁面,如 `<your_gitea.com>/<org>/settings/actions/runners`。
|
||||
- 倉庫級別:倉庫設置頁面,如 `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`。
|
||||
|
||||

|
||||
|
||||
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.
|
||||
註冊後,一個名為 `.runner` 的新文件將出現在當前目錄中。
|
||||
該文件存儲註冊信息。
|
||||
請不要手動編輯它。
|
||||
如果該文件丟失或損壞,你可以簡單地刪除它並重新註冊。
|
||||
|
||||
Finally, it's time to start the runner:
|
||||
最後,是時候啟動 runner 了:
|
||||
|
||||
```bash
|
||||
./act_runner daemon
|
||||
```
|
||||
|
||||
And you can see the new runner in the management page:
|
||||
你可以在管理頁面中看到新的 runner:
|
||||
|
||||

|
||||
|
||||
You can find more information by visiting [Act runner](usage/actions/act-runner.md).
|
||||
你可以訪問 [Act runner](usage/actions/act-runner.md) 獲取更多信息。
|
||||
|
||||
### Use Actions
|
||||
### 使用 Actions
|
||||
|
||||
Even if Actions is enabled for the Gitea instance, repositories still disable Actions by default.
|
||||
即使 Gitea 實例啟用了 Actions,倉庫仍然默認禁用 Actions。
|
||||
|
||||
To enable it, go to the settings page of your repository like `your_gitea.com/<owner>/repo/settings` and enable `Enable Repository Actions`.
|
||||
要啟用它,請轉到倉庫的設置頁面,如 `your_gitea.com/<owner>/repo/settings` 並啟用 `Enable Repository Actions`。
|
||||
|
||||

|
||||
|
||||
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.
|
||||
接下來的步驟可能相當複雜。
|
||||
你需要學習 [工作流程語法](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) 並編寫你想要的工作流程文件。
|
||||
|
||||
However, we can just start from a simple demo:
|
||||
然而,我們可以從一個簡單的示例開始:
|
||||
|
||||
```yaml
|
||||
name: Gitea Actions Demo
|
||||
@@ -115,24 +115,24 @@ jobs:
|
||||
|
||||
:::warning
|
||||
|
||||
Certain actions may not function correctly within SHA256 repositories or when Gitea runs on subpath. This includes [actions/checkout](https://github.com/actions/checkout/issues/1843).
|
||||
某些 actions 可能無法在 SHA256 倉庫中正常運行,或者當 Gitea 在子路徑上運行時。這包括 [actions/checkout](https://github.com/actions/checkout/issues/1843)。
|
||||
|
||||
:::
|
||||
|
||||
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.
|
||||
你可以將其作為擴展名為 `.yaml` 的文件上傳到倉庫的 `.gitea/workflows/` 目錄中,例如 `.gitea/workflows/demo.yaml`。
|
||||
你可能會注意到這與 [GitHub Actions 快速入門](https://docs.github.com/en/actions/quickstart) 非常相似。
|
||||
那是因為 Gitea Actions 設計上盡可能與 GitHub Actions 兼容。
|
||||
|
||||
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#mysqlmariadb) for more information.
|
||||
請注意,示例文件中包含一些表情符號。
|
||||
請確保你的數據庫支持它們,特別是當使用 MySQL 時。
|
||||
如果字符集不是 `utf8mb4`,將會出現錯誤,如 `Error 1366 (HY000): Incorrect string value: '\\xF0\\x9F\\x8E\\x89 T...' for column 'name' at row 1`。
|
||||
有關更多信息,請參見 [數據庫準備](../../installation/database-preparation.md#mysqlmariadb)。
|
||||
|
||||
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.
|
||||
行 `on: [push]` 表示當你向此倉庫推送提交時,工作流程將被觸發。
|
||||
然而,當你上傳 YAML 文件時,它也會推送一個提交,因此你應該在 Actions 標籤中看到一個新任務。
|
||||
|
||||

|
||||
|
||||
Great job! You have successfully started working with Actions.
|
||||
幹得好!你已經成功開始使用 Actions。
|
||||
|
||||
@@ -6,30 +6,26 @@ sidebar_position: 50
|
||||
|
||||
# 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.
|
||||
Secrets 允許你在用戶、組織或倉庫中存儲敏感信息。
|
||||
Secrets 在 Gitea 1.19+ 可用,並且在 1.20+ 啟用 ACTIONS 時可見。
|
||||
|
||||
# Naming your secrets
|
||||
## 命名你的 secrets
|
||||
|
||||
The following rules apply to secret names:
|
||||
以下規則適用於 secret 名稱:
|
||||
|
||||
- Secret names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
|
||||
- Secret 名稱只能包含字母數字字符 (`[a-z]`, `[A-Z]`, `[0-9]`) 或下劃線 (`_`)。不允許使用空格。
|
||||
- Secret 名稱不得以 `GITHUB_` 和 `GITEA_` 前綴開頭。
|
||||
- Secret 名稱不得以數字開頭。
|
||||
- Secret 名稱不區分大小寫。
|
||||
- Secret 名稱在創建它們的級別上必須是唯一的。
|
||||
|
||||
- Secret names must not start with the `GITHUB_` and `GITEA_` prefix.
|
||||
例如,在倉庫級別創建的 secret 必須在該倉庫中具有唯一名稱,而在組織級別創建的 secret 必須在該級別上具有唯一名稱。
|
||||
|
||||
- Secret names must not start with a number.
|
||||
### 使用 secrets
|
||||
|
||||
- Secret names are not case-sensitive.
|
||||
創建配置變數後,它們將自動填充到 `secrets` 上下文中。
|
||||
可以通過表達式 `${{ secrets.SECRET_NAME }}` 在工作流程中訪問它們。
|
||||
|
||||
- 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.
|
||||
|
||||
### Using secrets
|
||||
|
||||
After creating configuration variables, they will be automatically filled in the `secrets` context.
|
||||
They can be accessed through expressions like `${{ secrets.SECRET_NAME }}` in the workflow.
|
||||
|
||||
### Precedence
|
||||
|
||||
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.
|
||||
如果在多個級別存在同名 secret,則最低級別的 secret 優先。例如,如果組織級別的 secret 與倉庫級別的 secret 同名,則倉庫級別的 secret 優先。
|
||||
|
||||
Reference in New Issue
Block a user