feat(codex): 新增 Codex CLI composite action #1
+35
-20
@@ -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
|
||||
text="$(codex exec --model "$MODEL" "$PROMPT")"
|
||||
printf '%s\n' "$text"
|
||||
{
|
||||
echo 'text<<CODEX_OUTPUT'
|
||||
printf '%s\n' "$text"
|
||||
echo 'CODEX_OUTPUT'
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user