feat(Codex CLI): 新增 Codex CLI Docker Action

This commit is contained in:
2026-06-24 10:25:41 +00:00
parent d33f6ddecf
commit a8fd459117
3 changed files with 52 additions and 19 deletions
+19 -3
View File
@@ -1,10 +1,26 @@
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
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
+15 -11
View File
@@ -1,20 +1,24 @@
name: 'Docker Action Template'
description: 'Docker Action 範本'
name: 'Codex CLI'
description: 'Codex CLI Action'
author: 'Jeffery'
inputs:
runner_token:
description: 'Gitea Runner Token'
oauth:
description: 'Base64 encoded Codex auth.json'
required: true
text:
description: '輸入的文字'
default: "Hello, World!"
model:
description: 'Codex model name'
required: true
prompt:
description: 'Prompt for codex exec'
required: false
default: '請自我介紹'
outputs:
text:
description: '輸出的文字'
description: 'Execution result status'
runs:
using: 'docker'
image: 'Dockerfile'
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
RUNNER_TOKEN: ${{ inputs.runner_token || secrets.GITEA_TOKEN || secrets.RUNNER_TOKEN }}
OAUTH: ${{ inputs.oauth }}
MODEL: ${{ inputs.model }}
PROMPT: ${{ inputs.prompt }}
+18 -5
View File
@@ -1,11 +1,24 @@
#!/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