Skip to content

Commit a5d59de

Browse files
authored
Fix: vercelSyncEnvVars teamId (#1463)
* Update vercelSyncEnvVars.ts * Update vercelSyncEnvVars.ts * Update vercelSyncEnvVars.ts * Update vercelSyncEnvVars.ts * Update docs * Add changeset
1 parent 71808fa commit a5d59de

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.changeset/rotten-dolphins-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/build": minor
3+
---
4+
5+
Add teamId option to vercelSyncEnvVars

docs/config/config-file.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ The `vercelSyncEnvVars` build extension syncs environment variables from your Ve
511511

512512
<Note>
513513
You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables, or pass
514-
in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. You can find
515-
/ generate the `VERCEL_ACCESS_TOKEN` in your Vercel
516-
[dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers
517-
the project you want to sync.
514+
in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. If you're
515+
working with a team project, you'll also need to set `VERCEL_TEAM_ID`. You can find / generate
516+
the `VERCEL_ACCESS_TOKEN` in your Vercel [dashboard](https://vercel.com/account/settings/tokens).
517+
Make sure the scope of the token covers the project you want to sync.
518518
</Note>
519519

520520
```ts

docs/guides/examples/vercel-sync-env-vars.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ To sync environment variables, you just need to add our build extension to your
1313
<Note>
1414
You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables in the
1515
Trigger.dev dashboard, or pass in the token and project ID as arguments to the `vercelSyncEnvVars`
16-
build extension. You can find / generate the `VERCEL_ACCESS_TOKEN` in your Vercel
16+
build extension. If you're working with a team project, you'll also need to set `VERCEL_TEAM_ID`.
17+
You can find / generate the `VERCEL_ACCESS_TOKEN` in your Vercel
1718
[dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers
1819
the project with the environment variables you want to sync.
1920
</Note>

docs/guides/frameworks/nextjs.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ If you want to automatically sync environment variables from your Vercel project
251251

252252
<Note>
253253
You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables, or pass
254-
in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. You can find
255-
/ generate the `VERCEL_ACCESS_TOKEN` in your Vercel
256-
[dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers
257-
the project you want to sync.
254+
in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. If you're
255+
working with a team project, you'll also need to set `VERCEL_TEAM_ID`. You can find / generate
256+
the `VERCEL_ACCESS_TOKEN` in your Vercel [dashboard](https://vercel.com/account/settings/tokens).
257+
Make sure the scope of the token covers the project you want to sync.
258258
</Note>
259259

260260
```ts trigger.config.ts

packages/build/src/extensions/core/vercelSyncEnvVars.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { BuildExtension } from "@trigger.dev/core/v3/build";
22
import { syncEnvVars } from "../core.js";
33

4-
export function syncVercelEnvVars(
5-
options?: { projectId?: string; vercelAccessToken?: string },
4+
export function vercelSyncEnvVars(
5+
options?: { projectId?: string; vercelAccessToken?: string; vercelTeamId?: string },
66
): BuildExtension {
77
const sync = syncEnvVars(async (ctx) => {
88
const projectId = options?.projectId ?? process.env.VERCEL_PROJECT_ID ??
99
ctx.env.VERCEL_PROJECT_ID;
1010
const vercelAccessToken = options?.vercelAccessToken ??
1111
process.env.VERCEL_ACCESS_TOKEN ??
1212
ctx.env.VERCEL_ACCESS_TOKEN;
13+
const vercelTeamId = options?.vercelTeamId ?? process.env.VERCEL_TEAM_ID ??
14+
ctx.env.VERCEL_TEAM_ID;
1315

1416
if (!projectId) {
1517
throw new Error(
@@ -37,8 +39,9 @@ export function syncVercelEnvVars(
3739
`Invalid environment '${ctx.environment}'. Expected 'prod', 'staging', or 'dev'.`,
3840
);
3941
}
40-
const vercelApiUrl =
41-
`https://api.vercel.com/v8/projects/${projectId}/env?decrypt=true`;
42+
const params = new URLSearchParams({ decrypt: "true" });
43+
if (vercelTeamId) params.set("teamId", vercelTeamId);
44+
const vercelApiUrl = `https://api.vercel.com/v8/projects/${projectId}/env?${params}`;
4245

4346
try {
4447
const response = await fetch(vercelApiUrl, {

0 commit comments

Comments
 (0)