mirror of
https://gitea.com/gitea/docs.git
synced 2026-11-09 19:40:33 +00:00
docs: document self:, builtin:, $/ and runner tracing (#553)
Documents the `self:` and `builtin:` action prefixes from https://github.com/go-gitea/gitea/pull/39358, https://gitea.com/gitea/runner/pulls/1233 and https://gitea.com/gitea/runner/pulls/871, workflow-relative `$/` actions, and the runner's OpenTelemetry tracing from https://gitea.com/gitea/runner/pulls/1206. 1. Trims the action resolution and `DEFAULT_ACTIONS_URL` docs to state each fact once. 1. Drops outdated runner content from the FAQ and design pages. 1. Syncs zh-cn and zh-tw, including a port of the token permissions page they now link to. _Written by Claude._ Reviewed-on: https://gitea.com/gitea/docs/pulls/553 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
This commit is contained in:
1 parent
f9124b16db
commit
c4caf767ad
19 files changed
+476
-444
No files matched your search
@@ -27,34 +27,19 @@ DEFAULT_REPO_UNITS = ...,repo.actions
|
||||
|
||||
## 使用`actions/checkout@v4`等Actions時,Job容器會從何處下載腳本?
|
||||
|
||||
GitHub 上有成千上萬個 [Actions 腳本](https://github.com/marketplace?type=actions)。
|
||||
當您編寫 `uses: actions/checkout@v4` 時,它預設會從 [github.com/actions/checkout](https://github.com/actions/checkout) 下載腳本。
|
||||
那如果您想使用一些託管在其它平台上的腳本呢,比如在 gitea.com 上的?
|
||||
預設從 `https://github.com` 下載,若 `[actions].DEFAULT_ACTIONS_URL` 為 `self`,則從您自己的實例下載,參見[設定速查表](../../administration/config-cheat-sheet.md#actions-actions)。
|
||||
|
||||
好消息是,您可以指定要從任何位置使用Actions的URL前綴。
|
||||
這是Gitea Actions中的額外語法。
|
||||
例如:
|
||||
若要使用其他來源的 Action,請指定其主機:
|
||||
|
||||
- `uses: https://gitea.com/xxx/xxx@xxx`
|
||||
- `uses: https://github.com/xxx/xxx@xxx`
|
||||
- `uses: http://your_gitea_instance.com/xxx@xxx`
|
||||
|
||||
注意,`https://`或`http://`前綴是必需的!
|
||||
|
||||
這是與 GitHub Actions 的一個區別,GitHub Actions 只允許使用託管在 GitHub 上的 actions 腳本。
|
||||
但使用者理應擁有權利去靈活決定如何運行 Actions。
|
||||
|
||||
另外,如果您希望您的 Runner 預設從您自己的 Gitea 實例下載 Actions,可以透過設定 `[actions].DEFAULT_ACTIONS_URL`進行設定。
|
||||
參見[設定速查表](../../administration/config-cheat-sheet.md#actions-actions)。
|
||||
- `uses: https://gitea.com/owner/repo@ref`
|
||||
- `uses: http://your_gitea_instance.com/owner/repo@ref`
|
||||
- `uses: self:owner/repo@ref`,用於您自己的 Gitea 實例
|
||||
|
||||
## 如何限制Runner的權限?
|
||||
|
||||
Runner僅具有連接到您的Gitea實例的權限。
|
||||
當任何Runner接收到要運行的Job時,它將臨時獲得與Job關聯的儲存庫的有限權限。
|
||||
如果您想為Runner提供更多權限,允許它訪問更多私有儲存庫或外部系統,您可以向其傳遞[密鑰](usage/actions/secrets.md)。
|
||||
|
||||
對於 Actions 的細粒度權限控制是一項複雜的工作。
|
||||
在未來,我們將添加更多選項以使Gitea更可設定,例如允許對儲存庫進行更多寫訪問或對同一組織中的所有儲存庫進行讀訪問。
|
||||
Runner 只會連接到您的 Gitea 實例。
|
||||
對於每個 Job,Runner 會取得一個僅限於該 Job 所屬儲存庫的 `GITEA_TOKEN`,參見 [Actions Job 令牌權限](token-permissions.md)。
|
||||
若要讓 Job 存取更多私有儲存庫或外部系統,請向其傳遞[密鑰](usage/actions/secrets.md)。
|
||||
|
||||
## 如何避免被黑客攻擊?
|
||||
|
||||
@@ -75,19 +60,8 @@ Runner僅具有連接到您的Gitea實例的權限。
|
||||
|
||||
## runner支援哪些操作系統?
|
||||
|
||||
它在Linux、macOS和Windows上運行良好。
|
||||
雖然理論上支援其他操作系統,但需要進一步測試。
|
||||
|
||||
需要注意的一點是,如果選擇直接在主機上運行Job而不是在Job容器中運行,操作系統之間的環境差異可能會導致意外的失敗。
|
||||
|
||||
例如,在大多數情況下,Windows上沒有可用的bash,而act嘗試預設使用bash運行腳本。
|
||||
因此,您需要在工作流文件中將預設shell指定為`powershell`,參考[defaults.run](https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun)。
|
||||
|
||||
```yaml
|
||||
defaults:
|
||||
run:
|
||||
shell: powershell
|
||||
```
|
||||
官方發佈了 Linux、macOS 和 Windows 的二進制檔案。
|
||||
理論上,Go 和 Docker 支援的其他系統也能運作。
|
||||
|
||||
## 為什麼選擇GitHub Actions?為什麼不選擇與GitLab CI/CD相容的工具?
|
||||
|
||||
@@ -99,42 +73,13 @@ defaults:
|
||||
|
||||
## 如果它在多個標籤上運行,例如 `runs-on: [label_a, label_b]`,會發生什麼?
|
||||
|
||||
這是有效的語法。
|
||||
它意味著它應該在具有`label_a` **和** `label_b`標籤的Runner上運行,參考[GitHub Actions的工作流語法](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)。
|
||||
不幸的是,runner 並不支援這種方式。
|
||||
如上所述,我們將標籤映射到環境:
|
||||
|
||||
- `ubuntu` → `ubuntu:22.04`
|
||||
- `centos` → `centos:8`
|
||||
|
||||
但我們需要將標籤組映射到環境,例如:
|
||||
|
||||
- `[ubuntu]` → `ubuntu:22.04`
|
||||
- `[with-gpu]` → `linux:with-gpu`
|
||||
- `[ubuntu, with-gpu]` → `ubuntu:22.04_with-gpu`
|
||||
|
||||
我們還需要重新設計任務分配給Runner的方式。
|
||||
具有`ubuntu`、`centos`或`with-gpu`的Runner並不一定表示它可以接受`[centos, with-gpu]`的Job。
|
||||
因此,Runner應該通知Gitea實例它只能接受具有 `[ubuntu]`、`[centos]`、`[with-gpu]` 和 `[ubuntu, with-gpu]`的Job。
|
||||
這不是一個技術問題,只是在早期設計中被忽視了。
|
||||
參見[runtime.go#L65](https://gitea.com/gitea/runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L65)。
|
||||
|
||||
目前, runner嘗試匹配標籤中的每一個,並使用找到的第一個匹配項。
|
||||
Job 會在具有所有這些標籤的 Runner 上運行,與 [GitHub](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on) 相同。
|
||||
Runner 會使用它所具有的第一個標籤對應的環境。
|
||||
|
||||
## 代理標籤和自訂標籤對於Runner有什麼區別?
|
||||
|
||||

|
||||
|
||||
代理標籤是由Runner在註冊過程中向Gitea實例報告的。
|
||||
而自訂標籤則是由Gitea的管理員或組織或儲存庫的所有者手動添加的(取決於Runner所屬的級別)。
|
||||
|
||||
然而,目前這方面的設計還有待改進,因為它目前存在一些不完善之處。
|
||||
您可以向已註冊的Runner添加自訂標籤,比如 `centos`,這意味著該Runner將接收具有`runs-on: centos`的Job。
|
||||
然而,Runner可能不知道要使用哪個環境來執行該標籤,導致它使用預設鏡像或導致邏輯死衚衕。
|
||||
這個預設值可能與使用者的期望不符。
|
||||
參見[runtime.go#L71](https://gitea.com/gitea/runner/src/commit/90b8cc6a7a48f45cc28b5ef9660ebf4061fcb336/runtime/runtime.go#L71)。
|
||||
|
||||
與此同時,如果您想更改Runner的標籤,我們建議您重新註冊Runner。
|
||||
Gitea 已不再有自訂標籤。
|
||||
Runner 每次啟動時都會宣告其標籤,標籤來自 `runner.labels` 設定或註冊時指定的標籤,因此請在那裡修改並重新啟動 Runner。
|
||||
|
||||
## Gitea Actions runner會有更多的實現嗎?
|
||||
|
||||
@@ -165,3 +110,11 @@ defaults:
|
||||
|
||||
> 對於 `pull_request` 事件,在 [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) 中 `ref` 是 `refs/pull/:prNumber/merge`,它指向這個拉取請求合併提交的一個預覽。但是 Gitea 沒有這種 reference。
|
||||
> 因此,Gitea Actions 中 `ref` 是 `refs/pull/:prNumber/head`,它指向這個拉取請求的頭分支而不是合併提交的預覽。
|
||||
|
||||
## 如何共享私有儲存庫中的 Actions 和可重複使用的工作流?
|
||||
|
||||
前往儲存庫的**設定** > **Actions** > **General** 頁面,添加協作所有者。
|
||||
協作所有者的私有儲存庫可以存取目前儲存庫中的 Actions 和工作流。
|
||||
|
||||
若要在同一使用者或組織內共享,請改為在該使用者或組織的**設定** > **Actions** > **General** > **Cross-Repository Access** 中添加這些私有儲存庫。
|
||||
參見[跨儲存庫存取](token-permissions.md#cross-repository-access)。
|
||||
Reference in new issue
Block a user