Skip to content

Commit bf6c407

Browse files
authored
Merge branch 'main' into chore/prisma-v6-multi-file-schema
2 parents da62a13 + 9fca9e0 commit bf6c407

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+505
-72
lines changed

.changeset/pre.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"curvy-dogs-share",
2525
"eighty-rings-divide",
2626
"four-needles-add",
27+
"fuzzy-snakes-beg",
2728
"gentle-waves-suffer",
2829
"gold-insects-invite",
2930
"green-lions-relate",
@@ -33,8 +34,10 @@
3334
"itchy-frogs-care",
3435
"itchy-games-sort",
3536
"late-chairs-ring",
37+
"late-dancers-smile",
3638
"lazy-panthers-shop",
3739
"moody-squids-count",
40+
"nasty-cobras-wonder",
3841
"nice-colts-boil",
3942
"orange-rocks-grow",
4043
"plenty-dolphins-act",
@@ -45,6 +48,9 @@
4548
"red-chairs-begin",
4649
"red-wasps-cover",
4750
"shiny-kiwis-beam",
51+
"silly-cows-serve",
52+
"silly-timers-repair",
53+
"small-dancers-smell",
4854
"smart-coins-hammer",
4955
"sour-mirrors-accept",
5056
"spotty-ducks-punch",
@@ -62,6 +68,7 @@
6268
"wet-deers-think",
6369
"wet-steaks-reflect",
6470
"wild-mirrors-return",
71+
"witty-cherries-tan",
6572
"witty-donkeys-unite"
6673
]
6774
}

.changeset/witty-cherries-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Fix `syncEnvVars` for non-preview deployments

.github/workflows/unit-tests-internal.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ jobs:
127127
merge-multiple: true
128128

129129
- name: Merge reports
130-
run: pnpm dlx vitest run --merge-reports
130+
run: pnpm dlx vitest@3.1.4 run --merge-reports

.github/workflows/unit-tests-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ jobs:
127127
merge-multiple: true
128128

129129
- name: Merge reports
130-
run: pnpm dlx vitest run --merge-reports
130+
run: pnpm dlx vitest@3.1.4 run --merge-reports

.github/workflows/unit-tests-webapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ jobs:
133133
merge-multiple: true
134134

135135
- name: Merge reports
136-
run: pnpm dlx vitest run --merge-reports
136+
run: pnpm dlx vitest@3.1.4 run --merge-reports

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.alerts.new/route.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ const FormSchema = z
5050
.min(1)
5151
.or(z.enum(["TASK_RUN", "DEPLOYMENT_FAILURE", "DEPLOYMENT_SUCCESS"])),
5252
environmentTypes: z
53-
.array(z.enum(["STAGING", "PRODUCTION"]))
53+
.array(z.enum(["STAGING", "PRODUCTION", "PREVIEW"]))
5454
.min(1)
55-
.or(z.enum(["STAGING", "PRODUCTION"])),
55+
.or(z.enum(["STAGING", "PRODUCTION", "PREVIEW"])),
5656
type: z.enum(["WEBHOOK", "SLACK", "EMAIL"]).default("EMAIL"),
5757
channelValue: z.string().nonempty(),
5858
integrationId: z.string().optional(),
@@ -441,7 +441,7 @@ export default function Page() {
441441
<InputGroup>
442442
<Label>Environment</Label>
443443
<input type="hidden" name={environmentTypes.name} value={environment.type} />
444-
<EnvironmentCombo environment={environment} />
444+
<EnvironmentCombo environment={{ type: environment.type }} />
445445
<FormError id={environmentTypes.errorId}>{environmentTypes.error}</FormError>
446446
</InputGroup>
447447
<FormError>{form.error}</FormError>

apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.import.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
4747
})),
4848
});
4949

