mirror of
https://gitea.com/gitea/docs.git
synced 2026-11-07 02:20:31 +00:00
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]>
121 lines
8.0 KiB
Markdown
121 lines
8.0 KiB
Markdown
---
|
||
date: "2023-05-24T15:00:00+08:00"
|
||
slug: "faq"
|
||
sidebar_position: 100
|
||
---
|
||
|
||
# Gitea Actions常見問題解答
|
||
|
||
本頁面包含一些關於Gitea Actions的常見問題和答案。
|
||
|
||
## 是否可以在我的實例中預設禁用新儲存庫的Actions?
|
||
|
||
是的,當您為實例啟用Actions時,您可以選擇預設啟用actions單元以適用於所有新儲存庫。
|
||
|
||
```ini
|
||
[repository]
|
||
; 去掉 repo.actions 將不會為新倉庫自動啟用actions
|
||
DEFAULT_REPO_UNITS = ...,repo.actions
|
||
```
|
||
|
||
## 在工作流文件中應該使用`${{ github.xyz }}`還是`${{ gitea.xyz }}`?
|
||
|
||
您可以使用`github.xyz`,Gitea將正常工作。
|
||
如前所述,Gitea Actions的設計是與GitHub Actions相容的。
|
||
然而,我們建議在工作流文件中使用`gitea.xyz`,以防止在工作流文件中出現不同類型的密鑰(因為您在Gitea上使用此工作流,而不是GitHub)。
|
||
不過,這完全是可選的,因為目前這兩個選項的效果是相同的。
|
||
|
||
## 使用`actions/checkout@v4`等Actions時,Job容器會從何處下載腳本?
|
||
|
||
預設從 `https://github.com` 下載,若 `[actions].DEFAULT_ACTIONS_URL` 為 `self`,則從您自己的實例下載,參見[設定速查表](../../administration/config-cheat-sheet.md#actions-actions)。
|
||
|
||
若要使用其他來源的 Action,請指定其主機:
|
||
|
||
- `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 實例。
|
||
對於每個 Job,Runner 會取得一個僅限於該 Job 所屬儲存庫的 `GITEA_TOKEN`,參見 [Actions Job 令牌權限](token-permissions.md)。
|
||
若要讓 Job 存取更多私有儲存庫或外部系統,請向其傳遞[密鑰](usage/actions/secrets.md)。
|
||
|
||
## 如何避免被黑客攻擊?
|
||
|
||
有兩種可能的攻擊類型:未知的Runner竊取您的儲存庫中的程式碼或密鑰,或惡意腳本控制您的Runner。
|
||
|
||
避免前者意味著不允許您不認識的人為您的儲存庫、組織或實例註冊Runner。
|
||
|
||
後者要複雜一些。
|
||
如果您為公司使用私有的Gitea實例,您可能不需要擔心安全問題,因為您信任您的同事,並且可以追究他們的責任。
|
||
|
||
對於公共實例,情況略有不同。
|
||
以下是我們在 [gitea.com](http://gitea.com/)上的做法:
|
||
|
||
- 我們僅為 "gitea" 組織註冊Runner,因此我們的Runner不會執行來自其他儲存庫的Job。
|
||
- 我們的Runner始終在隔離容器中運行Job。雖然可以直接在主機上進行這樣的操作,但出於安全考慮,我們選擇不這樣做。
|
||
- 對於 fork 的拉取請求,需要獲得批准才能運行Actions。參見[#22803](https://github.com/go-gitea/gitea/pull/22803)。
|
||
- 如果有人在[gitea.com](http://gitea.com/)為其儲存庫或組織註冊自己的Runner,我們不會反對,只是不會在我們的組織中使用它。然而,他們應該注意確保該Runner不被他們不認識的其他使用者使用。
|
||
|
||
## runner支援哪些操作系統?
|
||
|
||
官方發佈了 Linux、macOS 和 Windows 的二進制檔案。
|
||
理論上,Go 和 Docker 支援的其他系統也能運作。
|
||
|
||
## 為什麼選擇GitHub Actions?為什麼不選擇與GitLab CI/CD相容的工具?
|
||
|
||
[@lunny](https://gitea.com/lunny)在實現Actions的[問題](https://github.com/go-gitea/gitea/issues/13539)中已經解釋過這個問題。
|
||
此外,Actions不僅是一個CI/CD 系統,還是一個自動化工具。
|
||
|
||
在開源世界中,已經有許多[市場上的Actions](https://github.com/marketplace?type=actions)實現了。
|
||
能夠重用它們是令人興奮的。
|
||
|
||
## 如果它在多個標籤上運行,例如 `runs-on: [label_a, label_b]`,會發生什麼?
|
||
|
||
Job 會在具有所有這些標籤的 Runner 上運行,與 [GitHub](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on) 相同。
|
||
Runner 會使用它所具有的第一個標籤對應的環境。
|
||
|
||
## 代理標籤和自訂標籤對於Runner有什麼區別?
|
||
|
||
Gitea 已不再有自訂標籤。
|
||
Runner 每次啟動時都會宣告其標籤,標籤來自 `runner.labels` 設定或註冊時指定的標籤,因此請在那裡修改並重新啟動 Runner。
|
||
|
||
## Gitea Actions runner會有更多的實現嗎?
|
||
|
||
雖然我們希望提供更多的選擇,但由於我們有限的人力資源, runner將是唯一受支援的官方Runner。
|
||
然而,無論您如何決定,Gitea 和 runner都是完全開源的,所以任何人都可以建立一個新的/更好的實現。
|
||
我們支援您的選擇,無論您如何決定。
|
||
如果您選擇分支 runner 來建立自己的版本,請在您認為您的更改對其他人也有幫助的情況下貢獻這些更改。
|
||
|
||
## Gitea 支援哪些工作流觸發事件?
|
||
|
||
表格中列出的所有事件都是支援的,並且與 GitHub 相容。
|
||
對於僅 GitHub 支援的事件,請參閱 GitHub 的[文件](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)。
|
||
|
||
| 觸發事件 | 活動類型 |
|
||
|-----------------------------|--------------------------------------------------------------------------------------------------------------------------|
|
||
| create | 不適用 |
|
||
| delete | 不適用 |
|
||
| fork | 不適用 |
|
||
| gollum | 不適用 |
|
||
| push | 不適用 |
|
||
| issues | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `milestoned`, `demilestoned`, `labeled`, `unlabeled` |
|
||
| issue_comment | `created`, `edited`, `deleted` |
|
||
| pull_request | `opened`, `edited`, `closed`, `reopened`, `assigned`, `unassigned`, `synchronize`, `labeled`, `unlabeled` |
|
||
| pull_request_review | `submitted`, `edited` |
|
||
| pull_request_review_comment | `created`, `edited` |
|
||
| release | `published`, `edited` |
|
||
| registry_package | `published` |
|
||
|
||
> 對於 `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)。
|