From d8ec02250c3dff51e7d69ea2f390b5edce4c3819 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 29 Jun 2026 11:59:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(codex):=20=E6=96=B0=E5=A2=9E=E5=AE=89?= =?UTF-8?q?=E8=A3=9D=20Codex=20CLI=E3=80=81=E5=AF=AB=E5=85=A5=20OAuth=20to?= =?UTF-8?q?ken=20=E4=B8=A6=E5=9F=B7=E8=A1=8C=E6=8F=90=E7=A4=BA=E8=A9=9E?= =?UTF-8?q?=E7=9A=84=20composite=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 55 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/action.yml b/action.yml index 646c3c6..457fc47 100644 --- a/action.yml +++ b/action.yml @@ -1,33 +1,48 @@ -name: 'Composite Action Template' -description: 'Composite Action 範本' +name: 'Codex CLI' +description: 'Codex CLI 工具' author: 'Jeffery' inputs: - text: - description: '輸入的文字' + prompt: + description: '傳給 Codex CLI 的提示詞' required: false - default: 'Hello, World!' + default: "請自我介紹" + oauth: + description: 'base64 編碼的 Codex OAuth token 檔案內容' + required: true outputs: text: description: '輸出的文字' - value: ${{ steps.change.outputs.text }} + value: ${{ steps.codex.outputs.text }} runs: using: 'composite' steps: - - name: 交換 - id: change + - name: 安裝工具 env: - GITEA_SERVER_URL: ${{ gitea.server_url }} - GITEA_REPOSITORY: ${{ gitea.repository }} - GITEA_TOKEN: ${{ gitea.token }} - TEXT: ${{ inputs.text }} + OAUTH: ${{ inputs.oauth }} run: | - echo "Gitea Server Url: $GITEA_SERVER_URL" + npm install -g @openai/codex - echo "Gitea Repository: $GITEA_REPOSITORY" + 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 - echo "Gitea Token: $GITEA_TOKEN" - - echo "Text: $TEXT" - - echo "text=$TEXT" >> "$GITHUB_OUTPUT" - shell: bash \ No newline at end of file + text="$(codex exec --model "$MODEL" "$PROMPT")" + printf '%s\n' "$text" + { + echo 'text<> "$GITHUB_OUTPUT" + shell: bash