Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

ci: pull enviornment variables from secure database

Brad Barbine333b5344d18
diff --git a/ci/src/deploy.ts b/ci/src/deploy.ts
index ba928b01b2..fba14f10e9 100644
--- a/ci/src/deploy.ts
+++ b/ci/src/deploy.ts
@@ -15,7 +15,8 @@ export type Workspace = {
// Domain Configuration
domain_name: string | null;
- domain_cert_arn: string | null;
+ cert_arn_erp: string | null;
+ cert_arn_mes: string | null;
// Database Configuration
connection_string: string | null;
@@ -26,6 +27,8 @@ export type Workspace = {
database_password: string | null;
jwt_key: string | null;
service_role_key: string | null;
+
+ // App Configuration
carbon_edition: string | null;
cloudflare_turnstile_secret_key: string | null;
cloudflare_turnstile_site_key: string | null;
@@ -52,8 +55,8 @@ export type Workspace = {
trigger_secret_key: string | null;
upstash_redis_rest_token: string | null;
upstash_redis_rest_url: string | null;
- vercel_env: string | null;
- vercel_url: string | null;
+ url_erp: string | null;
+ url_mes: string | null;
};
async function deploy(): Promise<void> {
@@ -77,9 +80,11 @@ async function deploy(): Promise<void> {
aws_account_id,
aws_region,
domain_name,
- domain_cert_arn,
+ cert_arn_erp,
+ cert_arn_mes,
database_url,
database_password,
+ slug,
project_id,
access_token,
anon_key,
@@ -110,17 +115,21 @@ async function deploy(): Promise<void> {
trigger_secret_key,
upstash_redis_rest_token,
upstash_redis_rest_url,
- vercel_env,
- vercel_url,
+ url_erp,
+ url_mes,
} = workspace;
+ if (slug === "app") {
+ continue;
+ }
+
if (!aws_account_id) {
- console.log(`🔴🍳 Missing aws account id for ${workspace.id}`);
+ console.log(`🔴🍳 Missing AWS account id for ${workspace.id}`);
continue;
}
if (!aws_region) {
- console.log(`🔴🍳 Missing aws region for ${workspace.id}`);
+ console.log(`🔴🍳 Missing AWS region for ${workspace.id}`);
continue;
}
@@ -129,8 +138,13 @@ async function deploy(): Promise<void> {
continue;
}
- if (!domain_cert_arn) {
- console.log(`🔴🍳 Missing domain cert arn for ${workspace.id}`);
+ if (!cert_arn_erp) {
+ console.log(`🔴🍳 Missing ERP domain cert ARN for ${workspace.id}`);
+ continue;
+ }
+
+ if (!cert_arn_mes) {
+ console.log(`🔴🍳 Missing MES domain cert ARN for ${workspace.id}`);
continue;
}
@@ -164,33 +178,13 @@ async function deploy(): Promise<void> {
continue;
}
- if (!controlled_environment) {
- console.log(`🔴🍳 Missing controlled environment for ${workspace.id}`);
- continue;
- }
-
- if (!exchange_rates_api_key) {
- console.log(`🔴🍳 Missing exchange rates api key for ${workspace.id}`);
- continue;
- }
-
- if (!novu_application_id) {
- console.log(`🔴🍳 Missing novu application id for ${workspace.id}`);
- continue;
- }
-
- if (!novu_secret_key) {
- console.log(`🔴🍳 Missing novu secret key for ${workspace.id}`);
- continue;
- }
-
if (!openai_api_key) {
- console.log(`🔴🍳 Missing openai api key for ${workspace.id}`);
+ console.log(`🔴🍳 Missing OpenAI API key for ${workspace.id}`);
continue;
}
if (!posthog_api_host) {
- console.log(`🔴🍳 Missing posthog api host for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Posthog API host for ${workspace.id}`);
continue;
}
@@ -202,7 +196,7 @@ async function deploy(): Promise<void> {
}
if (!resend_api_key) {
- console.log(`🔴🍳 Missing resend api key for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Resend API key for ${workspace.id}`);
continue;
}
@@ -212,34 +206,39 @@ async function deploy(): Promise<void> {
}
if (!trigger_api_url) {
- console.log(`🔴🍳 Missing trigger api url for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Trigger api url for ${workspace.id}`);
continue;
}
if (!trigger_project_id) {
- console.log(`🔴🍳 Missing trigger project id for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Trigger project id for ${workspace.id}`);
continue;
}
if (!trigger_secret_key) {
- console.log(`🔴🍳 Missing trigger secret key for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Trigger secret key for ${workspace.id}`);
continue;
}
if (!upstash_redis_rest_token) {
console.log(
- `🔴🍳 Missing upstash redis rest token for ${workspace.id}`
+ `🔴🍳 Missing Upstash Redis REST token for ${workspace.id}`
);
continue;
}
if (!upstash_redis_rest_url) {
- console.log(`🔴🍳 Missing upstash redis rest url for ${workspace.id}`);
+ console.log(`🔴🍳 Missing Upstash Redis rest url for ${workspace.id}`);
+ continue;
+ }
+
+ if (!url_erp) {
+ console.log(`🔴🍳 Missing ERP url for ${workspace.id}`);
continue;
}
- if (!vercel_url) {
- console.log(`🔴🍳 Missing vercel url for ${workspace.id}`);
+ if (!url_mes) {
+ console.log(`🔴🍳 Missing MES url for ${workspace.id}`);
continue;
}
@@ -251,27 +250,31 @@ async function deploy(): Promise<void> {
AWS_ACCOUNT_ID: aws_account_id,
AWS_REGION: aws_region,
CARBON_EDITION: carbon_edition ?? "enterprise",
- CLOUDFLARE_TURNSTILE_SECRET_KEY: cloudflare_turnstile_secret_key,
- CLOUDFLARE_TURNSTILE_SITE_KEY: cloudflare_turnstile_site_key,
- CONTROLLED_ENVIRONMENT: controlled_environment,
+ CERT_ARN_ERP: cert_arn_erp,
+ CERT_ARN_MES: cert_arn_mes,
+ CLOUDFLARE_TURNSTILE_SECRET_KEY:
+ cloudflare_turnstile_secret_key ?? undefined,
+ CLOUDFLARE_TURNSTILE_SITE_KEY:
+ cloudflare_turnstile_site_key ?? undefined,
+ CONTROLLED_ENVIRONMENT: controlled_environment ?? undefined,
DOMAIN: domain_name,
- EXCHANGE_RATES_API_KEY: exchange_rates_api_key,
- NOVU_APPLICATION_ID: novu_application_id,
- NOVU_SECRET_KEY: novu_secret_key,
+ EXCHANGE_RATES_API_KEY: exchange_rates_api_key ?? undefined,
+ NOVU_APPLICATION_ID: novu_application_id ?? undefined,
+ NOVU_SECRET_KEY: novu_secret_key ?? undefined,
OPENAI_API_KEY: openai_api_key,
- POSTHOG_API_HOST: posthog_api_host,
- POSTHOG_PROJECT_PUBLIC_KEY: posthog_project_public_key,
+ POSTHOG_API_HOST: posthog_api_host ?? undefined,
+ POSTHOG_PROJECT_PUBLIC_KEY: posthog_project_public_key ?? undefined,
RESEND_API_KEY: resend_api_key,
SESSION_SECRET: session_secret,
- SLACK_BOT_TOKEN: slack_bot_token,
- SLACK_CLIENT_ID: slack_client_id,
- SLACK_CLIENT_SECRET: slack_client_secret,
- SLACK_OAUTH_REDIRECT_URL: slack_oauth_redirect_url,
- SLACK_SIGNING_SECRET: slack_signing_secret,
- SLACK_STATE_SECRET: slack_state_secret,
- STRIPE_BYPASS_COMPANY_IDS: stripe_bypass_company_ids,
- STRIPE_SECRET_KEY: stripe_secret_key,
- STRIPE_WEBHOOK_SECRET: stripe_webhook_secret,
+ SLACK_BOT_TOKEN: slack_bot_token ?? undefined,
+ SLACK_CLIENT_ID: slack_client_id ?? undefined,
+ SLACK_CLIENT_SECRET: slack_client_secret ?? undefined,
+ SLACK_OAUTH_REDIRECT_URL: slack_oauth_redirect_url ?? undefined,
+ SLACK_SIGNING_SECRET: slack_signing_secret ?? undefined,
+ SLACK_STATE_SECRET: slack_state_secret ?? undefined,
+ STRIPE_BYPASS_COMPANY_IDS: stripe_bypass_company_ids ?? undefined,
+ STRIPE_SECRET_KEY: stripe_secret_key ?? undefined,
+ STRIPE_WEBHOOK_SECRET: stripe_webhook_secret ?? undefined,
SUPABASE_ANON_KEY: anon_key,
SUPABASE_ANON_PUBLIC: anon_key,
SUPABASE_API_URL: database_url,
@@ -283,8 +286,9 @@ async function deploy(): Promise<void> {
TRIGGER_SECRET_KEY: trigger_secret_key,
UPSTASH_REDIS_REST_TOKEN: upstash_redis_rest_token,
UPSTASH_REDIS_REST_URL: upstash_redis_rest_url,
- VERCEL_ENV: vercel_env ?? "production",
- VERCEL_URL: vercel_url,
+ URL_ERP: url_erp,
+ URL_MES: url_mes,
+ VERCEL_ENV: "production",
},
// Run SST from the repository root where sst.config.ts is located
cwd: "..",
diff --git a/sst.config.ts b/sst.config.ts
index 4ba9f73eb5..155ce85f6b 100644
--- a/sst.config.ts
+++ b/sst.config.ts
@@ -5,7 +5,7 @@ export default $config({
return {
name: "carbon",
home: "aws",
- region: "us-gov-east-1",
+ region: process.env.AWS_REGION,
removal: input?.stage === "prod" ? "retain" : "remove",
};
},
@@ -21,7 +21,7 @@ export default $config({
domain: {
name: "itar.carbon.ms",
dns: false,
- cert: `arn:aws-us-gov:acm:us-gov-east-1:${process.env.AWS_ACCOUNT_ID}:certificate/65266e53-a298-427a-842c-9d5300ccd811`,
+ cert: process.env.CERT_ARN_ERP,
},
rules: [
{ listen: "80/http", redirect: "443/https" },
@@ -68,7 +68,7 @@ export default $config({
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
VERCEL_ENV: "production",
- VERCEL_URL: "itar.carbon.ms",
+ VERCEL_URL: process.env.URL_ERP ?? "itar.carbon.ms",
},
});
@@ -78,7 +78,7 @@ export default $config({
domain: {
name: "mes.itar.carbon.ms",
dns: false,
- cert: `arn:aws-us-gov:acm:us-gov-east-1:${process.env.AWS_ACCOUNT_ID}:certificate/30136c8d-2553-494b-a081-2d85f9d6429f`,
+ cert: process.env.CERT_ARN_MES,
},
rules: [
{ listen: "80/http", redirect: "443/https" },
@@ -116,7 +116,7 @@ export default $config({
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
VERCEL_ENV: "production",
- VERCEL_URL: "mes.itar.carbon.ms",
+ VERCEL_URL: process.env.URL_MES ?? "mes.itar.carbon.ms",
},
});