Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 607c9b82ea | |||
| 8acea007e7 | |||
| 953951145f | |||
| 1576e783fb | |||
| e017705c64 | |||
| 5f77b83a0f | |||
| da43cb02b0 | |||
| 577a930438 | |||
| 121f66b0b3 | |||
| faa808bb5f | |||
| 07df3ef4a5 | |||
| fc537958ca |
@@ -29,5 +29,4 @@
|
|||||||
|
|
||||||
每個階段都會加上明確的 log,並確保即使部分功能未完成也能降級執行、不會中斷 pipeline。
|
每個階段都會加上明確的 log,並確保即使部分功能未完成也能降級執行、不會中斷 pipeline。
|
||||||
|
|
||||||
每次執行後請貼 log,我會協助 debug。
|
每次執行後請貼 log,我會協助 debug。
|
||||||
|
|
||||||
+3
-1
@@ -10,6 +10,7 @@ export async function commitAndPush(workspace) {
|
|||||||
try {
|
try {
|
||||||
const fullPath = path.join(workspace, FINDINGS_PATH);
|
const fullPath = path.join(workspace, FINDINGS_PATH);
|
||||||
const content = fs.readFileSync(fullPath, 'utf8');
|
const content = fs.readFileSync(fullPath, 'utf8');
|
||||||
|
console.log(` [debug] FINDINGS_PATH=${FINDINGS_PATH} branch=${process.env.PR_HEAD_BRANCH} token=${process.env.GITEA_TOKEN ? '***' : 'EMPTY'}`);
|
||||||
const result = await commitFile(
|
const result = await commitFile(
|
||||||
FINDINGS_PATH,
|
FINDINGS_PATH,
|
||||||
content,
|
content,
|
||||||
@@ -18,6 +19,7 @@ export async function commitAndPush(workspace) {
|
|||||||
const commitHash = result.commit?.sha?.slice(0, 7) || 'unknown';
|
const commitHash = result.commit?.sha?.slice(0, 7) || 'unknown';
|
||||||
console.log(` ✅ persisted findings commit=${commitHash} push=${process.env.PR_HEAD_BRANCH}`);
|
console.log(` ✅ persisted findings commit=${commitHash} push=${process.env.PR_HEAD_BRANCH}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
|
const detail = e.response?.data ? JSON.stringify(e.response.data) : e.message;
|
||||||
|
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.response?.status || ''} ${detail}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-3
@@ -28,7 +28,9 @@ export async function commitFile(filePath, content, message) {
|
|||||||
try {
|
try {
|
||||||
const existing = await axios.get(`${url}?ref=${PR_HEAD_BRANCH}`, { headers: headers(), httpsAgent, timeout: 15000 });
|
const existing = await axios.get(`${url}?ref=${PR_HEAD_BRANCH}`, { headers: headers(), httpsAgent, timeout: 15000 });
|
||||||
sha = existing.data.sha;
|
sha = existing.data.sha;
|
||||||
} catch {
|
console.log(` [debug] 取得現有檔案 SHA=${sha}`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(` [debug] 檔案不存在,將建立新檔案: ${e.response?.status || e.message}`);
|
||||||
sha = undefined;
|
sha = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,13 +41,15 @@ export async function commitFile(filePath, content, message) {
|
|||||||
...(sha ? { sha } : {}),
|
...(sha ? { sha } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(` [debug] ${sha ? 'PUT' : 'POST'} ${url} branch=${PR_HEAD_BRANCH} content_len=${encoded.length}`);
|
||||||
const resp = await axios.request({
|
const resp = await axios.request({
|
||||||
method: sha ? 'put' : 'post',
|
method: sha ? 'put' : 'post',
|
||||||
url,
|
url,
|
||||||
headers: headers(),
|
headers: { ...headers(), 'Content-Type': 'application/json' },
|
||||||
httpsAgent,
|
httpsAgent,
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
data: payload,
|
data: JSON.stringify(payload),
|
||||||
});
|
});
|
||||||
|
console.log(` [debug] response status=${resp.status}`);
|
||||||
return resp.data;
|
return resp.data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user