Files
jiantw83 18b226906f
CI / 1. BUILD (pull_request) Successful in 4s
CI / 2. TEST (pull_request) Has been skipped
CI / 3. RESULT (pull_request) Has been skipped
docs(setup-codex): 重整 action、workflow 與 README 文件
2026-07-11 10:44:30 +00:00

71 lines
3.4 KiB
Markdown
Raw Permalink 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/11 18:39:51Asia/Taipei
`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。
## 專案列表
### 專案描述
| 專案名稱 | 專案描述 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並透過 workflow 範例展示如何在 CICD 中串接 Codex。 |
### 參考專案
| 專案名稱 | 參考專案列表 |
| --- | --- |
| [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) | 無 |
## 功能列表
本專案未公開可列入 README 的功能(public methodconstructorextension methodoperator)。
| 功能名稱 | 功能描述 |
| --- | --- |
| (無) | 此專案未公開可列入 README 的功能。 |
## 使用範例
### 在 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
- name: Run Setup Codex
uses: ./
with:
oauth: ${{ secrets.CODEX_OAUTH }}
- 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 的存取權限與隱私。
- `outputs.message` 目前參照的 `steps.exchange` 步驟不存在,屬於既有問題,需人工確認。
### 對應的 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`build``base_ref == 'develop'` 設定 `IS_BETA` 並輸出 `is_beta`,當 `is_beta == 'true'`(即 develop 的 PR)時執行本 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 並顯示。 |