Files

22 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#### 3.1 工作原理简述
1. **触发器(Events)**:像 `push`、`pull_request`、`tag_push` 等事件会触发对应的工作流。
2. **工作流(Workflow)文件**:默认存储在仓库的 `.gitea/workflows/` 目录下(或自定义)。类似 GitHub Actions,一般命名为 `main.yml` 或 `*.yml`。
3. **Runner**:一旦事件触发,Gitea 会调用 Runner 进行执行。Runner 就是一个容器/服务器,里边通过 `act` 工具解析并执行 `.gitea/workflows/*.yml` 中的 steps。
4. **steps / jobs**:在定义的 workflow 中,可以分多个 job,每个 job 再包含多个 step,依次执行 shell 命令或调用各种 actions(如 `actions/checkout@v4` 等)。
#### 3.2 存放[工作流](https://so.csdn.net/so/search?q=%E5%B7%A5%E4%BD%9C%E6%B5%81&spm=1001.2101.3001.7020)文件的位置
- **默认位置**:在 Gitea 仓库的根目录下新建 `.gitea/workflows/` 文件夹,然后在里面放置你的工作流文件,如 `main.yml`、`build.yml` 等。
- **可自定义**:如果你在仓库的 `Settings` 里修改了默认的 workflow 路径,你就需要把 `.yml` 文件放在你指定的目录里。
例如,我们可以在仓库中新建:
```
.gitea
└─ workflows
└─ main.yml
```
然后把下面这段示例写到 `main.yml` 里即可。
![[cc515c8d4a015321486e8e18ca98ebb9_2ac444af0f4840cda3a64e98950ac8b4.png]]