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:
appleboy
2025-04-05 00:57:20 +00:00
committed by Bo-Yi Wu (吳柏毅)
parent dbfa0ba454
commit ac801c4790
6 changed files with 238 additions and 256 deletions
@@ -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`
![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.
註冊後,一個名為 `.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:
![view runner](/images/usage/actions/view-runner.png)
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`
![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.
接下來的步驟可能相當複雜。
你需要學習 [工作流程語法](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 標籤中看到一個新任務。
![view job](/images/usage/actions/view-job.png)
Great job! You have successfully started working with Actions.
幹得好!你已經成功開始使用 Actions