mirror of
https://gitea.com/gitea/docs.git
synced 2026-11-07 18:40:32 +00:00
<!-- cloudflare-preview --> Preview: https://pr-564.docs-gitea-com.pages.dev Reviewed-on: https://gitea.com/gitea/docs/pulls/564 Reviewed-by: bircni <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
103 lines
4.2 KiB
Markdown
103 lines
4.2 KiB
Markdown
---
|
|
date: "2023-05-24T15:00:00+08:00"
|
|
slug: "comparison"
|
|
sidebar_position: 15
|
|
---
|
|
|
|
# 与GitHub Actions的对比
|
|
|
|
Gitea Actions旨在与GitHub Actions兼容,差异如下。
|
|
|
|
## 额外功能
|
|
|
|
<a id="absolute-action-urls"></a>
|
|
### Action URL绝对路径
|
|
|
|
`uses:`支持指向任意Git托管平台的绝对URL,例如`uses: https://gitea.com/actions/checkout@v4`。
|
|
|
|
<a id="action-prefixes"></a>
|
|
### Action前缀
|
|
|
|
`uses:`支持以下前缀:
|
|
|
|
- `self:`引用您自己的Gitea实例,例如`uses: self:owner/repo@v1`或`uses: self:owner/repo/.gitea/workflows/build.yml@v1`
|
|
- `builtin:`运行Gitea Runner内置的Action,无需下载,Job镜像中也无需Node,例如`uses: builtin:checkout`
|
|
|
|
`builtin:checkout`支持`actions/checkout`的`repository`、`ref`、`token`、`path`和`fetch-depth`输入,默认值相同,其他输入会使步骤失败。
|
|
|
|
<a id="workflow-relative-actions"></a>
|
|
### 相对于工作流的Actions
|
|
|
|
`$/`引用工作流所在的仓库和提交,或外层复合Action所在的仓库和提交,例如`uses: $/.gitea/actions/build`。
|
|
与`./`不同,它无需事先检出代码。
|
|
|
|
### 使用Go编写Actions
|
|
|
|
请参阅[创建Go Actions](https://blog.gitea.com/creating-go-actions/)。
|
|
|
|
### 支持非标准的调度语法 @yearly, @monthly, @weekly, @daily, @hourly
|
|
|
|
`schedule`还支持`@yearly`、`@monthly`、`@weekly`、`@daily`和`@hourly`,而[GitHub不支持](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule)。
|
|
|
|
## 不支持的工作流语法
|
|
|
|
### `jobs.<job_id>.environment`
|
|
|
|
[`jobs.<job_id>.environment`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenvironment)会被忽略。
|
|
|
|
### 复杂的`runs-on`
|
|
|
|
[`runs-on`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)支持:
|
|
|
|
- 静态字符串:`runs-on: self-hosted`
|
|
- 标签数组:`runs-on: [linux, self-hosted]`
|
|
- 字符串表达式:`runs-on: ${{ github.event_name == 'push' && 'ubuntu-latest' || 'self-hosted' }}`
|
|
- 包含表达式的数组:`runs-on: [linux, "${{ github.event_name == 'push' && 'ubuntu-latest' || 'self-hosted' }}"]`
|
|
|
|
## 缺失的功能
|
|
|
|
### 软件包仓库授权
|
|
|
|
`GITEA_TOKEN`无法发布到其所属仓库的软件包注册表,例如无法推送OCI镜像。
|
|
请改用个人访问令牌,参见[此问题](https://github.com/go-gitea/gitea/issues/23642#issuecomment-2119876692)。
|
|
|
|
### 问题匹配器
|
|
|
|
[问题匹配器](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md)会被忽略。
|
|
|
|
### 为错误创建注释
|
|
|
|
[错误注释](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-creating-an-annotation-for-an-error)会被忽略。
|
|
|
|
### 表达式
|
|
|
|
[表达式](https://docs.github.com/en/actions/learn-github-actions/expressions)支持GitHub的标准函数和上下文。
|
|
|
|
## 缺失的UI功能
|
|
|
|
### 预处理和后处理步骤
|
|
|
|
预处理和后处理步骤在Job日志中没有单独的区块。
|
|
|
|
### 服务步骤
|
|
|
|
服务步骤在Job日志中没有单独的区块。
|
|
|
|
## 不一样的行为
|
|
|
|
### `permissions`和`jobs.<job_id>.permissions`
|
|
|
|
`permissions`和`jobs.<job_id>.permissions`控制`GITEA_TOKEN`的权限,该权限受仓库和所有者设置的限制,并在fork拉取请求和跨仓库访问时受到进一步限制。
|
|
不支持`statuses`、`checks`、`deployments`、`id-token`、`security-events`和`pages`等GitHub专有的权限范围,而Gitea额外提供了`code`、`releases`、`wiki`和`projects`。
|
|
请参阅[Actions Job令牌权限](token-permissions.md)。
|
|
|
|
### 下载Actions
|
|
|
|
未指定主机的Actions(如`uses: actions/checkout@v4`)会从`https://github.com`下载,当`[actions].DEFAULT_ACTIONS_URL`为`self`时则从您自己的实例下载。
|
|
请参阅[配置备忘单](../../administration/config-cheat-sheet.md#actions-actions)。
|
|
其他来源请参阅[Action URL绝对路径](#absolute-action-urls)、[Action前缀](#action-prefixes)和[相对于工作流的Actions](#workflow-relative-actions)。
|
|
|
|
### 上下文可用性
|
|
|
|
不检查[上下文可用性](https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability),因此`env`等上下文可以在更多地方使用。
|