Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 69624a542e | |||
| 8aa273b8bd | |||
| 00458d4eb2 |
+5
-5
@@ -1,9 +1,9 @@
|
|||||||
FROM node:20-slim
|
FROM alpine
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apk add --no-cache bash nodejs npm git \
|
||||||
apt-get install -y --no-install-recommends git && \
|
&& node --version \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
&& npm --version \
|
||||||
git --version
|
&& git --version
|
||||||
|
|
||||||
WORKDIR /action
|
WORKDIR /action
|
||||||
|
|
||||||
|
|||||||
+34
-17
@@ -15,24 +15,41 @@ export async function commitAndPush(workspace) {
|
|||||||
.replace('https://', `https://${GITEA_TOKEN}@`)
|
.replace('https://', `https://${GITEA_TOKEN}@`)
|
||||||
.replace('http://', `http://${GITEA_TOKEN}@`) + `/${GITEA_REPOSITORY}.git`;
|
.replace('http://', `http://${GITEA_TOKEN}@`) + `/${GITEA_REPOSITORY}.git`;
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
git(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
// git(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
||||||
git(['config', 'user.name', 'AI Review Bot'], repoDir);
|
// git(['config', 'user.name', 'AI Review Bot'], repoDir);
|
||||||
git(['fetch', 'origin', PR_HEAD_BRANCH], repoDir);
|
// git(['fetch', 'origin', PR_HEAD_BRANCH], repoDir);
|
||||||
git(['checkout', PR_HEAD_BRANCH], repoDir);
|
// git(['checkout', PR_HEAD_BRANCH], repoDir);
|
||||||
git(['add', FINDINGS_PATH], repoDir);
|
// git(['add', FINDINGS_PATH], repoDir);
|
||||||
|
|
||||||
const status = git(['status', '--porcelain'], repoDir);
|
// const status = git(['status', '--porcelain'], repoDir);
|
||||||
if (!status) {
|
// if (!status) {
|
||||||
console.log(' findings.json 無變更,跳過 commit');
|
// console.log(' findings.json 無變更,跳過 commit');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const out = git(['commit', '-m', 'chore: update ai-review findings [skip ci]'], repoDir);
|
// const out = git(['commit', '-m', 'chore: update ai-review findings [skip ci]'], repoDir);
|
||||||
const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
|
// const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
|
||||||
git(['push', remoteUrl, PR_HEAD_BRANCH], repoDir);
|
// git(['push', remoteUrl, PR_HEAD_BRANCH], repoDir);
|
||||||
console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH}`);
|
// console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH}`);
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
|
// console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
|
||||||
|
// }
|
||||||
|
|
||||||
|
git(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
||||||
|
git(['config', 'user.name', 'AI Review Bot'], repoDir);
|
||||||
|
git(['fetch', 'origin', PR_HEAD_BRANCH], repoDir);
|
||||||
|
git(['checkout', PR_HEAD_BRANCH], repoDir);
|
||||||
|
git(['add', FINDINGS_PATH], repoDir);
|
||||||
|
|
||||||
|
const status = git(['status', '--porcelain'], repoDir);
|
||||||
|
if (!status) {
|
||||||
|
console.log(' findings.json 無變更,跳過 commit');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const out = git(['commit', '-m', 'chore: update ai-review findings [skip ci]'], repoDir);
|
||||||
|
const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
|
||||||
|
git(['push', remoteUrl, PR_HEAD_BRANCH], repoDir);
|
||||||
|
console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user