You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deployment/preview-branches.mdx
+59-3Lines changed: 59 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,13 @@ import UpgradeToV4Note from "/snippets/upgrade-to-v4-note.mdx";
7
7
8
8
<UpgradeToV4Note />
9
9
10
-
## How does it work?
10
+
## How to use preview branches
11
11
12
-
The Preview environment is special – you create branches from it. We recommend you automatically create a preview branch for each git branch when a Pull Request is opened and then archive it automatically when the PR is merged/closed.
12
+
The preview environment is special – you create branches from it. The branches you create live under the preview environment and have all the features you're used to from other environments (like staging or production). That means you can trigger runs, have schedules, test them, use Realtime, etc.
13
+
14
+

15
+
16
+
We recommend you automatically create a preview branch for each git branch when a Pull Request is opened and then archive it automatically when the PR is merged/closed.
13
17
14
18
The process to use preview branches looks like this:
15
19
@@ -25,7 +29,7 @@ There are two main ways to do this:
25
29
26
30
### Limits on active preview branches
27
31
28
-
We restrict the number of active preview branches (per project). You can archive a preview branch at any time (automatically or manually) to unlock another slot.
32
+
We restrict the number of active preview branches (per project). You can archive a preview branch at any time (automatically or manually) to unlock another slot – or you can upgrade your plan.
29
33
30
34
Once archived you can still view the dashboard for the branch but you can't trigger or execute runs (or other write operations).
31
35
@@ -145,3 +149,55 @@ From the "Preview branches" page you can create a branch:
You can set environment variables for "Preview" and they will get applied to all branches (existing and new). You can also set environment variables for a specific branch. If they are set for both then the branch-specific variables will take precedence.
These can be set manually in the dashboard, or automatically at deploy time using the [syncEnvVars()](/config/extensions/syncEnvVars) or [syncVercelEnvVars()](/config/extensions/syncEnvVars#syncvercelenvvars) build extensions.
160
+
161
+
### Sync environment variables
162
+
163
+
You can find this in the Trigger.dev dashboard. Full instructions are in the [syncEnvVars()](/config/extensions/syncEnvVars) documentation.
164
+
165
+
```ts trigger.config.ts
166
+
import { defineConfig } from "@trigger.dev/sdk";
167
+
// You will need to install the @trigger.dev/build package
168
+
import { syncEnvVars } from "@trigger.dev/build/extensions/core";
169
+
170
+
export default defineConfig({
171
+
//... other config
172
+
build: {
173
+
// This will automatically detect and sync environment variables
174
+
extensions: [
175
+
syncEnvVars(async (ctx) => {
176
+
// You can fetch env variables from a 3rd party service like Infisical, Hashicorp Vault, etc.
177
+
// The ctx.branch will be set if it's a preview deployment.
You need to set the `VERCEL_ACCESS_TOKEN`, `VERCEL_PROJECT_ID` and `VERCEL_TEAM_ID` environment variables. You can find these in the Vercel dashboard. Full instructions are in the [syncVercelEnvVars()](/config/extensions/syncEnvVars#syncvercelenvvars) documentation.
188
+
189
+
The extension will automatically detect a preview branch deploy from Vercel and sync the appropriate environment variables.
190
+
191
+
```ts trigger.config.ts
192
+
import { defineConfig } from "@trigger.dev/sdk";
193
+
// You will need to install the @trigger.dev/build package
194
+
import { syncVercelEnvVars } from "@trigger.dev/build/extensions/core";
195
+
196
+
export default defineConfig({
197
+
//... other config
198
+
build: {
199
+
// This will automatically detect and sync environment variables
0 commit comments