The gihub.ref description is confusing and incorrect, particularly for PRs
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- github-actions
调研方向
先查看链接的 docs.github.com URL 中关于 GitHub Actions GitHub 上下文的文章,然后将其中对 github.ref 的描述与链接的事件文档进行对比。明确每个列出事件的行为,并将该段落重构为易读的情况;描述准确且没有歧义即表示完成。
由索引模型根据 Issue 内容生成。
描述
Code of Conduct
- I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#github-context
What part(s) of the article would you like to see updated?
The description for github.ref is confusing, misleading and incorrect, particularly for PR events.
The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by
push, this is the branch or tag ref that was pushed. For workflows triggered bypull_requestthat were not merged, this is the pull request merge branch. If the pull request was merged, this is the head branch. For workflows triggered byrelease, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format isrefs/heads/<branch_name>. For pull requests events exceptpull_request_targetthat were not merged, it isrefs/pull/<pr_number>/merge.pull_request_targetevents have thereffrom the base branch. For tags it isrefs/tags/<tag_name>. For example,refs/heads/feature-branch-1.
Firstly, it's quite hard to follow the different branching logic of that parapgrah. Can this be formatted better, e.g. with nested bullet points?
Secondly, particularly for PR events, the logic is quite unclear, and incorrect in some places. The description mentions
pull requests events
but doesn't define them what these are. Is it the following subset of triggers?
Assuming this is the case, my understanding of the logic is as follows:
pull_requestevents with aclosedactivity type that were merged:github.ref=refs/heads/<head_branch>- All other
pull_requestevents:github.ref=refs/pull/<pr_number>/merge - All
pull_request_targetevents (potentially excluding merged events):github.ref=refs/heads/<base_branch> issue_comment,pull_request_reviewandpull_request_review_comment(and potentially mergedpull_request_target) events:github.ref=refs/pull/<pr_number>/merge
Problems to highlight:
- It's unclear whether "pull requests events except
pull_request_targetthat were not merged" includes mergedpull_request_targetevents. My tests suggest it doesn't; mergedpull_request_targetevents showrefs/heads/main, notrefs/pull/<pr_number>/merge. What is this line trying to say? - On a merged
pull_requestevent, my tests show<base_branch>, not<head_branch>. There is a mistake in the description. - For
pull_request_targetevents, regardless of PR direction (main->testortest->main), my tests showrefs/heads/main. Is it always the repo default, not the PR base? - My tests show
issue_commentevents userefs/heads/main(regardless of PR direction), notrefs/pull/<pr_number>/merge. Are these events not part of the PR logic? Does it always use the repo default? - If we're being picky, there's a case to be made that "workflows triggered by
pull_requestthat were not merged" means "closedand not merged" - meaning other activity types might not be included in the list. This could be worded better
Is the following summary more accurate?
- All
pull_request_targetevents:refs/heads/<default_branch> - Merged
pull_requestevents:refs/heads/<base_branch> - All other
pull_requestevents, and allpull_request_reviewandpull_request_review_commentevents:refs/pull/<pr_number>/merge issue_commentevents:refs/heads/<default_branch>
Additional information
No response
- 主要语言
- TypeScript
- 星标
- 20.9k
- 派生
- 68.8k
- 平均合并
- 13 小时 43 分钟
- 30 天内合并 PR
- 110
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/docs 的其他 Issue
-
triage
难度 1/5 1-3 小时 新手友好度 88/100
-
localization
难度 2/5 1-2 天 新手友好度 72/100
-
builder persona
难度 2/5 1-3 小时 新手友好度 82/100
-
content localization
难度 2/5 1-3 小时 新手友好度 78/100
-
content localization
难度 1/5 1 小时以内 新手友好度 92/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 75/100
fil-donadoni/tolaria#4409 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
corsairdev/corsair#1764 ·