# ============================================================ # 用途:Gitea CI,在 pull request 上執行 AI 程式碼審查(AI code review on pull requests) # 更新日期:2026/06/26 11:34:46 # ============================================================ # workflow 名稱,會顯示在 Gitea Actions 介面上 name: CI # 觸發條件設定 on: # 針對 pull request 事件觸發 pull_request: # 忽略指定目標分支:當 PR 目標分支為 master 時不觸發此 workflow branches-ignore: - master # 觸發的 PR 事件類型:opened(PR 開啟)、synchronize(PR 有新 commit 推送) types: [opened, synchronize] # 定義此 workflow 的 jobs jobs: release-tag-version: name: Release Tag Version runs-on: ubuntu outputs: version: ${{ steps.release-tag-version.outputs.version }} steps: - name: 計算版本號 id: release-tag-version uses: https://gitea.jsc.idv.tw/composite-actions/release-tag-version@${{ vars.ACTION_RELEASE_TAG_VERSION }} with: is_beta: 'true' # job 識別碼:ai-code-review ai-code-review: # job 顯示名稱 name: AI Code Review needs: release-tag-version # 指定執行環境的 runner 標籤:ubuntu runs-on: ubuntu # 此 job 所需的權限設定 permissions: # 對 repository 內容的寫入權限(讀寫程式碼/檔案) contents: write # 對 pull request 的寫入權限(讓 AI 可在 PR 上留言/審查) pull-requests: write # 對 issues 的寫入權限(建立/更新 issue 留言所需) issues: write # job 的執行步驟 steps: - name: 取得程式碼 uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }} - name: 安裝 AI 工具 uses: https://gitea.jsc.idv.tw/docker-actions/antigravity@${{ vars.ACTION_ANTIGRAVITY_VERSION }} - name: 檢查 AI 助理 CLI shell: bash run: | set -e found="" for tool in codex claude opencode; do if command -v "$tool" >/dev/null 2>&1; then found="${found} ${tool}" "$tool" --version || true fi done if [ -z "$found" ]; then echo "找不到可用的 AI 助理 CLI(需要 codex、claude 或 opencode 其中之一)" >&2 exit 1 fi echo "可用 AI 助理 CLI:${found}" - name: AI 程式碼審查 # 使用外部 composite action 執行審查邏輯。 # 版本由 release-tag-version 計算,便於在 PR 中測試目前 action 版本。 uses: https://gitea.jsc.idv.tw/docker-actions/ai-code-review@v${{ needs.release-tag-version.outputs.version }} # 傳遞給 composite action 的輸入參數 with: # 留言用 token:取自 secret COMMENT_TOKEN,供 action 在 PR 上發布審查留言 token: ${{ secrets.TOKEN }} model: ${{ vars.AI_CODE_REVIEW_MODEL }}