feat(codex): 新增 Codex CLI composite action #1

Merged
admin merged 15 commits from ai-review-resolve/develop-20260629-115924 into develop 2026-06-29 06:17:23 +00:00
2 changed files with 47 additions and 2 deletions
Showing only changes of commit 6e771e2e52 - Show all commits
+2 -2
View File
@@ -30,6 +30,6 @@ jobs:
with: with:
oauth: ${{ secrets.CODEX_OAUTH }} oauth: ${{ secrets.CODEX_OAUTH }}
prompt: "請自我介紹" prompt: "請自我介紹"
- name: 檢查登入 - name: 檢查登入帳號
if: ${{ steps.codex.outputs.text == '' }} if: ${{ steps.codex.outputs.email != vars.CODEX_EMAIL }}
run: exit 1 run: exit 1
+45
View File
@@ -13,6 +13,9 @@ outputs:
text: text:
description: '輸出的文字' description: '輸出的文字'
value: ${{ steps.codex.outputs.text }} value: ${{ steps.codex.outputs.text }}
email:
description: '目前登入帳號的電子郵件(由 codex app-server account/read 取得)'
value: ${{ steps.account.outputs.email }}
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
@@ -46,3 +49,45 @@ runs:
echo 'CODEX_OUTPUT' echo 'CODEX_OUTPUT'
} >> "$GITHUB_OUTPUT" } >> "$GITHUB_OUTPUT"
shell: bash shell: bash
- name: 取得登入帳號
id: account
run: |
cat > "$RUNNER_TEMP/codex_account.py" <<'PY'
import json, subprocess, time
p = subprocess.Popen(
["codex", "app-server"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, text=True, bufsize=1,
)
def send(obj):
p.stdin.write(json.dumps(obj) + "\n")
p.stdin.flush()
send({"jsonrpc": "2.0", "id": 1, "method": "initialize",
"params": {"clientInfo": {"name": "ci", "version": "1.0"}}})
send({"jsonrpc": "2.0", "method": "initialized", "params": {}})
send({"jsonrpc": "2.0", "id": 2, "method": "account/read", "params": {}})
email = ""
deadline = time.time() + 25
while time.time() < deadline:
line = p.stdout.readline()
if not line:
break
try:
msg = json.loads(line)
except Exception:
continue
if msg.get("id") == 2:
account = (msg.get("result") or {}).get("account") or {}
email = account.get("email") or ""
break
p.terminate()
print(email)
PY
email="$(python3 "$RUNNER_TEMP/codex_account.py")"
printf 'email=%s\n' "$email" >> "$GITHUB_OUTPUT"
shell: bash