name: 'Codex Issue Response' description: '使用 Codex 產生 Gitea issue 留言回覆' author: 'Jeffery' inputs: gitea_server_url: description: 'Gitea server URL' required: true gitea_repository: description: 'Gitea repository, for example owner/repo' required: true gitea_token: description: 'Gitea Personal Access Token for API authorization' required: true codex_auth_config: description: 'Base64 encoded Codex auth.json' required: true model: description: 'Codex model name' default: 'gpt-5.4-mini' issue_title: description: 'Issue title' required: true issue_body: description: 'Issue body' required: false default: '' issue_number: description: 'Issue number' required: true comment_body: description: 'Issue comment body' required: true outputs: status: description: 'Codex execution result status' value: ${{ steps.codex.outputs.status }} response: description: 'Codex execution result response' value: ${{ steps.codex.outputs.output }} runs: using: 'composite' steps: - name: 建立 Prompt id: prompt env: ISSUE_TITLE: ${{ inputs.issue_title }} ISSUE_BODY: ${{ inputs.issue_body }} COMMENT_BODY: ${{ inputs.comment_body }} run: | shopt -s extglob clean_comment="${COMMENT_BODY//@codex/}" clean_comment="${clean_comment##+([[:space:]])}" clean_comment="${clean_comment%%+([[:space:]])}" if [ -z "$ISSUE_TITLE" ]; then echo 'Issue title is required' >&2 exit 1 fi if [ -z "$ISSUE_BODY" ]; then ISSUE_BODY='(無描述)' fi if [ -z "$clean_comment" ]; then clean_comment='(未提供額外留言)' fi { echo 'prompt<<__PROMPT__' cat <> "$GITHUB_OUTPUT" shell: bash - name: 產生 AI 回覆 id: codex uses: https://gitea.jsc.idv.tw/actions/codex@v0.0.2 with: oauth: ${{ inputs.codex_auth_config }} model: ${{ inputs.model }} prompt: ${{ steps.prompt.outputs.prompt }} - name: 留言 AI 回覆 env: GITEA_REPOSITORY: ${{ inputs.gitea_repository }} GITEA_SERVER_URL: ${{ inputs.gitea_server_url }} GITEA_TOKEN: ${{ inputs.gitea_token }} ISSUE_NUMBER: ${{ inputs.issue_number }} RESPONSE: ${{ steps.codex.outputs.output }} run: | gitea_server_url="${GITEA_SERVER_URL%/}" if [ -z "$gitea_server_url" ]; then echo 'Gitea server URL is required' >&2 exit 1 fi case "$gitea_server_url" in https://gitea.jsc.idv.tw) ;; *) echo "Unsupported Gitea server URL: $gitea_server_url" >&2 exit 1 ;; esac if [ -z "$RESPONSE" ]; then echo 'Codex response is empty' >&2 exit 1 fi comment_payload="$(printf '%s' "$RESPONSE" | jq -Rs '{body: .}')" curl --fail-with-body \ -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ --data "$comment_payload" \ "$gitea_server_url/api/v1/repos/$GITEA_REPOSITORY/issues/$ISSUE_NUMBER/comments" shell: bash