docs(codex): 補齊 function docstring 與指令檔註解並重建 README #4
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user