Files
codex/action.yml
T
Jeffery 7ee6921c63
CI / Release Tag Version (pull_request) Successful in 3s
CI / Codex (pull_request) Successful in 20s
fix(codex): 改以 codex exec 真實往返驗證登入,移除直接解析 OAuth token
不再解析 auth.json 的 id_token 來取得 email(只證明 secret 解得開、
無法確保工具真的登入成功)。改為透過 codex exec 實際呼叫模型:登入無效
或 token 過期時 codex exec 會直接失敗,CI 再以 steps.codex.outputs.text
是否為空做最終把關。action 移除 email output,保留 -s danger-full-access
以避免 runner 容器內 bubblewrap 沙箱失敗。
2026-06-29 12:35:35 +08:00

49 lines
1.2 KiB
YAML

name: 'Codex CLI'
description: 'Codex CLI 工具'
author: 'Jeffery'
inputs:
prompt:
description: '傳給 Codex CLI 的提示詞'
required: false
default: "請自我介紹"
oauth:
description: 'base64 編碼的 Codex OAuth token 檔案內容'
required: true
outputs:
text:
description: '輸出的文字'
value: ${{ steps.codex.outputs.text }}
runs:
using: 'composite'
steps:
- name: 安裝工具
env:
OAUTH: ${{ inputs.oauth }}
run: |
npm install -g @openai/codex
oauth_file="$HOME/.codex/auth.json"
install -d -m 700 "$(dirname "$oauth_file")"
printf '%s' "$OAUTH" | base64 -d > "$oauth_file"
chmod 600 "$oauth_file"
shell: bash
- name: 執行工具
id: codex
env:
MODEL: ${{ vars.CODEX_MODEL }}
PROMPT: ${{ inputs.prompt }}
run: |
if [ -z "$MODEL" ]; then
echo 'CODEX_MODEL repository variable is required.' >&2
exit 1
fi
text="$(codex exec --skip-git-repo-check -s danger-full-access --model "$MODEL" "$PROMPT")"
printf '%s\n' "$text"
{
echo 'text<<CODEX_OUTPUT'
printf '%s\n' "$text"
echo 'CODEX_OUTPUT'
} >> "$GITHUB_OUTPUT"
shell: bash