refactor(calculate-version): 將版本計算邏輯由 bash 改寫為 Node.js 並依功能分檔
保留 entrypoint.sh 作為容器進入點,改為啟動 app/ 下的 Node.js 程式; 依功能拆分為 logger/config/version/releases/output/index,並更新 Dockerfile 改用 node:lts-alpine。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4983a72524
commit
bd6b6017ab
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
|
||||
/**
|
||||
* 將一行 `name=value` 附加寫入 GitHub/Gitea Action 的輸出檔。
|
||||
*
|
||||
* @param {string} name - 輸出變數名稱(output 的 key)。
|
||||
* @param {string} value - 輸出變數的值(output 的 value)。
|
||||
* @param {string} [file=process.env.GITHUB_OUTPUT] - 輸出檔路徑,預設取自環境變數 `GITHUB_OUTPUT`。
|
||||
* @throws {Error} 當輸出檔路徑為 falsy(例如 `GITHUB_OUTPUT` 未設定)時拋出,無法寫入輸出。
|
||||
* @returns {void}
|
||||
*/
|
||||
function writeOutput(name, value, file = process.env.GITHUB_OUTPUT) {
|
||||
if (!file) {
|
||||
throw new Error('GITHUB_OUTPUT 未設定,無法寫入輸出');
|
||||
}
|
||||
|
||||
fs.appendFileSync(file, `${name}=${value}\n`);
|
||||
}
|
||||
|
||||
module.exports = { writeOutput };
|
||||
Reference in New Issue
Block a user