Files

92 lines
3.0 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/17 11:54:39
安裝 Codex CLI 並還原 OAuth 憑證的 Gitea Composite Action。此 action 以 composite(複合)型態封裝「啟動橫幅 → 安裝 CLI → 解碼寫入 OAuth 憑證」三個步驟,供其他 workflow 以 `uses` 引用;啟動時會輸出 action 名稱/用途/更新時間,方便在 CI 日誌辨識。
---
## 目錄
- [專案列表](#專案列表)
- [功能列表](#功能列表)
- [使用範例](#使用範例)
---
## 專案列表
### 專案描述
| 專案名稱 | 專案描述 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/composite-actions/setup-codex/src/branch/master/) | 安裝 Codex CLI,並將 base64 編碼的 OAuth 憑證解碼寫入 `~/.codex/auth.json` 的 Gitea Composite Action。 |
### 參考專案
| 專案名稱 | 參考專案列表 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/composite-actions/setup-codex/src/branch/master/) | 無 |
### NuGet 套件
| 專案名稱 | NuGet 套件列表 |
| --- | --- |
| [setup-codex](https://gitea.jsc.idv.tw/composite-actions/setup-codex/src/branch/master/) | 無 |
---
## 功能列表
本專案為 Gitea Composite Action,未包含可列入 README 的公開程式方法(public method、public constructor、public extension method、public operator)。以下改以 action 的對外契約與步驟說明呈現,實際呼叫方式請見「[使用範例](#使用範例)」。
### 輸入參數(inputs
| 參數 | 必填 | 預設值 | 說明 |
| --- | --- | --- | --- |
| `oauth` | 是 | 無 | base64 編碼的 OAuth 憑證字串;解碼後寫入 `~/.codex/auth.json`。建議由呼叫端以 `secret` 傳入。 |
### 執行步驟(runs.steps
| 步驟 | 說明 |
| --- | --- |
| `顯示 action 資訊` | 啟動橫幅;輸出 action 名稱、用途與更新時間。 |
| `安裝 Codex CLI` | 以 `npm install -g @openai/codex` 全域安裝 Codex CLI。 |
| `寫入 OAuth 憑證` | 單行完成:建立 `~/.codex` 目錄 → 將 `oauth`base64)解碼寫入 `auth.json``chmod 600`;全程不輸出憑證內容。 |
---
## 使用範例
<a id="使用範例"></a>
在其他 workflow 中引用本 action,並以 `secret` 傳入 base64 OAuth 憑證:
```yaml
jobs:
demo:
runs-on: ubuntu
steps:
- name: 取得原始碼
uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }}
- name: 執行 Setup Codex
uses: https://gitea.jsc.idv.tw/composite-actions/setup-codex@master
with:
oauth: ${{ secrets.CODEX_OAUTH_B64 }}
- name: 使用 Codex CLI
shell: bash
run: codex --version
```
> `oauth` 需為 OAuth 憑證檔內容經 base64 編碼後的字串(例如 `base64 -w0 ~/.codex/auth.json`),action 會解碼還原至 `~/.codex/auth.json`。
執行時 CI 日誌會先出現啟動橫幅:
```text
================================================
Action : Setup Codex
用途 : 安裝 Codex CLI 並還原 OAuth 憑證
更新時間: 2026/07/17 11:54:39
================================================
```