Scheduling infrastructure for absolutely everyone.
chore: sync vercel env var with trigger.dev and deploy (#25610)
Morganecaf24d9a2ec
diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.ymlindex 0f02ccf9702..d4deae6ee50 100644--- a/.github/workflows/draft-release.yml+++ b/.github/workflows/draft-release.yml@@ -55,6 +55,21 @@ jobs:- uses: ./.github/actions/yarn-install+ # 1. Generate Prisma Client+ # This is required so Trigger.dev can find the database types during bundling+ - name: Generate Prisma Client+ run: yarn prisma generate++ # 2. Deploy Trigger.dev tasks+ # We use --skip-promotion to get a version without making it live yet+ - name: Deploy Trigger.dev+ id: deploy-trigger+ env:+ TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}+ run: |+ # The CLI outputs the version; id allows us to access outputs.deploymentVersion+ npx trigger.dev@latest deploy --skip-promotion+- name: Bump versionenv:VERSION: ${{ inputs.next_version }}@@ -62,6 +77,16 @@ jobs:cd apps/webyarn version "$VERSION"+ # 3. Update .env.production files+ # We inject the Trigger version into the apps so they stay in sync+ - name: Update Env Files+ run: |+ VERSION="${{ steps.deploy-trigger.outputs.deploymentVersion }}"+ echo "TRIGGER_VERSION=$VERSION" > apps/web/.env.production+ echo "TRIGGER_VERSION=$VERSION" > apps/api/v2/.env.production+ git add -f apps/web/.env.production apps/api/v2/.env.production++ # 4. Commit everything together- name: Commit changesenv:VERSION: ${{ inputs.next_version }}@@ -73,5 +98,5 @@ jobs:- name: Draft releaserun: gh release create v$VERSION --generate-notes --draftenv:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}VERSION: ${{ inputs.next_version }}diff --git a/apps/api/v2/src/app.module.ts b/apps/api/v2/src/app.module.tsindex 6ec489bcba8..64fa31ef085 100644--- a/apps/api/v2/src/app.module.ts+++ b/apps/api/v2/src/app.module.ts@@ -27,7 +27,9 @@ import { AppController } from "./app.controller";imports: [SentryModule.forRoot(),ConfigModule.forRoot({- ignoreEnvFile: true,+ ...(process.env.NODE_ENV === "production"+ ? { envFilePath: ".env.production" }+ : { ignoreEnvFile: true }),isGlobal: true,load: [appConfig],}),diff --git a/package.json b/package.jsonindex 69a6759199e..55dfa648e23 100644--- a/package.json+++ b/package.json@@ -42,7 +42,8 @@"dev:swagger": "turbo run dev --filter=\"@calcom/api-proxy\" --filter=\"@calcom/api\" --filter=\"@calcom/swagger\"","dev:website": "turbo run dev --filter=\"@calcom/web\" --filter=\"@calcom/website\"","dev:trigger": "turbo run dev:trigger --filter=\"@calcom/features\"",- "deploy:trigger": "turbo run deploy:trigger --filter=\"@calcom/features\"",+ "deploy:trigger:prod": "turbo run deploy:trigger:prod --filter=\"@calcom/features\"",+ "deploy:trigger:staging": "turbo run deploy:trigger:staging --filter=\"@calcom/features\"","dev": "turbo run dev --filter=\"@calcom/web\"","dx": "turbo run dx","i-dev": "infisical run -- turbo run dev --filter=\"@calcom/web\"",diff --git a/packages/features/package.json b/packages/features/package.jsonindex 540a3330663..88102884e44 100644--- a/packages/features/package.json+++ b/packages/features/package.json@@ -9,7 +9,8 @@"scripts": {"lint": "biome lint .","dev:trigger": "npx trigger.dev@latest dev --analyze",- "deploy:trigger": "npx trigger.dev@latest deploy"+ "deploy:trigger:prod": "npx trigger.dev@latest deploy --skip-promotion",+ "deploy:trigger:staging": "npx trigger.dev@latest deploy --env staging --skip-promotion"},"dependencies": {"@calcom/atoms": "workspace:*",diff --git a/packages/features/trigger.config.ts b/packages/features/trigger.config.tsindex 156ee73162b..8596ee163b5 100644--- a/packages/features/trigger.config.ts+++ b/packages/features/trigger.config.ts@@ -1,8 +1,15 @@+import { syncVercelEnvVars } from "@trigger.dev/build/extensions/core";import { defineConfig } from "@trigger.dev/sdk";import dotEnv from "dotenv";dotEnv.config({ path: "../../.env" });+const canSyncEnvVars = Boolean(+ process.env.TRIGGER_DEV_VERCEL_ACCESS_TOKEN &&+ process.env.TRIGGER_DEV_VERCEL_PROJECT_ID &&+ process.env.TRIGGER_DEV_VERCEL_TEAM_ID+);+export default defineConfig({// Your project ref from the Trigger.dev dashboardproject: process.env.TRIGGER_DEV_PROJECT_REF ?? "", // e.g., "proj_abc123"@@ -22,9 +29,29 @@ export default defineConfig({},},+ // Keep the process alive after the task has finished running so the next task doesn’t have to wait for the process to start up again.+ processKeepAlive: true,+// Build configuration (optional)build: {external: ["@prisma/client", "nodemailer", "jsdom", "playwright-core", "playwright", "chromium-bidi"],+ extensions: canSyncEnvVars+ ? [+ syncVercelEnvVars({+ // A personal access token created in your Vercel account settings+ // Used to authenticate API requests to Vercel+ // Generate at: https://vercel.com/account/tokens+ vercelAccessToken: process.env.TRIGGER_DEV_VERCEL_ACCESS_TOKEN,+ // The unique identifier of your Vercel project+ // Found in Project Settings > General > Project ID+ projectId: process.env.TRIGGER_DEV_VERCEL_PROJECT_ID,+ // Optional: The ID of your Vercel team+ // Only required for team projects+ // Found in Team Settings > General > Team ID+ vercelTeamId: process.env.TRIGGER_DEV_VERCEL_TEAM_ID,+ }),+ ]+ : [],},// Max duration of a task in secondsdiff --git a/turbo.json b/turbo.jsonindex c056404eed7..94579d015cd 100644--- a/turbo.json+++ b/turbo.json@@ -286,6 +286,9 @@"TRIGGER_SECRET_KEY","TRIGGER_API_URL","TRIGGER_DEV_PROJECT_REF",+ "TRIGGER_DEV_VERCEL_ACCESS_TOKEN",+ "TRIGGER_DEV_VERCEL_PROJECT_ID",+ "TRIGGER_DEV_VERCEL_TEAM_ID","ENABLE_ASYNC_TASKER","STRIPE_ORG_PRODUCT_ID","GOOGLE_ADS_ENABLED",@@ -393,8 +396,10 @@"NEXT_PUBLIC_SENTRY_DSN_CLIENT","BUILD_STANDALONE","NEXT_PUBLIC_API_HITPAY_PRODUCTION",- "NEXT_PUBLIC_API_HITPAY_SANDBOX"- ]+ "NEXT_PUBLIC_API_HITPAY_SANDBOX",+ "TRIGGER_VERSION"+ ],+ "inputs": ["$TURBO_DEFAULT$", ".env.production"]},"@calcom/web#dx": {"cache": false,@@ -418,8 +423,11 @@"LOG_LEVEL","NEXTAUTH_SECRET","USE_POOL",- "LOGGER_BRIDGE_LOG_LEVEL"- ]+ "LOGGER_BRIDGE_LOG_LEVEL",+ "REDIS_URL",+ "TRIGGER_VERSION"+ ],+ "inputs": ["$TURBO_DEFAULT$", ".env.production"]},"@calcom/ai#build": {"env": [@@ -499,9 +507,28 @@"env": ["TRIGGER_DEV_PROJECT_REF"],"cache": false},- "deploy:trigger": {+ "deploy:trigger:prod": {"inputs": ["./.env"],- "env": ["TRIGGER_DEV_PROJECT_REF"],+ "env": [+ "TRIGGER_DEV_PROJECT_REF",+ "TRIGGER_API_URL",+ "TRIGGER_SECRET_KEY",+ "TRIGGER_DEV_VERCEL_ACCESS_TOKEN",+ "TRIGGER_DEV_VERCEL_PROJECT_ID",+ "TRIGGER_DEV_VERCEL_TEAM_ID"+ ],+ "cache": false+ },+ "deploy:trigger:staging": {+ "inputs": ["./.env"],+ "env": [+ "TRIGGER_DEV_PROJECT_REF",+ "TRIGGER_API_URL",+ "TRIGGER_SECRET_KEY",+ "TRIGGER_DEV_VERCEL_ACCESS_TOKEN",+ "TRIGGER_DEV_VERCEL_PROJECT_ID",+ "TRIGGER_DEV_VERCEL_TEAM_ID"+ ],"cache": false},"dx": {