Knowledge File / AI技能杠杆
使用自仓库语法引用同仓库的 Actions
GitHub Actions 新增自仓库引用语法,以 $/ 开头指向当前运行提交,无需 checkout,简化内部组合,并支持完整 SHA 锁定。
SOURCE / AI技能杠杆
MIN / 9
ACCESS / 会员
POST / 2026-07-31 01:39:46
原贴
查看原文原文
You can now reference an action or reusable workflow that lives in the same repository using the new self-repository syntax. A uses: value that starts with $/ resolves to your workflow’s own repository at the exact commit that is running, with no checkout required. It works everywhere the workspace-relative ./ syntax works, including workflow steps, composite action steps, nested composition, and reusable workflow calls. Before this, referencing an action defined in your own repository meant either relying on ./ and a checkout, or hardcoding a version. This was a maintenance burden and quietly defeated commit SHA pinning. With self-repository references, sibling actions and workflows automatically match the ref you are already running, so your internal references stay consistent even when callers pin to a full-length commit SHA. This also makes it possible to adopt the enterprise policy that requires actions to be pinned to a full-length commit SHA for workflows that call their own actions. Self-repository references are now the recommended way to compose actions and reusable workflows within a repository. They are available on github.com. This feature requires the GitHub Actions runner to be on version 2.336.0 or newer. Learn more by checking out our docs about finding and customizing actions , or join the discussion within GitHub Community .
中文翻译
你现在可以使用新的自仓库语法,引用位于同一仓库中的操作或可重用工作流。
以 $/ 开头的 uses: 值会解析为你工作流自身仓库正在运行的确切提交,且无需 checkout。
它适用于所有工作区相对 ./ 语法可用的地方,包括工作流步骤、复合操作步骤、嵌套组合和可重用工作流调用。
在此之前,引用自己仓库中定义的操作,要么依赖 ./ 和 checkout,要么硬编码版本。
这是一种维护负担,并悄悄破坏了提交 SHA 固定。
使用自仓库引用,同级操作和工作流会自动匹配你正在运行的引用,因此即使调用者固定到完整长度的提交 SHA,你的内部引用也能保持一致。
这也使得采用企业策略成为可能,该策略要求对调用自身操作的工作流,将操作固定到完整长度的提交 SHA。
自仓库引用现在是组合仓库内操作和可重用工作流的推荐方式。
它们在 github.com 上可用。
此功能要求 GitHub Actions runner 版本为 2.336.0 或更高。
可通过查看关于查找和自定义操作的文档了解更多,或加入 GitHub Community 中的讨论。
核心信息
GitHub Actions 新增自仓库引用语法,以 $/ 开头指向当前运行提交,无需 checkout,简化内部组合,并支持完整 SHA 锁定。
- GitHub Actions 新增自仓库引用语法,以 $/ 开头指向当前运行提交,无需 checkout,简化内部组合,并支持完整 SHA 锁定。
- 原贴提到:You can now reference an action or reusable workflow that lives in the s
- 来源:github.blog
试看内容
成为会员查看完整内容
你已经看到了这篇内容的前置整理,剩余深度部分仅对会员开放。
详细解读
信息差价值
参考来源
成为会员查看完整内容