Skip to content

Commit cff4e37

Browse files
authored
Add Chinese documentations for Actions (#24902)
1 parent 69eb92a commit cff4e37

12 files changed

+877
-6
lines changed

docs/content/doc/usage/actions/act-runner.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
date: "2023-04-27T15:00:00+08:00"
33
title: "Act Runner"
4-
slug: "usage/actions/act-runner"
4+
slug: "act-runner"
55
weight: 20
66
draft: false
77
toc: false
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
date: "2023-05-24T15:00:00+08:00"
3+
title: "Act Runner"
4+
slug: "act-runner"
5+
weight: 20
6+
draft: false
7+
toc: false
8+
menu:
9+
sidebar:
10+
parent: "actions"
11+
name: "Act Runner"
12+
weight: 20
13+
identifier: "actions-runner"
14+
---
15+
16+
# Act Runner
17+
18+
本页面将详细介绍[Act Runner](https://gitea.com/gitea/act_runner),这是Gitea Actions的Runner。
19+
20+
**目录**
21+
22+
{{< toc >}}
23+
24+
## 要求
25+
26+
建议在Docker容器中运行Job,因此您需要首先安装Docker。
27+
并确保Docker守护进程正在运行。
28+
29+
其他与Docker API兼容的OCI容器引擎也应该可以正常工作,但尚未经过测试。
30+
31+
但是,如果您确定要直接在主机上运行Job,则不需要Docker。
32+
33+
## 安装
34+
35+
有多种安装Act Runner的方法。
36+
37+
### 下载二进制文件
38+
39+
您可以从[发布页面](https://gitea.com/gitea/act_runner/releases)下载二进制文件。
40+
然而,如果您想使用最新的夜间构建版本,可以从[下载页面](https://dl.gitea.com/act_runner/)下载。
41+
42+
下载二进制文件时,请确保您已经下载了适用于您的平台的正确版本。
43+
您可以通过运行以下命令进行检查:
44+
45+
```bash
46+
chmod +x act_runner
47+
./act_runner --version
48+
```
49+
50+
如果看到版本信息,则表示您已经下载了正确的二进制文件。
51+
52+
### 使用 Docker 镜像
53+
54+
您可以使用[docker hub](https://hub.docker.com/r/gitea/act_runner/tags)上的Docker镜像。
55+
与二进制文件类似,您可以使用`nightly`标签使用最新的夜间构建版本,而`latest`标签是最新的稳定版本。
56+
57+
```bash
58+
docker pull gitea/act_runner:latest # for the latest stable release
59+
docker pull gitea/act_runner:nightly # for the latest nightly build
60+
```
61+
62+
## 配置
63+
64+
配置通过配置文件进行。它是可选的,当没有指定配置文件时,将使用默认配置。
65+
66+
您可以通过运行以下命令生成配置文件:
67+
68+
```bash
69+
./act_runner generate-config
70+
```
71+
72+
默认配置是安全的,可以直接使用。
73+
74+
```bash
75+
./act_runner generate-config > config.yaml
76+
./act_runner --config config.yaml [command]
77+
```
78+
79+
当使用Docker镜像时,可以使用`CONFIG_FILE`环境变量指定配置文件。确保将文件作为卷挂载到容器中:
80+
81+
```bash
82+
docker run -v $(pwd)/config.yaml:/config.yaml -e CONFIG_FILE=/config.yaml ...
83+
```
84+
85+
您可能注意到上面的命令都是不完整的,因为现在还不是运行Act Runner的时候。
86+
在运行Act Runner之前,我们需要首先将其注册到您的Gitea实例中。
87+
88+
## 注册
89+
90+
在运行Act Runner之前,需要进行注册,因为Runner需要知道从哪里获取Job,并且对于Gitea实例来说,识别Runner也很重要。
91+
92+
### Runner级别
93+
94+
您可以在不同级别上注册Runner,它可以是:
95+
96+
- 实例级别:Runner将为实例中的所有存储库运行Job。
97+
- 组织级别:Runner将为组织中的所有存储库运行Job。
98+
- 存储库级别:Runner将为其所属的存储库运行Job。
99+
100+
请注意,即使存储库具有自己的存储库级别Runner,它仍然可以使用实例级别或组织级别Runner。未来的版本可能提供更多对此进行更好控制的选项。
101+
102+
### 获取注册令牌
103+
104+
Runner级别决定了从哪里获取注册令牌。
105+
106+
- 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/runners`
107+
- 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/runners`
108+
- 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/runners`
109+
110+
如果您无法看到设置页面,请确保您具有正确的权限并且已启用 Actions。
111+
112+
注册令牌的格式是一个随机字符串 `D0gvfu2iHfUjNqCYVljVyRV14fISpJxxxxxxxxxx`
113+
114+
### 注册Runner
115+
116+
可以通过运行以下命令来注册Act Runner:
117+
118+
```bash
119+
./act_runner register
120+
```
121+
122+
或者,您可以使用 `--config` 选项来指定前面部分提到的配置文件。
123+
124+
```bash
125+
./act_runner --config config.yaml register
126+
```
127+
128+
您将逐步输入注册信息,包括:
129+
130+
- Gitea 实例的 URL,例如 `https://gitea.com/``http://192.168.8.8:3000/`
131+
- 注册令牌。
132+
- Runner名称(可选)。如果留空,将使用主机名。
133+
- Runner标签(可选)。如果留空,将使用默认标签。
134+
135+
您可能对Runner标签感到困惑,稍后将对其进行解释。
136+
137+
如果您想以非交互方式注册Runner,可以使用参数执行以下操作。
138+
139+
```bash
140+
./act_runner register --no-interactive --instance <instance_url> --token <registration_token> --name <runner_name> --labels <runner_labels>
141+
```
142+
143+
注册Runner后,您可以在当前目录中找到一个名为 `.runner` 的新文件。该文件存储注册信息。
144+
请不要手动编辑该文件。
145+
如果此文件丢失或损坏,可以直接删除它并重新注册。
146+
147+
如果您想将注册信息存储在其他位置,请在配置文件中指定,并不要忘记指定 `--config` 选项。
148+
149+
### 使用Docker注册Runner
150+
151+
如果您使用的是Docker镜像,注册行为会略有不同。在这种情况下,注册和运行合并为一步,因此您需要在运行Act Runner时指定注册信息。
152+
153+
```bash
154+
docker run \
155+
-v $(pwd)/config.yaml:/config.yaml \
156+
-v $(pwd)/data:/data \
157+
-v /var/run/docker.sock:/var/run/docker.sock \
158+
-e CONFIG_FILE=/config.yaml \
159+
-e GITEA_INSTANCE_URL=<instance_url> \
160+
-e GITEA_RUNNER_REGISTRATION_TOKEN=<registration_token> \
161+
-e GITEA_RUNNER_NAME=<runner_name> \
162+
-e GITEA_RUNNER_LABELS=<runner_labels> \
163+
--name my_runner \
164+
-d gitea/act_runner:nightly
165+
```
166+
167+
您可能注意到我们已将`/var/run/docker.sock`挂载到容器中。
168+
这是因为Act Runner将在Docker容器中运行Job,因此它需要与Docker守护进程进行通信。
169+
如前所述,如果要在主机上直接运行Job,可以将其移除。
170+
需要明确的是,这里的 "主机" 实际上指的是当前运行 Act Runner的容器,而不是主机机器本身。
171+
172+
### 标签
173+
174+
Runner的标签用于确定Runner可以运行哪些Job以及如何运行它们。
175+
176+
默认标签为`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`
177+
它们是逗号分隔的列表,每个项目都是一个标签。
178+
179+
让我们以 `ubuntu-22.04:docker://node:16-bullseye` 为例。
180+
它意味着Runner可以运行带有`runs-on: ubuntu-22.04`的Job,并且该Job将在使用`node:16-bullseye`镜像的Docker容器中运行。
181+
182+
如果默认镜像无法满足您的需求,并且您有足够的磁盘空间可以使用更好、更大的镜像,您可以将其更改为`ubuntu-22.04:docker://<您喜欢的镜像>`
183+
您可以在[act 镜像](https://github.com/nektos/act/blob/master/IMAGES.md)上找到更多有用的镜像。
184+
185+
如果您想直接在主机上运行Job,您可以将其更改为`ubuntu-22.04:host`或仅`ubuntu-22.04``:host`是可选的。
186+
然而,我们建议您使用类似`linux_amd64:host``windows:host`的特殊名称,以避免误用。
187+
188+
还有一点需要注意的是,建议在更改标签时注册Runner。
189+
这可能会有些麻烦,所以我们可能会在将来提供更好的方法来处理。
190+
191+
## 运行
192+
193+
注册完Runner后,您可以通过运行以下命令来运行它:
194+
195+
```bash
196+
./act_runner daemon
197+
# or
198+
./act_runner daemon --config config.yaml
199+
```
200+
201+
Runner将从Gitea实例获取Job并自动运行它们。
202+
203+
由于Act Runner仍处于开发中,建议定期检查最新版本并进行升级。

docs/content/doc/usage/actions/comparison.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
date: "2023-04-27T15:00:00+08:00"
33
title: "Compared to GitHub Actions"
4-
slug: "usage/actions/comparison"
4+
slug: "comparison"
55
weight: 30
66
draft: false
77
toc: false
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
date: "2023-05-24T15:00:00+08:00"
3+
title: "与GitHub Actions的对比"
4+
slug: "comparison"
5+
weight: 30
6+
draft: false
7+
toc: false
8+
menu:
9+
sidebar:
10+
parent: "actions"
11+
name: "对比"
12+
weight: 30
13+
identifier: "actions-comparison"
14+
---
15+
16+
# 与GitHub Actions的对比
17+
18+
尽管Gitea Actions旨在与GitHub Actions兼容,但它们之间存在一些差异。
19+
20+
**目录**
21+
22+
{{< toc >}}
23+
24+
## 额外功能
25+
26+
### Action URL绝对路径
27+
28+
Gitea Actions支持通过URL绝对路径定义actions,这意味着您可以使用来自任何Git存储库的Actions。
29+
例如,`uses: https://github.com/actions/checkout@v3``uses: http://your_gitea.com/owner/repo@branch`
30+
31+
### 使用Go编写Actions
32+
33+
Gitea Actions支持使用Go编写Actions。
34+
请参阅[创建Go Actions](https://blog.gitea.io/2023/04/creating-go-actions/)
35+
36+
## 不支持的工作流语法
37+
38+
### `concurrency`
39+
40+
这是用于一次运行一个Job。
41+
请参阅[使用并发](https://docs.github.com/zh/actions/using-jobs/using-concurrency)
42+
43+
Gitea Actions目前不支持此功能。
44+
45+
### `run-name`
46+
47+
这是工作流生成的工作流运行的名称。
48+
请参阅[GitHub Actions 的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#run-name)
49+
50+
Gitea Actions目前不支持此功能。
51+
52+
### `permissions``jobs.<job_id>.permissions`
53+
54+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#permissions)
55+
56+
Gitea Actions目前不支持此功能。
57+
58+
### `jobs.<job_id>.timeout-minutes`
59+
60+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes)
61+
62+
Gitea Actions目前不支持此功能。
63+
64+
### `jobs.<job_id>.continue-on-error`
65+
66+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error)
67+
68+
Gitea Actions目前不支持此功能。
69+
70+
### `jobs.<job_id>.environment`
71+
72+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenvironment)
73+
74+
Gitea Actions 目前不支持此功能。
75+
76+
### 复杂的`runs-on`
77+
78+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)
79+
80+
Gitea Actions目前只支持`runs-on: xyz``runs-on: [xyz]`
81+
82+
### `workflow_dispatch`
83+
84+
请参阅[GitHub Actions的工作流语法](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch)
85+
86+
Gitea Actions目前不支持此功能。
87+
88+
### `hashFiles`表达式
89+
90+
请参阅[表达式](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles)
91+
92+
Gitea Actions目前不支持此功能,如果使用它,结果将始终为空字符串。
93+
94+
作为解决方法,您可以使用[go-hashfiles](https://gitea.com/actions/go-hashfiles)
95+
96+
## 缺失的功能
97+
98+
### 变量
99+
100+
请参阅[变量](https://docs.github.com/zh/actions/learn-github-actions/variables)
101+
102+
目前变量功能正在开发中。
103+
104+
### 问题匹配器
105+
106+
问题匹配器是一种扫描Actions输出以查找指定正则表达式模式并在用户界面中突出显示该信息的方法。
107+
请参阅[问题匹配器](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md)
108+
109+
Gitea Actions目前不支持此功能。
110+
111+
### 为错误创建注释
112+
113+
请参阅[为错误创建注释](https://docs.github.com/zh/actions/using-workflows/workflow-commands-for-github-actions#example-creating-an-annotation-for-an-error)
114+
115+
Gitea Actions目前不支持此功能。
116+
117+
## 缺失的UI功能
118+
119+
### 预处理和后处理步骤
120+
121+
预处理和后处理步骤在Job日志用户界面中没有自己的用户界面。
122+
123+
## 不一样的行为
124+
125+
### 下载Actions
126+
127+
Gitea Actions默认不从GitHub下载Actions。
128+
"默认" 意味着您在`uses` 字段中不指定主机,如`uses: actions/checkout@v3`
129+
相反,`uses: https://github.com/actions/checkout@v3`是有指定主机的。
130+
131+
如果您不进行配置,缺失的主机将填充为`https://gitea.com`
132+
这意味着`uses: actions/checkout@v3`将从[gitea.com/actions/checkout](https://gitea.com/actions/checkout)下载该Action,而不是[github.com/actions/checkout](https://github.com/actions/checkout)
133+
134+
正如前面提到的,这是可配置的。
135+
如果您希望您的运行程序默认从GitHub或您自己的Gitea实例下载动作,您可以通过设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单]({{< relref "doc/administration/config-cheat-sheet.en-us.md#actions-actions" >}})。
136+
137+
### 上下文可用性
138+
139+
不检查上下文可用性,因此您可以在更多地方使用env上下文。
140+
请参阅[上下文可用性](https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability)
141+
142+
## 已知问题
143+
144+
### `docker/build-push-action@v4`
145+
146+
请参阅[act_runner#119](https://gitea.com/gitea/act_runner/issues/119#issuecomment-738294)
147+
148+
`ACTIONS_RUNTIME_TOKEN`在Gitea Actions中是一个随机字符串,而不是JWT。
149+
但是`DOCKER/BUILD-PUSH-ACTION@V4尝试将令牌解析为JWT,并且不处理错误,因此Job失败。
150+
151+
有两种解决方法:
152+
153+
手动将`ACTIONS_RUNTIME_TOKEN`设置为空字符串,例如:
154+
155+
``` yml
156+
- name: Build and push
157+
uses: docker/build-push-action@v4
158+
env:
159+
ACTIONS_RUNTIME_TOKEN: ''
160+
with:
161+
...
162+
```
163+
164+
该问题已在较新的[提交](https://gitea.com/docker/build-push-action/commit/d8823bfaed2a82c6f5d4799a2f8e86173c461aba?style=split&whitespace=show-all#diff-1af9a5bdf96ddff3a2f3427ed520b7005e9564ad)中修复,但尚未发布。因此,您可以通过指定分支名称来使用最新版本,例如:
165+
166+
``` yml
167+
- name: Build and push
168+
uses: docker/build-push-action@master
169+
with:
170+
...
171+
```

0 commit comments

Comments
 (0)