@turboops/cli 1.0.0-dev.612 → 1.0.0-dev.613
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +54 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2248,6 +2248,7 @@ PIPELINE-STRUKTUR:
|
|
|
2248
2248
|
- if: $CI_COMMIT_BRANCH # L\xE4uft auf ALLEN Branches!
|
|
2249
2249
|
|
|
2250
2250
|
2. DEPLOY-JOBS (jeder NUR auf seinem Branch!):
|
|
2251
|
+
WICHTIG: KEIN --image Flag n\xF6tig! Die CLI erkennt CI_COMMIT_SHA automatisch!
|
|
2251
2252
|
|
|
2252
2253
|
deploy-dev:
|
|
2253
2254
|
image: node:20-alpine
|
|
@@ -2255,21 +2256,21 @@ PIPELINE-STRUKTUR:
|
|
|
2255
2256
|
- npm install -g @turboops/cli
|
|
2256
2257
|
- turbo config set token \${TURBOOPS_TOKEN}
|
|
2257
2258
|
script:
|
|
2258
|
-
- turbo deploy dev --
|
|
2259
|
+
- turbo deploy dev --wait # CLI erkennt Image automatisch via CI_COMMIT_SHA
|
|
2259
2260
|
rules:
|
|
2260
2261
|
- if: $CI_COMMIT_BRANCH == "dev" # NUR auf dev Branch!
|
|
2261
2262
|
needs: [build]
|
|
2262
2263
|
|
|
2263
2264
|
deploy-test:
|
|
2264
2265
|
script:
|
|
2265
|
-
- turbo deploy test --wait
|
|
2266
|
+
- turbo deploy test --wait
|
|
2266
2267
|
rules:
|
|
2267
2268
|
- if: $CI_COMMIT_BRANCH == "test" # NUR auf test Branch!
|
|
2268
2269
|
needs: [deploy-dev]
|
|
2269
2270
|
|
|
2270
2271
|
deploy-prod:
|
|
2271
2272
|
script:
|
|
2272
|
-
- turbo deploy prod --wait
|
|
2273
|
+
- turbo deploy prod --wait
|
|
2273
2274
|
rules:
|
|
2274
2275
|
- if: $CI_COMMIT_BRANCH == "main" # NUR auf main Branch!
|
|
2275
2276
|
when: manual
|
|
@@ -2278,7 +2279,7 @@ PIPELINE-STRUKTUR:
|
|
|
2278
2279
|
WICHTIG:
|
|
2279
2280
|
- Der Build l\xE4uft auf ALLEN Branches (dev, test, main)
|
|
2280
2281
|
- Jeder Deploy-Job l\xE4uft NUR auf seinem zugeordneten Branch
|
|
2281
|
-
- --image
|
|
2282
|
+
- KEIN --image Flag n\xF6tig - CLI erkennt CI_COMMIT_SHA/GITHUB_SHA automatisch
|
|
2282
2283
|
- Registry-URL: registry.turbo-ops.de/${projectSlug}
|
|
2283
2284
|
- Secrets ben\xF6tigt: TURBOOPS_TOKEN
|
|
2284
2285
|
|
|
@@ -2302,17 +2303,58 @@ Erstelle die Datei "${pipelineFile}".`;
|
|
|
2302
2303
|
// src/commands/deploy.ts
|
|
2303
2304
|
import { Command as Command4 } from "commander";
|
|
2304
2305
|
import chalk6 from "chalk";
|
|
2305
|
-
var
|
|
2306
|
+
var REGISTRY_URL = "registry.turbo-ops.de";
|
|
2307
|
+
function detectCiCommitSha() {
|
|
2308
|
+
if (process.env.CI_COMMIT_SHA) {
|
|
2309
|
+
return process.env.CI_COMMIT_SHA;
|
|
2310
|
+
}
|
|
2311
|
+
if (process.env.GITHUB_SHA) {
|
|
2312
|
+
return process.env.GITHUB_SHA;
|
|
2313
|
+
}
|
|
2314
|
+
if (process.env.BITBUCKET_COMMIT) {
|
|
2315
|
+
return process.env.BITBUCKET_COMMIT;
|
|
2316
|
+
}
|
|
2317
|
+
if (process.env.BUILD_SOURCEVERSION) {
|
|
2318
|
+
return process.env.BUILD_SOURCEVERSION;
|
|
2319
|
+
}
|
|
2320
|
+
if (process.env.CIRCLE_SHA1) {
|
|
2321
|
+
return process.env.CIRCLE_SHA1;
|
|
2322
|
+
}
|
|
2323
|
+
if (process.env.GIT_COMMIT) {
|
|
2324
|
+
return process.env.GIT_COMMIT;
|
|
2325
|
+
}
|
|
2326
|
+
return null;
|
|
2327
|
+
}
|
|
2328
|
+
function detectCiEnvironment() {
|
|
2329
|
+
if (process.env.GITLAB_CI) return "GitLab CI";
|
|
2330
|
+
if (process.env.GITHUB_ACTIONS) return "GitHub Actions";
|
|
2331
|
+
if (process.env.BITBUCKET_PIPELINES) return "Bitbucket Pipelines";
|
|
2332
|
+
if (process.env.TF_BUILD) return "Azure DevOps";
|
|
2333
|
+
if (process.env.CIRCLECI) return "CircleCI";
|
|
2334
|
+
if (process.env.JENKINS_URL) return "Jenkins";
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
var deployCommand = new Command4("deploy").description("Trigger a deployment (for CI/CD pipelines)").argument("<environment>", "Environment slug (e.g., production, staging)").option("-i, --image <tag>", "Docker image tag to deploy (auto-detected in CI/CD)").option("-w, --wait", "Wait for deployment to complete", true).option("--no-wait", "Do not wait for deployment to complete").option(
|
|
2306
2338
|
"--timeout <ms>",
|
|
2307
2339
|
"Timeout in milliseconds when waiting",
|
|
2308
2340
|
"600000"
|
|
2309
2341
|
).action(async (environment, options) => {
|
|
2310
2342
|
const { project, environment: env } = await getCommandContextWithEnvironment(environment);
|
|
2311
2343
|
logger.header(`Deploying: ${project.name} \u2192 ${env.name}`);
|
|
2344
|
+
let imageTag = options.image;
|
|
2345
|
+
if (!imageTag) {
|
|
2346
|
+
const commitSha = detectCiCommitSha();
|
|
2347
|
+
const ciEnv = detectCiEnvironment();
|
|
2348
|
+
if (commitSha && ciEnv) {
|
|
2349
|
+
imageTag = `${REGISTRY_URL}/${project.slug}:${commitSha}`;
|
|
2350
|
+
logger.info(`CI/CD detected (${ciEnv})`);
|
|
2351
|
+
logger.info(`Auto-using image: ${imageTag}`);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2312
2354
|
logger.info("Triggering deployment...");
|
|
2313
2355
|
const { data: deployment, error } = await apiClient.deploy(
|
|
2314
2356
|
env.id,
|
|
2315
|
-
|
|
2357
|
+
imageTag
|
|
2316
2358
|
);
|
|
2317
2359
|
if (error) {
|
|
2318
2360
|
logger.error(`Failed to trigger deployment: ${error}`);
|
|
@@ -2328,7 +2370,7 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2328
2370
|
status: deployment.status,
|
|
2329
2371
|
environment: env.slug,
|
|
2330
2372
|
project: project.slug,
|
|
2331
|
-
imageTag:
|
|
2373
|
+
imageTag: imageTag || "auto-promotion"
|
|
2332
2374
|
});
|
|
2333
2375
|
if (!options.wait) {
|
|
2334
2376
|
logger.info("Deployment started. Use --wait to wait for completion.");
|
|
@@ -2629,17 +2671,19 @@ PIPELINE-STRUKTUR:
|
|
|
2629
2671
|
- Docker Images bauen mit docker-compose build
|
|
2630
2672
|
- Images pushen mit docker-compose push
|
|
2631
2673
|
- Registry: registry.turbo-ops.de/${projectSlug}
|
|
2674
|
+
- Image-Tag: \${CI_COMMIT_SHA} (wird automatisch von CLI erkannt)
|
|
2632
2675
|
|
|
2633
2676
|
2. Deploy-Jobs: Jeder Job l\xE4uft NUR auf seinem Branch!
|
|
2634
2677
|
- deploy-dev: rules: if: $CI_COMMIT_BRANCH == "dev"
|
|
2635
2678
|
- deploy-test: rules: if: $CI_COMMIT_BRANCH == "test"
|
|
2636
2679
|
- deploy-prod: rules: if: $CI_COMMIT_BRANCH == "main" (when: manual)
|
|
2637
2680
|
|
|
2638
|
-
DEPLOY-BEFEHLE:
|
|
2681
|
+
DEPLOY-BEFEHLE (WICHTIG: KEIN --image Flag n\xF6tig!):
|
|
2639
2682
|
- TurboOps CLI installieren: npm install -g @turboops/cli
|
|
2640
2683
|
- Token setzen: turbo config set token \${TURBOOPS_TOKEN}
|
|
2641
|
-
- Deploy
|
|
2642
|
-
|
|
2684
|
+
- Deploy: turbo deploy <stage> --wait
|
|
2685
|
+
|
|
2686
|
+
Die CLI erkennt automatisch CI_COMMIT_SHA/GITHUB_SHA und verwendet das richtige Image!
|
|
2643
2687
|
|
|
2644
2688
|
DEPENDENCIES:
|
|
2645
2689
|
- deploy-dev needs: [build]
|