Skip to content

Commit 6c658d4

Browse files
committed
Pass in triggeredVia in the CLI
1 parent eb3aca5 commit 6c658d4

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/cli-v3/src/commands/deploy.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
GitMeta,
77
DeploymentFinalizedEvent,
88
DeploymentEventFromString,
9+
DeploymentTriggeredVia,
910
} from "@trigger.dev/core/v3/schemas";
1011
import { Command, Option as CommandOption } from "commander";
1112
import { join, relative, resolve } from "node:path";
@@ -48,7 +49,7 @@ import {
4849
import { loadDotEnvVars } from "../utilities/dotEnv.js";
4950
import { isDirectory } from "../utilities/fileSystem.js";
5051
import { setGithubActionsOutputAndEnvVars } from "../utilities/githubActions.js";
51-
import { createGitMeta } from "../utilities/gitMeta.js";
52+
import { createGitMeta, isGitHubActions } from "../utilities/gitMeta.js";
5253
import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
5354
import { resolveLocalEnvVars } from "../utilities/localEnvVars.js";
5455
import { logger } from "../utilities/logger.js";
@@ -382,6 +383,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
382383
type: features.run_engine_v2 ? "MANAGED" : "V1",
383384
runtime: buildManifest.runtime,
384385
isNativeBuild: false,
386+
triggeredVia: getTriggeredVia(),
385387
},
386388
envVars.TRIGGER_EXISTING_DEPLOYMENT_ID
387389
);
@@ -893,6 +895,17 @@ async function initializeOrAttachDeployment(
893895
return newDeploymentOrError.data;
894896
}
895897

898+
function getTriggeredVia(): DeploymentTriggeredVia {
899+
if (isGitHubActions()) {
900+
return "cli:github_actions";
901+
}
902+
if (isCI) {
903+
return "cli:ci_other";
904+
}
905+
906+
return "cli:manual";
907+
}
908+
896909
async function handleNativeBuildServerDeploy({
897910
apiClient,
898911
options,
@@ -998,6 +1011,7 @@ async function handleNativeBuildServerDeploy({
9981011
artifactKey,
9991012
skipPromotion: options.skipPromotion,
10001013
configFilePath,
1014+
triggeredVia: getTriggeredVia(),
10011015
});
10021016

10031017
if (!initializeDeploymentResult.success) {

packages/cli-v3/src/utilities/gitMeta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function errorToString(err: unknown): string {
105105
return err instanceof Error ? err.message : String(err);
106106
}
107107

108-
function isGitHubActions() {
108+
export function isGitHubActions() {
109109
// GH Actions CI sets these env variables
110110
return (
111111
process.env.GITHUB_ACTIONS === "true" &&

packages/core/src/v3/schemas/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ export type ExternalBuildData = z.infer<typeof ExternalBuildData>;
403403
const anyString = z.custom<string & {}>((v) => typeof v === "string");
404404

405405
export const DeploymentTriggeredVia = z
406-
.enum(["cli:manual", "cli:ci", "cli:github_actions", "git_integration:github", "dashboard"])
406+
.enum(["cli:manual", "cli:ci_other", "cli:github_actions", "git_integration:github", "dashboard"])
407407
.or(anyString);
408408

409409
export type DeploymentTriggeredVia = z.infer<typeof DeploymentTriggeredVia>;

0 commit comments

Comments
 (0)