feat(codex-response): 整合 Codex issue 回覆 action

This commit is contained in:
2026-06-24 15:46:49 +00:00
parent f0c56a0616
commit 0d2df8256e
2 changed files with 103 additions and 74 deletions
+33 -41
View File
@@ -1,51 +1,43 @@
name: AI Response
on:
issue_comment:
types:
- created
jobs:
version:
name: 計算版本號
runs-on: ubuntu
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: 計算版本號
id: version
uses: https://gitea.jsc.idv.tw/actions/calculate-version@${{ vars.ACTION_CALCULATE_VERSION }}
with:
IS_BETA: true
- name: 標註版本號
uses: akkuman/gitea-release-action@${{ vars.ACTION_RELEASE_VERSION }}
with:
name: codex v${{ steps.version.outputs.version }}
tag_name: v${{ steps.version.outputs.version }}
target_commitish: ${{ github.head_ref }}
response:
name: 回覆問題留言
runs-on: ubuntu
if: ${{ contains(github.event.comment.body, '@opencode') }}
needs: [version]
if: ${{ contains(github.event.comment.body, '@codex') }}
steps:
- name: 安裝 OpenCode
run: npm install -g opencode-ai
- name: 產生 AI 回覆
env:
COMMENT_BODY: ${{ github.event.comment.body }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_TITLE: ${{ github.event.issue.title }}
NO_COLOR: "1"
TERM: dumb
run: |
clean_comment="$(printf '%s' "$COMMENT_BODY" | sed -E 's/@opencode[[:space:]]*//g')"
{
printf '請根據以下 Gitea issue 資訊,以繁體中文回覆使用者。\n'
printf '請只輸出要張貼到 issue 留言中的內容,不要包含額外前言。\n\n'
printf '## 問題標題\n%s\n\n' "$ISSUE_TITLE"
printf '## 問題描述\n%s\n\n' "$ISSUE_BODY"
printf '## 使用者留言\n%s\n' "$clean_comment"
} > prompt.md
opencode run --agent plan "$(cat prompt.md)" > response.md
- name: 留言到問題
env:
GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
RUNNER_TOKEN: ${{ secrets.RUNNER_TOKEN }}
run: |
jq -n --rawfile body response.md '{body: $body}' > comment.json
curl --fail-with-body \
-X POST \
-H "Authorization: token $RUNNER_TOKEN" \
-H "Content-Type: application/json" \
--data @comment.json \
"$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY/issues/$ISSUE_NUMBER/comments"
- name: 取得專案
uses: actions/checkout@v6
- name: 產生並留言 AI 回覆
uses: https://gitea.jsc.idv.tw/actions/codex-response@v${{ needs.version.outputs.version }}
with:
gitea_server_url: ${{ gitea.server_url }}
gitea_repository: ${{ gitea.repository }}
gitea_token: ${{ secrets.GITEA_TOKEN }}
oauth: ${{ secrets.CODEX_OAUTH }}
model: gpt-5.4-mini
issue_title: ${{ github.event.issue.title }}
issue_body: ${{ github.event.issue.body }}
issue_number: ${{ github.event.issue.number }}
comment_body: ${{ github.event.comment.body }}