Files
setup-codex/README.md
T
Jeffery e839b74754
CI / 1. BUILD (pull_request) Successful in 1s
CI / 2. TEST (pull_request) Has been skipped
CI / 3. RESULT (pull_request) Has been skipped
docs(指令檔與 README): 補齊 action/master 逐行註解並更新 README 與 CI 觸發說明
2026-07-03 17:52:40 +08:00

76 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# setup-codex
> 更新時間:2026/07/03 17:43:30
`setup-codex` 是一個 **Gitea composite action**,用於在 Gitea Actions runner 上安裝並登入 [Codex CLI](https://chatgpt.com/codex),讓後續 workflow 步驟能直接呼叫已完成 OAuth 登入的 `codex` 指令。本 repo 由 action 定義(`action.yml`)與示範用的 CI/CD workflow 組成,內容皆為 YAML 與少量 shellNode**不含可列入 README 的公開程式方法**。
## 專案列表
### 專案描述
| 專案名稱 | 專案描述 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並顯示目前登入帳號;另附 CI(僅在 base 為 masterdevelop 的 PR 觸發,發佈 Release、依 is_beta 條件執行 codex 測試)與 CDpush master 反查 commit tag)示範 workflow。 |
### 參考專案
| 專案名稱 | 參考專案列表 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | 無 |
### NuGet 套件
| 專案名稱 | NuGet 套件列表 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | 無 |
## 功能列表
本專案為 Gitea composite actionYAML + shellNode),未公開任何可列入 README 的程式方法(public methodconstructorextension methodoperator)。
| 功能名稱 | 功能描述 |
| --- | --- |
| (無) | 此專案未公開可列入 README 的功能。 |
## 使用範例
> 說明:本專案無公開程式方法,以下改以「如何在 workflow 中使用此 composite action」作為使用範例。
### 在 workflow 中引用 action
在同一個 repo 內,可用相對路徑 `./` 引用本 action;跨 repo 則以 `owner/repo@版本` 引用。此 action 需要一個必填參數 `oauth`(透過 OAuth 登入 ChatGPT 產生、並經 base64 編碼的驗證檔內容,建議存放於 secrets)。
```yaml
jobs:
demo:
runs-on: ubuntu
steps:
- name: Source Code Checkout
uses: actions/checkout@v4
# 引用本 repo 根目錄的 composite action
- name: Run Setup Codex
uses: ./
with:
oauth: ${{ secrets.CODEX_OAUTH }}
# 登入完成後即可直接呼叫 codex
- name: Execute Codex
shell: bash
run: codex exec "請你進行自我介紹"
```
**前置條件與注意事項**
- `oauth`:必填。內容為 CodexChatGPT OAuth 驗證檔(`auth.json`)先經 base64 編碼後的字串,請存於 secret(例如 `CODEX_OAUTH`)避免外洩。
- action 會在 runner 家目錄產生 `~/.codex/auth.json`(含機敏憑證),並將 Codex 執行檔目錄加入 `PATH`
- action 內建的 `Show Codex Account` 步驟會將登入帳號的 email 輸出到 workflow log,請留意 log 的存取權限與隱私。
### 對應的 workflow 檔案
| 檔案 | 觸發時機 | 用途 |
| --- | --- | --- |
| [action.yml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/action.yml) | 被其他 workflow 以 `uses` 引用 | 定義安裝/登入 Codex 的 composite action。 |
| [.gitea/workflows/ci.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/ci.yaml) | base 為 `master``develop` 的 Pull Request`opened``synchronize` | 發佈 beta Release、輸出 `is_beta`,並在 `is_beta == 'true'` 時執行本 action 以 `codex exec` 產生自我介紹、顯示結果。 |
| [.gitea/workflows/master.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/master.yaml) | push 至 `master` | 反查指定 commit 所屬的 git tag 並顯示。 |
> ⚠️ 注意:`ci.yaml` 的 `build` job 目前輸出的 `is_beta` 取自 `env.IS_BETA`,但該 env 未定義,實務上 `is_beta` 會是空字串、導致 `test` job 被略過;`action.yml` 的 `outputs.message` 參照的 `steps.exchange` 步驟亦不存在。以上為既有、待人工確認事項。