feat(Codex CLI): 新增 Codex CLI Docker Action
This commit is contained in:
+17
-1
@@ -1,7 +1,23 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
# 安裝必要的工具
|
# 安裝必要的工具
|
||||||
RUN apk add --no-cache --no-check-certificate bash
|
RUN apk add --no-cache --no-check-certificate bash ca-certificates curl git
|
||||||
|
|
||||||
|
# 設定安裝用的環境變數
|
||||||
|
ENV CODEX_NON_INTERACTIVE=1
|
||||||
|
ENV CODEX_INSTALL_DIR=/usr/local/bin
|
||||||
|
ENV CODEX_HOME=/root/.codex
|
||||||
|
|
||||||
|
# 安裝 Codex CLI 工具
|
||||||
|
RUN curl -fsSL https://chatgpt.com/codex/install.sh | sh
|
||||||
|
|
||||||
|
# 安裝 doc 技能
|
||||||
|
RUN codex plugin marketplace add https://gitea.jsc.idv.tw/plugins/doc.git \
|
||||||
|
&& codex plugin add jsc@doc
|
||||||
|
|
||||||
|
# 安裝 code-review 技能
|
||||||
|
RUN codex plugin marketplace add https://gitea.jsc.idv.tw/plugins/code-review.git \
|
||||||
|
&& codex plugin add jsc@code-review
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
+15
-11
@@ -1,20 +1,24 @@
|
|||||||
name: 'Docker Action Template'
|
name: 'Codex CLI'
|
||||||
description: 'Docker Action 範本'
|
description: 'Codex CLI Action'
|
||||||
author: 'Jeffery'
|
author: 'Jeffery'
|
||||||
inputs:
|
inputs:
|
||||||
runner_token:
|
oauth:
|
||||||
description: 'Gitea Runner Token'
|
description: 'Base64 encoded Codex auth.json'
|
||||||
required: true
|
required: true
|
||||||
text:
|
model:
|
||||||
description: '輸入的文字'
|
description: 'Codex model name'
|
||||||
default: "Hello, World!"
|
required: true
|
||||||
|
prompt:
|
||||||
|
description: 'Prompt for codex exec'
|
||||||
|
required: false
|
||||||
|
default: '請自我介紹'
|
||||||
outputs:
|
outputs:
|
||||||
text:
|
text:
|
||||||
description: '輸出的文字'
|
description: 'Execution result status'
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
env:
|
env:
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
OAUTH: ${{ inputs.oauth }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
MODEL: ${{ inputs.model }}
|
||||||
RUNNER_TOKEN: ${{ inputs.runner_token || secrets.GITEA_TOKEN || secrets.RUNNER_TOKEN }}
|
PROMPT: ${{ inputs.prompt }}
|
||||||
|
|||||||
+18
-5
@@ -1,11 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Gitea Server Url: $GITEA_SERVER_URL"
|
set -euo pipefail
|
||||||
|
|
||||||
echo "Gitea Repository: $GITEA_REPOSITORY"
|
if [[ -z "${OAUTH:-}" ]]; then
|
||||||
|
echo "OAUTH is required: provide base64 encoded Codex auth.json." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Gitea Runner Token: $RUNNER_TOKEN"
|
if [[ -z "${MODEL:-}" ]]; then
|
||||||
|
echo "MODEL is required." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Input Text: $INPUT_TEXT"
|
CODEX_HOME="${CODEX_HOME:-/root/.codex}"
|
||||||
|
mkdir -p "$CODEX_HOME"
|
||||||
|
printf '%s' "$OAUTH" | base64 -d > "$CODEX_HOME/auth.json"
|
||||||
|
chmod 600 "$CODEX_HOME/auth.json"
|
||||||
|
|
||||||
echo "text=$INPUT_TEXT" >> "$GITHUB_OUTPUT"
|
codex exec --dangerously-bypass-approvals-and-sandbox --model "$MODEL" "$PROMPT"
|
||||||
|
|
||||||
|
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
||||||
|
echo "text=completed" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user