github / github/docs

Documentation bug: expression numbers are mis-documented

未關閉 適合新手
#43,008 11 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

builder persona content github_actions never-stale
主要語言
TypeScript
星號
20.8k
分支
68.8k
平均合併
13 小時 10 分鐘
30 天內合併 PR
111

描述

### Code of Conduct

- [x] I have read and agree to the GitHub Docs project's [Code of Conduct](https://github.com/github/docs/blob/main/.github/CODE_OF_CONDUCT.md)

### What article on docs.github.com is affected?

The "Literals" section of the GitHub Actions expression syntax page:

https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#literals

That link is for the "Free, Pro, and Teams" page, but the GHES and GHEC pages are also affected.

### What part(s) of the article would you like to see updated?

The `number` literal is documented as "Any number format supported by JSON." However, in reality, the GitHub Actions expression parser takes a much larger set of literals, which it coerces to numbers.

For example, neither hex nor octal literals are valid in JSON, but GitHub Actions accepts them. For example:

```
${{ 0xff }}
${{ 0o777 }}
```

More generally, GitHub Actions appears to support any number literal that the JavaScript `Number(...)` constructor can coerce a string from. Those coercion rules are documented here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_coercion

This can be seen in the official GitHub Actions expression parser, which appears to use the `Number(...)` constructor when turning a `StringData` lexeme into a number:

https://github.com/actions/languageservices/blob/fb5c6e4f27bb1ddf512609a6a341aadd17ce86f3/expressions/src/data/string.ts#L14-L16

### Additional information

Yes, this is trivially reproducible in any GitHub Actions workflow or action definition.

See https://github.com/zizmorcore/zizmor/pull/1628 for a related downstream report.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 GitHub Actions 運算式語法頁面的「Literals」區段開始,比較 Free、Pro 和 Teams、GHES 以及 GHEC 版本。檢視 expressions/src/data/string.ts 第 14–16 行中參照的 parser 原始碼,以及連結的 Number coercion 規則。完成標準是:文件準確描述所有受影響頁面上可接受的 Number literals。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
github-actions, javascript
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
78/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。