Skip to content

Commit df62502

Browse files
authored
feat(infra): add dev environment support (#3867)
* feat(infra): add dev environment support * fix(ci): push :dev ECR tag when building from dev branch * fix(feature-flags): simplify isHosted subdomain check * fix(ci,feature-flags): guard URL parse, fix dev AWS creds in images.yml
1 parent 1a2aa69 commit df62502

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [main, staging]
5+
branches: [main, staging, dev]
66
pull_request:
7-
branches: [main, staging]
7+
branches: [main, staging, dev]
88

99
concurrency:
1010
group: ci-${{ github.ref }}
@@ -23,7 +23,7 @@ jobs:
2323
detect-version:
2424
name: Detect Version
2525
runs-on: blacksmith-4vcpu-ubuntu-2404
26-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
26+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev')
2727
outputs:
2828
version: ${{ steps.extract.outputs.version }}
2929
is_release: ${{ steps.extract.outputs.is_release }}
@@ -49,7 +49,7 @@ jobs:
4949
build-amd64:
5050
name: Build AMD64
5151
needs: [test-build, detect-version]
52-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
52+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev')
5353
runs-on: blacksmith-8vcpu-ubuntu-2404
5454
permissions:
5555
contents: read
@@ -75,8 +75,8 @@ jobs:
7575
- name: Configure AWS credentials
7676
uses: aws-actions/configure-aws-credentials@v4
7777
with:
78-
role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }}
79-
aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }}
78+
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 }}
79+
aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_REGION || secrets.STAGING_AWS_REGION }}
8080

8181
- name: Login to Amazon ECR
8282
id: login-ecr
@@ -109,6 +109,8 @@ jobs:
109109
# ECR tags (always build for ECR)
110110
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
111111
ECR_TAG="latest"
112+
elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
113+
ECR_TAG="dev"
112114
else
113115
ECR_TAG="staging"
114116
fi

.github/workflows/images.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
- name: Configure AWS credentials
3737
uses: aws-actions/configure-aws-credentials@v4
3838
with:
39-
role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }}
40-
aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }}
39+
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 }}
40+
aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_REGION || secrets.STAGING_AWS_REGION }}
4141

4242
- name: Login to Amazon ECR
4343
id: login-ecr
@@ -70,6 +70,8 @@ jobs:
7070
# ECR tags (always build for ECR)
7171
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
7272
ECR_TAG="latest"
73+
elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
74+
ECR_TAG="dev"
7375
else
7476
ECR_TAG="staging"
7577
fi

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ export const isDev = env.NODE_ENV === 'development'
1919
export const isTest = env.NODE_ENV === 'test'
2020

2121
/**
22-
* Is this the hosted version of the application
23-
*/
24-
export const isHosted =
25-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
26-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
22+
* Is this the hosted version of the application.
23+
* True for sim.ai and any subdomain of sim.ai (e.g. staging.sim.ai, dev.sim.ai).
24+
*/
25+
const appUrl = getEnv('NEXT_PUBLIC_APP_URL')
26+
let appHostname = ''
27+
try {
28+
appHostname = appUrl ? new URL(appUrl).hostname : ''
29+
} catch {
30+
// invalid URL — isHosted stays false
31+
}
32+
export const isHosted = appHostname === 'sim.ai' || appHostname.endsWith('.sim.ai')
2733

2834
/**
2935
* Is billing enforcement enabled

0 commit comments

Comments
 (0)