Files
codex/action.yml
T
jiantw83 4077596fcc
CI / Release Tag Version (pull_request) Successful in 3s
CI / Codex (pull_request) Failing after 23s
refactor(codex): move email validation into main execution step and remove redundant check
2026-06-29 05:58:47 +00:00

66 lines
1.8 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: |
if [ -z "$OAUTH" ]; then
echo 'oauth input (secrets.CODEX_OAUTH) is required and must not be empty.' >&2
exit 1
fi
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 }}
EXPECTED_EMAIL: ${{ vars.CODEX_EMAIL }}
PROMPT: ${{ inputs.prompt }}
run: |
if [ -z "$MODEL" ]; then
echo 'CODEX_MODEL repository variable is required.' >&2
exit 1
fi
if [ -z "$EXPECTED_EMAIL" ]; then
echo 'CODEX_EMAIL repository variable is required.' >&2
exit 1
fi
if [ -z "$PROMPT" ]; then
email="$(python3 "$GITHUB_ACTION_PATH/app/codex_account.py")"
echo "text=$email" >> "$GITHUB_OUTPUT"
exit 0
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
- name: 檢查輸出
if: ${{ steps.codex.outputs.text != vars.ANTIGRAVITY_EMAIL }}
run: exit 1