diff --git a/scripts/git-incremental-deploy-macos.mjs b/scripts/git-incremental-deploy-macos.mjs index 0e0e5539..2d88dc3b 100755 --- a/scripts/git-incremental-deploy-macos.mjs +++ b/scripts/git-incremental-deploy-macos.mjs @@ -38,6 +38,7 @@ const USAGE = `gongxiangp2 Mac 部署入口 --dry-run 仅执行源码、SSH、Registry 与生产连通性预检 --no-cache 不使用 Docker 构建缓存 --reuse-verified-image 复用已经校验的精确提交镜像 + --skip-deploy 仅构建并推送精确提交镜像,不连接生产机或切换流量 --keep-old-images 不清理旧 Docker 镜像 --aggressive-cache-cleanup 清理超过 7 天的构建缓存 --no-rollback 禁用失败后的旧镜像自动恢复 @@ -67,6 +68,7 @@ export function parseArguments(argv) { dryRun: false, noCache: false, reuseVerifiedImage: false, + skipDeploy: false, keepOldImages: false, aggressiveCleanup: false, noRollback: false, @@ -85,6 +87,7 @@ export function parseArguments(argv) { case '--dry-run': options.dryRun = true; break case '--no-cache': options.noCache = true; break case '--reuse-verified-image': options.reuseVerifiedImage = true; break + case '--skip-deploy': options.skipDeploy = true; break case '--keep-old-images': options.keepOldImages = true; break case '--aggressive-cache-cleanup': options.aggressiveCleanup = true; break case '--no-rollback': options.noRollback = true; break @@ -101,6 +104,9 @@ export function parseArguments(argv) { if (options.reuseVerifiedImage && options.noCache) { throw new Error('--reuse-verified-image 不能与 --no-cache 同时使用') } + if (options.reuseVerifiedImage && options.skipDeploy) { + throw new Error('--reuse-verified-image 不能与 --skip-deploy 同时使用') + } return options } @@ -358,7 +364,7 @@ async function main() { __SKIP_BUILD__: '0', __SKIP_PUSH__: '0', __REUSE_VERIFIED_IMAGE__: options.reuseVerifiedImage ? '1' : '0', - __SKIP_DEPLOY__: '0', + __SKIP_DEPLOY__: options.skipDeploy ? '1' : '0', __KEEP_OLD_IMAGES__: options.keepOldImages ? '1' : '0', __AGGRESSIVE_CLEANUP__: options.aggressiveCleanup ? '1' : '0', __ROLLBACK_ON_FAILURE__: options.noRollback ? '0' : '1', diff --git a/scripts/git-incremental-deploy.test.mjs b/scripts/git-incremental-deploy.test.mjs index 07fca79e..cff32041 100644 --- a/scripts/git-incremental-deploy.test.mjs +++ b/scripts/git-incremental-deploy.test.mjs @@ -39,6 +39,11 @@ test('Mac entry requires an exact commit outside DryRun', () => { assert.throws(() => parseArguments(['--commit', 'abc']), /40 位小写/) assert.equal(parseArguments(['--dry-run']).dryRun, true) assert.equal(parseArguments(['--commit', 'b'.repeat(40)]).commit, 'b'.repeat(40)) + assert.equal(parseArguments(['--commit', 'b'.repeat(40), '--skip-deploy']).skipDeploy, true) + assert.throws( + () => parseArguments(['--commit', 'b'.repeat(40), '--reuse-verified-image', '--skip-deploy']), + /不能与 --skip-deploy/, + ) }) test('deployment SSH hops keep long builds and cutovers alive', () => {