Fix: Make CI .env manipulation robust against missing trailing newlines (#15189)

## Problem

CI workflow started timing out on October 14, 2025 after commit
`d750df7fff` removed the trailing newline from `.env.example`.

## Root Cause

When `.env.example` lacks a trailing newline:
```bash
# Last line without newline
# CLICKHOUSE_URL=...twenty
```

And CI runs:
```bash
echo "NODE_PORT=3002" >> .env
```

Result:
```bash
# CLICKHOUSE_URL=...twentyNODE_PORT=3002  ← Commented out!
```

Server starts on default port 3000 instead of 3002, health check fails.

## Fix

1. **Restore trailing newline** to `.env.example`
2. **Make all CI `.env` operations robust** by adding `echo "" >> .env`
before appending
3. **Simplified `set_env_var`** function to always add newline first

Now works regardless of whether template files have trailing newlines.

## Files Changed

- 6 CI workflow files
- 1 .env.example file
This commit is contained in:
Félix Malfait
2025-10-18 13:46:56 +02:00
committed by GitHub
parent 44aee860d9
commit 5375a478db
10 changed files with 39 additions and 6 deletions
@@ -0,0 +1,22 @@
import { type DataSource } from 'typeorm';
const tableName = 'billingCustomer';
export const seedBillingCustomers = async (
dataSource: DataSource,
schemaName: string,
workspaceId: string,
) => {
await dataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, ['workspaceId', 'stripeCustomerId'])
.orIgnore()
.values([
{
workspaceId,
stripeCustomerId: 'cus_default0',
},
])
.execute();
};
@@ -1,5 +1,6 @@
import { type DataSource } from 'typeorm';
import { seedBillingCustomers } from 'src/engine/workspace-manager/dev-seeder/core/billing/utils/seed-billing-customers.util';
import { seedBillingSubscriptions } from 'src/engine/workspace-manager/dev-seeder/core/billing/utils/seed-billing-subscriptions.util';
import { seedAgents } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-agents.util';
import { seedApiKeys } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-api-keys.util';
@@ -43,6 +44,7 @@ export const seedCoreSchema = async ({
}
if (seedBilling) {
await seedBillingCustomers(dataSource, schemaName, workspaceId);
await seedBillingSubscriptions(dataSource, schemaName, workspaceId);
}
};