50+
// Only sync parent variables if this is a branch environment
5051
if (environment.parentEnvironmentId && body.parentVariables) {
5152
const parentResult = await repository.create(environment.project.id, {
5253
override: typeof body.override === "boolean" ? body.override : false,

apps/webapp/app/v3/services/alerts/deliverAlert.server.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { type ProjectAlertChannelType, type ProjectAlertType } from "@trigger.de
4040
import { alertsRateLimiter } from "~/v3/alertsRateLimiter.server";
4141
import { v3RunPath } from "~/utils/pathBuilder";
4242
import { ApiRetrieveRunPresenter } from "~/presenters/v3/ApiRetrieveRunPresenter.server";
43+
import { environmentTitle } from "~/components/environments/EnvironmentLabel";
4344

4445
type FoundAlert = Prisma.Result<
4546
typeof prisma.projectAlert,
@@ -56,6 +57,12 @@ type FoundAlert = Prisma.Result<
5657
include: {
5758
lockedBy: true;
5859
lockedToVersion: true;
60+
runtimeEnvironment: {
61+
select: {
62+
type: true;
63+
branchName: true;
64+
};
65+
};
5966
};
6067
};
6168
workerDeployment: {
@@ -65,6 +72,12 @@ type FoundAlert = Prisma.Result<
6572
tasks: true;
6673
};
6774
};
75+
environment: {
76+
select: {
77+
type: true;
78+
branchName: true;
79+
};
80+
};
6881
};
6982
};
7083
};
@@ -90,6 +103,12 @@ export class DeliverAlertService extends BaseService {
90103
include: {
91104
lockedBy: true,
92105
lockedToVersion: true,
106+
runtimeEnvironment: {
107+
select: {
108+
type: true,
109+
branchName: true,
110+
},
111+
},
93112
},
94113
},
95114
workerDeployment: {
@@ -99,6 +118,12 @@ export class DeliverAlertService extends BaseService {
99118
tasks: true,
100119
},
101120
},
121+
environment: {
122+
select: {
123+
type: true,
124+
branchName: true,
125+
},
126+
},
102127
},
103128
},
104129
},
@@ -177,10 +202,9 @@ export class DeliverAlertService extends BaseService {
177202
runId: alert.taskRun.friendlyId,
178203
taskIdentifier: alert.taskRun.taskIdentifier,
179204
fileName: alert.taskRun.lockedBy?.filePath ?? "Unknown",
180-
exportName: alert.taskRun.lockedBy?.exportName ?? "Unknown",
181205
version: alert.taskRun.lockedToVersion?.version ?? "Unknown",
182206
project: alert.project.name,
183-
environment: alert.environment.slug,
207+
environment: environmentTitle(alert.taskRun.runtimeEnvironment),
184208
error: createJsonErrorObject(taskRunError),
185209
runLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/runs/${alert.taskRun.friendlyId}`,
186210
organization: alert.project.organization.title,
@@ -211,7 +235,7 @@ export class DeliverAlertService extends BaseService {
211235
email: "alert-deployment-failure",
212236
to: emailProperties.data.email,
213237
version: alert.workerDeployment.version,
214-
environment: alert.environment.slug,
238+
environment: environmentTitle(alert.workerDeployment.environment),
215239
shortCode: alert.workerDeployment.shortCode,
216240
failedAt: alert.workerDeployment.failedAt ?? new Date(),
217241
error: preparedError,
@@ -232,7 +256,7 @@ export class DeliverAlertService extends BaseService {
232256
email: "alert-deployment-success",
233257
to: emailProperties.data.email,
234258
version: alert.workerDeployment.version,
235-
environment: alert.environment.slug,
259+
environment: environmentTitle(alert.workerDeployment.environment),
236260
shortCode: alert.workerDeployment.shortCode,
237261
deployedAt: alert.workerDeployment.deployedAt ?? new Date(),
238262
deploymentLink: `${env.APP_ORIGIN}/projects/v3/${alert.project.externalRef}/deployments/${alert.workerDeployment.shortCode}`,
@@ -292,6 +316,7 @@ export class DeliverAlertService extends BaseService {
292316
id: alert.environment.id,
293317
type: alert.environment.type,
294318
slug: alert.environment.slug,
319+
branchName: alert.environment.branchName ?? undefined,
295320
},
296321
organization: {
297322
id: alert.project.organizationId,
@@ -349,6 +374,7 @@ export class DeliverAlertService extends BaseService {
349374
id: alert.environment.id,
350375
type: alert.environment.type,
351376
slug: alert.environment.slug,
377+
branchName: alert.environment.branchName ?? undefined,
352378
},
353379
organization: {
354380
id: alert.project.organizationId,
@@ -648,9 +674,8 @@ export class DeliverAlertService extends BaseService {
648674
const taskRunError = this.#getRunError(alert);
649675
const error = createJsonErrorObject(taskRunError);
650676

651-
const exportName = alert.taskRun.lockedBy?.exportName ?? "Unknown";
652677
const version = alert.taskRun.lockedToVersion?.version ?? "Unknown";
653-
const environment = alert.environment.slug;
678+
const environment = environmentTitle(alert.taskRun.runtimeEnvironment);
654679
const taskIdentifier = alert.taskRun.taskIdentifier;
655680
const timestamp = alert.taskRun.completedAt ?? new Date();
656681
const runId = alert.taskRun.friendlyId;
@@ -664,7 +689,7 @@ export class DeliverAlertService extends BaseService {
664689
type: "section",
665690
text: {
666691
type: "mrkdwn",
667-
text: `:rotating_light: Error in *${exportName}* _<!date^${Math.round(
692+
text: `:rotating_light: Error in *${taskIdentifier}* _<!date^${Math.round(
668693
timestamp.getTime() / 1000
669694
)}^at {date_num} {time_secs}|${timestamp.toLocaleString()}>_`,
670695
},

apps/webapp/app/v3/services/alerts/performTaskRunAlerts.server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export class PerformTaskRunAlertsService extends BaseService {
1616
where: { id: runId },
1717
include: {
1818
lockedBy: true,
19-
runtimeEnvironment: true,
19+
runtimeEnvironment: {
20+
include: {
21+
parentEnvironment: true,
22+
},
23+
},
2024
},
2125
});
2226

@@ -32,7 +36,7 @@ export class PerformTaskRunAlertsService extends BaseService {
3236
has: "TASK_RUN",
3337
},
3438
environmentTypes: {
35-
has: run.runtimeEnvironment.type,
39+
has: run.runtimeEnvironment.parentEnvironment?.type ?? run.runtimeEnvironment.type,
3640
},
3741
enabled: true,
3842
},

