From a3a202a79947dac87cc96de98d1e199d58eab2d7 Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 31 Mar 2026 12:01:38 -0700 Subject: [PATCH 1/4] feat(infra): add dev environment support --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/images.yml | 2 ++ apps/sim/lib/core/config/feature-flags.ts | 16 +++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3a1bdb3b66..645a3597948 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main, staging] + branches: [main, staging, dev] pull_request: - branches: [main, staging] + branches: [main, staging, dev] concurrency: group: ci-${{ github.ref }} @@ -23,7 +23,7 @@ jobs: detect-version: name: Detect Version runs-on: blacksmith-4vcpu-ubuntu-2404 - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev') outputs: version: ${{ steps.extract.outputs.version }} is_release: ${{ steps.extract.outputs.is_release }} @@ -49,7 +49,7 @@ jobs: build-amd64: name: Build AMD64 needs: [test-build, detect-version] - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev') runs-on: blacksmith-8vcpu-ubuntu-2404 permissions: contents: read @@ -75,8 +75,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: - role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} - aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }} + role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} + aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_REGION || secrets.STAGING_AWS_REGION }} - name: Login to Amazon ECR id: login-ecr diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 44e8636d909..d38eb261396 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -70,6 +70,8 @@ jobs: # ECR tags (always build for ECR) if [ "${{ github.ref }}" = "refs/heads/main" ]; then ECR_TAG="latest" + elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then + ECR_TAG="dev" else ECR_TAG="staging" fi diff --git a/apps/sim/lib/core/config/feature-flags.ts b/apps/sim/lib/core/config/feature-flags.ts index d5fa530e52b..48270e2168d 100644 --- a/apps/sim/lib/core/config/feature-flags.ts +++ b/apps/sim/lib/core/config/feature-flags.ts @@ -19,11 +19,17 @@ export const isDev = env.NODE_ENV === 'development' export const isTest = env.NODE_ENV === 'test' /** - * Is this the hosted version of the application - */ -export const isHosted = - getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' || - getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai' + * Is this the hosted version of the application. + * True for sim.ai and any subdomain of sim.ai (e.g. staging.sim.ai, dev.sim.ai). + */ +export const isHosted = (() => { + try { + const hostname = new URL(getEnv('NEXT_PUBLIC_APP_URL') || '').hostname + return hostname === 'sim.ai' || hostname.endsWith('.sim.ai') + } catch { + return false + } +})() /** * Is billing enforcement enabled From 61454460947840e1c537cee4b964b7f2b5466919 Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 31 Mar 2026 12:53:47 -0700 Subject: [PATCH 2/4] fix(ci): push :dev ECR tag when building from dev branch --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 645a3597948..3b67ff38f56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,6 +109,8 @@ jobs: # ECR tags (always build for ECR) if [ "${{ github.ref }}" = "refs/heads/main" ]; then ECR_TAG="latest" + elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then + ECR_TAG="dev" else ECR_TAG="staging" fi From a247646b4330ce13910303de9ceee3ce85a2e485 Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 31 Mar 2026 14:57:28 -0700 Subject: [PATCH 3/4] fix(feature-flags): simplify isHosted subdomain check --- apps/sim/lib/core/config/feature-flags.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/sim/lib/core/config/feature-flags.ts b/apps/sim/lib/core/config/feature-flags.ts index 48270e2168d..9d21eee6533 100644 --- a/apps/sim/lib/core/config/feature-flags.ts +++ b/apps/sim/lib/core/config/feature-flags.ts @@ -22,14 +22,9 @@ export const isTest = env.NODE_ENV === 'test' * Is this the hosted version of the application. * True for sim.ai and any subdomain of sim.ai (e.g. staging.sim.ai, dev.sim.ai). */ -export const isHosted = (() => { - try { - const hostname = new URL(getEnv('NEXT_PUBLIC_APP_URL') || '').hostname - return hostname === 'sim.ai' || hostname.endsWith('.sim.ai') - } catch { - return false - } -})() +const appUrl = getEnv('NEXT_PUBLIC_APP_URL') +const appHostname = appUrl ? new URL(appUrl).hostname : '' +export const isHosted = appHostname === 'sim.ai' || appHostname.endsWith('.sim.ai') /** * Is billing enforcement enabled From 158e4dfce868a9c2015abcf6a0feed2d098af5e8 Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 31 Mar 2026 15:02:48 -0700 Subject: [PATCH 4/4] fix(ci,feature-flags): guard URL parse, fix dev AWS creds in images.yml --- .github/workflows/images.yml | 4 ++-- apps/sim/lib/core/config/feature-flags.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index d38eb261396..8028c433638 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -36,8 +36,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: - role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} - aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }} + role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} + aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_REGION || secrets.STAGING_AWS_REGION }} - name: Login to Amazon ECR id: login-ecr diff --git a/apps/sim/lib/core/config/feature-flags.ts b/apps/sim/lib/core/config/feature-flags.ts index 9d21eee6533..012d1d5e026 100644 --- a/apps/sim/lib/core/config/feature-flags.ts +++ b/apps/sim/lib/core/config/feature-flags.ts @@ -23,7 +23,12 @@ export const isTest = env.NODE_ENV === 'test' * True for sim.ai and any subdomain of sim.ai (e.g. staging.sim.ai, dev.sim.ai). */ const appUrl = getEnv('NEXT_PUBLIC_APP_URL') -const appHostname = appUrl ? new URL(appUrl).hostname : '' +let appHostname = '' +try { + appHostname = appUrl ? new URL(appUrl).hostname : '' +} catch { + // invalid URL — isHosted stays false +} export const isHosted = appHostname === 'sim.ai' || appHostname.endsWith('.sim.ai') /**