docs(README): 新增 Codex CLI composite action 使用說明
CI / Release Tag Version (pull_request) Successful in 3s
CI / Codex (pull_request) Failing after 14s

This commit is contained in:
Jeffery
2026-06-29 11:59:43 +08:00
parent dc9ab5f235
commit 5a21b30e9c
+57
View File
@@ -0,0 +1,57 @@
# Codex CLI Composite Action
此 repository 提供一個 Gitea/GitHub Actions composite action,用於安裝 Codex CLI、寫入 OAuth token、執行指定提示詞,並將 CLI 輸出寫入 action output。
## 專案列表
### 專案描述
| 專案名稱 | 專案描述 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/composite-actions/codex) | 提供 Codex CLI composite action,讓 workflow 可透過 `oauth``prompt` 輸入執行 CLI,並從 repository variable 讀取模型名稱後取得文字輸出。 |
### 參考專案
| 專案名稱 | 參考專案列表 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/composite-actions/codex) | 無 |
### NuGet 套件
| 專案名稱 | NuGet 套件列表 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/composite-actions/codex) | 無 |
## 功能列表
此 repository 未包含可列入 README 的 public method、public constructor、public extension method 或 public operator。
## 使用範例
### 在 workflow 中呼叫 Codex CLI
以下範例示範在 workflow step 中呼叫此 composite action,傳入 OAuth token 與提示詞,並在後續步驟讀取 `text` output。模型名稱由 action 直接讀取 `vars.CODEX_MODEL`
```yaml
- name: 執行 Codex CLI
id: codex
uses: https://gitea.jsc.idv.tw/composite-actions/codex@v1
with:
oauth: ${{ secrets.CODEX_OAUTH }}
prompt: "請自我介紹"
- name: 使用輸出文字
run: printf '%s\n' '${{ steps.codex.outputs.text }}'
```
前置條件:
- `secrets.CODEX_OAUTH` 必須是 Codex OAuth token 檔案內容的 base64 字串。
- `vars.CODEX_MODEL` 必須是 Codex CLI 可用的模型名稱。
- runner 必須可透過 npm 安裝 `@openai/codex`
預期結果:
- action 會安裝 `codex` CLI。
- action 會將 OAuth token 寫入 `$HOME/.codex/auth.json` 並設定檔案權限為 `600`
- action 會執行 `codex exec --model "$MODEL" "$PROMPT"`,並把 stdout 寫入 `steps.codex.outputs.text`