docs/apikeys.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@ Each environment has its own secret key. You can find the value on the API keys
1111

1212
![How to find your secret key](/images/api-keys.png)
1313

14+
<Note>
15+
For preview branches, you need to also set the `TRIGGER_PREVIEW_BRANCH` environment variable as
16+
well. You can find the value on the API keys page when you're on the preview branch.
17+
</Note>
18+
1419
### Automatically Configuring the SDK
1520

1621
To automatically configure the SDK with your secret key, you can set the `TRIGGER_SECRET_KEY` environment variable. The SDK will automatically use this value when calling API methods (like `trigger`).
1722

1823
```bash .env
1924
TRIGGER_SECRET_KEY="tr_dev_…"
25+
TRIGGER_PREVIEW_BRANCH="my-branch" # Only needed for preview branches
2026
```
2127

2228
You can do the same if you are self-hosting and need to change the default URL by using `TRIGGER_API_URL`.
2329

2430
```bash .env
2531
TRIGGER_API_URL="https://trigger.example.com"
32+
TRIGGER_PREVIEW_BRANCH="my-branch" # Only needed for preview branches
2633
```
2734

2835
The default URL is `https://api.trigger.dev`.
@@ -37,6 +44,7 @@ import { myTask } from "./trigger/myTasks";
3744

3845
configure({
3946
secretKey: "tr_dev_1234", // WARNING: Never actually hardcode your secret key like this
47+
previewBranch: "my-branch", // Only needed for preview branches
4048
baseURL: "https://mytrigger.example.com", // Optional
4149
});
4250

docs/cli-preview-archive.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: "CLI preview archive command"
3+
sidebarTitle: "preview archive"
4+
description: "The `trigger.dev preview archive` command can be used to archive a preview branch."
5+
---
6+
7+
import UpgradeToV4Note from "/snippets/upgrade-to-v4-note.mdx";
8+
import ProjectPathArg from "/snippets/cli-args-project-path.mdx";
9+
import CommonOptions from "/snippets/cli-options-common.mdx";
10+
import ProjectRefOption from "/snippets/cli-options-project-ref.mdx";
11+
import EnvFileOption from "/snippets/cli-options-env-file.mdx";
12+
import ConfigFileOption from "/snippets/cli-options-config-file.mdx";
13+
import SkipUpdateCheckOption from "/snippets/cli-options-skip-update-check.mdx";
14+
import BranchOption from "/snippets/cli-options-branch.mdx";
15+
16+
<UpgradeToV4Note />
17+
18+
Run the command like this:
19+
20+
<CodeGroup>
21+
22+
```bash npm
23+
npx trigger.dev@v4-beta preview archive
24+
```
25+
26+
```bash pnpm
27+
pnpm dlx trigger.dev@v4-beta preview archive
28+
```
29+
30+
```bash yarn
31+
yarn dlx trigger.dev@v4-beta preview archive
32+
```
33+
34+
</CodeGroup>
35+
36+
It will archive the preview branch, automatically detecting the branch name from git. You can manually specify the branch using the `--branch` option.
37+
38+
## Arguments
39+
40+
```
41+
npx trigger.dev@v4-beta preview archive [path]
42+
```
43+
44+
<ProjectPathArg />
45+
46+
## Options
47+
48+
<BranchOption />
49+
50+
<ConfigFileOption />
51+
52+
<ProjectRefOption />
53+
54+
<EnvFileOption />
55+
56+
<SkipUpdateCheckOption />
57+
58+
### Common options
59+
60+
These options are available on most commands.
61+
62+
<CommonOptions />

0 commit comments

Comments
 (0)