chore(Docker action): 整理 Docker action 執行設定
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
|||||||
id: release-tag-version
|
id: release-tag-version
|
||||||
uses: https://gitea.jsc.idv.tw/composite-actions/release-tag-version@${{ vars.ACTION_RELEASE_TAG_VERSION }}
|
uses: https://gitea.jsc.idv.tw/composite-actions/release-tag-version@${{ vars.ACTION_RELEASE_TAG_VERSION }}
|
||||||
with:
|
with:
|
||||||
is_beta: 'true'
|
is_beta: true
|
||||||
# job 識別碼:ai-code-review
|
# job 識別碼:ai-code-review
|
||||||
ai-code-review:
|
ai-code-review:
|
||||||
# job 顯示名稱
|
# job 顯示名稱
|
||||||
@@ -34,6 +34,14 @@ jobs:
|
|||||||
needs: release-tag-version
|
needs: release-tag-version
|
||||||
# 指定執行環境的 runner 標籤:ubuntu
|
# 指定執行環境的 runner 標籤:ubuntu
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
|
# job 的執行步驟
|
||||||
|
steps:
|
||||||
|
- name: 取得程式碼
|
||||||
|
uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }}
|
||||||
|
- 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 }}
|
||||||
# 此 job 所需的權限設定
|
# 此 job 所需的權限設定
|
||||||
permissions:
|
permissions:
|
||||||
# 對 repository 內容的寫入權限(讀寫程式碼/檔案)
|
# 對 repository 內容的寫入權限(讀寫程式碼/檔案)
|
||||||
@@ -42,35 +50,6 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
# 對 issues 的寫入權限(建立/更新 issue 留言所需)
|
# 對 issues 的寫入權限(建立/更新 issue 留言所需)
|
||||||
issues: write
|
issues: write
|
||||||
# job 的執行步驟
|
|
||||||
steps:
|
|
||||||
- name: 取得程式碼
|
|
||||||
uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }}
|
|
||||||
- name: 安裝 AI 工具
|
|
||||||
uses: https://gitea.jsc.idv.tw/composite-actions/codex@${{ vars.ACTION_CODEX_VERSION }}
|
|
||||||
with:
|
|
||||||
oauth: ${{ secrets.CODEX_OAUTH }}
|
|
||||||
- name: 檢查 AI 助理 CLI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
tools="$(node --input-type=module -e "import { getLLMCLICommands } from './app/config.js'; console.log(getLLMCLICommands().join(' '));")"
|
|
||||||
found=""
|
|
||||||
for tool in $tools; 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(需要 ${tools} 其中之一)" >&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 的輸入參數
|
# 傳遞給 composite action 的輸入參數
|
||||||
with:
|
with:
|
||||||
# 留言用 token:取自 secret COMMENT_TOKEN,供 action 在 PR 上發布審查留言
|
# 留言用 token:取自 secret COMMENT_TOKEN,供 action 在 PR 上發布審查留言
|
||||||
|
|||||||
+6
-26
@@ -1,34 +1,14 @@
|
|||||||
# =============================================================================
|
FROM codex:latest
|
||||||
# 用途:建置「AI 程式碼審查」Docker action 映像檔。
|
|
||||||
# 以 Alpine Linux 為基底,安裝 bash / git / Node.js / npm 等執行環境,
|
|
||||||
# 將 app/ 程式碼與相依套件打包進映像,並透過 entrypoint.sh 作為容器進入點,
|
|
||||||
# 供 CI(Gitea Actions)以 Docker action 形式執行 AI code review 流程。
|
|
||||||
# 更新日期:2026/06/26 11:34:46
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
# 指定支援中的 Alpine Linux 固定版本;Alpine 體積小,可縮小最終映像大小並加快拉取速度。
|
RUN apt update \
|
||||||
# 釘選明確版本可避免 latest tag 隨時間變動,提升建置可重現性。
|
&& apt install -y --no-install-recommends git
|
||||||
FROM alpine:3.24.1
|
&& apt clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*s
|
||||||
|
|
||||||
# 安裝必要的工具
|
|
||||||
# 安裝執行 code review 所需的工具:bash(執行 entrypoint 腳本)、git(前置遠端驗證/取得 diff)、
|
|
||||||
# nodejs 與 npm(執行 app 內的 Node.js 程式)。
|
|
||||||
# --no-cache:不保留 apk 套件索引快取,避免殘留在映像層中以減少映像大小。
|
|
||||||
RUN apk add --no-cache bash git nodejs npm
|
|
||||||
|
|
||||||
# 將專案的 app/ 目錄複製到映像內的 /app;包含 Node.js 程式碼與 package.json 等相依宣告。
|
|
||||||
COPY ./app /app
|
COPY ./app /app
|
||||||
|
|
||||||
# 進入 /app 安裝 npm 相依套件,使 Node.js 程式可在容器內正常執行。
|
|
||||||
# 副作用:會在 /app/node_modules 產生套件檔案,並依 package-lock.json(若存在)解析版本。
|
|
||||||
RUN cd /app && npm install
|
RUN cd /app && npm install
|
||||||
|
|
||||||
# 將容器進入點腳本 entrypoint.sh 複製到映像根目錄 /entrypoint.sh。
|
COPY ./entrypoint.sh /entrypoint.sh
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
# 賦予 entrypoint.sh 可執行權限,確保容器啟動時能直接執行該腳本。
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
# 設定容器進入點為 /entrypoint.sh(exec 形式,不經過 shell 解析);
|
|
||||||
# 容器啟動時即執行此腳本,作為 Docker action 的實際入口。
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
+4
-15
@@ -4,23 +4,16 @@ author: 'Jeffery'
|
|||||||
inputs:
|
inputs:
|
||||||
token:
|
token:
|
||||||
description: ''
|
description: ''
|
||||||
required: true
|
required: false
|
||||||
comment_token:
|
comment_token:
|
||||||
description: ''
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
model:
|
model:
|
||||||
description: ''
|
description: '要使用的 AI 助理 CLI 模型識別字串'
|
||||||
required: true
|
required: true
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'docker'
|
||||||
steps:
|
image: 'Dockerfile'
|
||||||
- name: 安裝 Node.js 相依套件
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd "${GITHUB_ACTION_PATH:-${GITEA_ACTION_PATH:-.}}/app"
|
|
||||||
npm ci
|
|
||||||
- name: 執行 AI 程式碼審查
|
|
||||||
shell: bash
|
|
||||||
env:
|
env:
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
@@ -31,7 +24,3 @@ runs:
|
|||||||
PR_HEAD_BRANCH: ${{ gitea.event.pull_request.head.ref }}
|
PR_HEAD_BRANCH: ${{ gitea.event.pull_request.head.ref }}
|
||||||
PR_BASE_BRANCH: ${{ gitea.event.pull_request.base.ref }}
|
PR_BASE_BRANCH: ${{ gitea.event.pull_request.base.ref }}
|
||||||
MODEL: ${{ inputs.model }}
|
MODEL: ${{ inputs.model }}
|
||||||
run: |
|
|
||||||
echo "🚀 AI Code Review Action 啟動"
|
|
||||||
cd "${GITHUB_ACTION_PATH:-${GITEA_ACTION_PATH:-.}}/app"
|
|
||||||
node main.js
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ai-code-review",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "AI code review Gitea action",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"test": "npm --prefix app test"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://gitea.jsc.idv.tw/docker-actions/ai-code-review.git"
|
|
||||||
},
|
|
||||||
"author": "Jeffery",
|
|
||||||
"license": "ISC"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user