Skip to content

Commit fa21d39

Browse files
committed
ci: swap production build with staging on runtime
1 parent f7e0704 commit fa21d39

File tree

12 files changed

+83
-82
lines changed

12 files changed

+83
-82
lines changed

.github/build/build.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ FROM node:20.14-alpine
33
# runtime args and environment variables
44
ARG DIST=Redis-Insight.tar.gz
55
ARG NODE_ENV=production
6+
ARG RI_SERVER_ENV=production
67
ARG RI_SEGMENT_WRITE_KEY
78
ENV RI_SEGMENT_WRITE_KEY=${RI_SEGMENT_WRITE_KEY}
89
ENV NODE_ENV=${NODE_ENV}
10+
ENV RI_SERVER_ENV=${RI_SERVER_ENV}
911
ENV RI_SERVE_STATICS=true
1012
ENV RI_BUILD_TYPE='DOCKER_ON_PREMISE'
1113
ENV RI_APP_FOLDER_ABSOLUTE_PATH='/data'

.github/workflows/pipeline-build-docker.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ jobs:
7676
7777
- name: Build Docker (x64)
7878
run: |
79-
# Build alpine x64 image
79+
# Build alpine x64 image with production config
8080
docker buildx build \
8181
-f .github/build/build.Dockerfile \
8282
--platform linux/amd64 \
8383
--build-arg DIST=release/web/Redis-Insight-web-linux-musl.x64.tar.gz \
84-
--build-arg NODE_ENV="$ENV" \
84+
--build-arg NODE_ENV=production \
85+
--build-arg RI_SERVER_ENV=production \
8586
--build-arg RI_SEGMENT_WRITE_KEY="$RI_SEGMENT_WRITE_KEY" \
8687
-t redisinsight:amd64 \
8788
.
@@ -92,12 +93,13 @@ jobs:
9293
- name: Build Docker (arm64)
9394
if: ${{ !inputs.for_e2e_tests }}
9495
run: |
95-
# Build alpine arm64 image
96+
# Build alpine arm64 image with production config
9697
docker buildx build \
9798
-f .github/build/build.Dockerfile \
9899
--platform linux/arm64 \
99100
--build-arg DIST=release/web/Redis-Insight-web-linux-musl.arm64.tar.gz \
100-
--build-arg NODE_ENV="$ENV" \
101+
--build-arg NODE_ENV=production \
102+
--build-arg RI_SERVER_ENV=production \
101103
--build-arg RI_SEGMENT_WRITE_KEY="$RI_SEGMENT_WRITE_KEY" \
102104
-t redisinsight:arm64 \
103105
.

.github/workflows/pipeline-build-linux.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,16 @@ jobs:
6262
- name: Install plugins dependencies and build plugins
6363
run: yarn build:statics
6464

65-
- name: Build linux packages (production)
66-
if: vars.ENV == 'production' && inputs.target == vars.ALL
65+
- name: Build linux packages
66+
if: inputs.target == vars.ALL
6767
run: yarn package:prod
6868

69-
- name: Build linux packages (staging)
70-
if: (vars.ENV == 'staging' || vars.ENV == 'development') && inputs.target == vars.ALL
71-
run: yarn package:stage
72-
7369
- name: Build linux packages (custom)
7470
if: inputs.target != vars.ALL
7571
run: |
7672
target=$(echo "${{inputs.target}}" | grep -oE 'build_linux_[^_ ]+' | sed 's/build_linux_//' | sort -u | paste -sd ' ' -)
7773
78-
if [ "${{ vars.ENV == 'production' }}" == "true" ]; then
79-
yarn package:prod --linux $target
80-
else
81-
yarn package:stage --linux $target
82-
fi
74+
yarn package:prod --linux $target
8375
8476
- uses: actions/upload-artifact@v4
8577
name: Upload vendor for plugins

.github/workflows/pipeline-build-macos.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,17 @@ jobs:
5757
- name: Install plugins dependencies and build plugins
5858
run: yarn build:statics
5959

60-
- name: Build macos dmg (prod)
61-
if: vars.ENV == 'production' && inputs.target == vars.ALL
62-
run: |
63-
unset CSC_LINK
64-
65-
yarn package:prod
66-
yarn package:mas
67-
rm -rf release/mac
68-
mv release/mas-universal/Redis-Insight-mac-universal-mas.pkg release/Redis-Insight-mac-universal-mas.pkg
69-
70-
- name: Build macos dmg (staging)
71-
if: (vars.ENV == 'staging' || vars.ENV == 'development') && inputs.target == vars.ALL
60+
- name: Build macos dmg
61+
if: inputs.target == vars.ALL
7262
run: |
7363
unset CSC_LINK
7464
7565
echo $APP_BUNDLE_VERSION
7666
echo $CSC_KEYCHAIN
7767
78-
yarn package:stage && yarn package:mas
68+
yarn package:prod
69+
yarn package:mas
7970
rm -rf release/mac
80-
8171
mv release/mas-universal/Redis-Insight-mac-universal-mas.pkg release/Redis-Insight-mac-universal-mas.pkg
8272
8373
# handle manual builds
@@ -87,11 +77,7 @@ jobs:
8777
unset CSC_LINK
8878
target=$(echo "${{inputs.target}}" | grep -oE 'build_macos_[^ ]+' | sed 's/build_macos_/dmg:/' | paste -sd ' ' -)
8979
90-
if [ "${{ vars.ENV == 'production' }}" == "true" ]; then
91-
yarn package:prod --mac $target
92-
else
93-
yarn package:stage --mac $target
94-
fi
80+
yarn package:prod --mac $target
9581
9682
rm -rf release/mac
9783

.github/workflows/pipeline-build-windows.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,12 @@ jobs:
4343
- name: Install plugins dependencies and build plugins
4444
run: yarn build:statics:win
4545

46-
- name: Build windows exe (production)
47-
if: vars.ENV == 'production'
46+
- name: Build windows exe
4847
run: |
4948
yarn package:prod
5049
rm -rf release/win-unpacked
5150
shell: bash
5251

53-
- name: Build windows exe (staging)
54-
if: (vars.ENV == 'staging' || vars.ENV == 'development')
55-
run: |
56-
yarn package:stage
57-
rm -rf release/win-unpacked
58-
shell: bash
59-
6052
- uses: actions/upload-artifact@v4
6153
with:
6254
name: windows-builds

.github/workflows/release-prod.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,19 @@ on:
99
type: string
1010

1111
jobs:
12-
tests-prod:
13-
name: Run all tests
14-
uses: ./.github/workflows/tests.yml
15-
secrets: inherit
16-
with:
17-
short_rte_list: false
18-
pre_release: true
19-
20-
builds-prod:
21-
name: Create all builds for release
22-
uses: ./.github/workflows/build.yml
23-
needs: tests-prod
24-
secrets: inherit
25-
with:
26-
environment: "production"
27-
target: "all"
12+
# Builds are reused from release-stage.yml - artifacts are already available
13+
# No need to run tests again (already passed in staging)
14+
# No need to rebuild (using the same production builds from staging)
2815

2916
virustotal-prod:
3017
name: Virustotal
3118
uses: ./.github/workflows/virustotal.yml
32-
needs: builds-prod
3319
secrets: inherit
3420
with:
3521
skip_report: true
3622

3723
aws-upload-prod:
38-
name: Realse to AWS S3
24+
name: Release to AWS S3
3925
uses: ./.github/workflows/aws-upload-prod.yml
4026
needs: virustotal-prod
4127
secrets: inherit

.github/workflows/release-stage.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: 📖 Release (stage)
33
on:
44
push:
55
branches:
6-
- "release/**"
6+
- 'release/**'
77

88
jobs:
99
tests:
@@ -14,15 +14,17 @@ jobs:
1414
short_rte_list: false
1515
pre_release: true
1616

17+
# Build once with production config - these artifacts will be reused for production release
1718
builds:
18-
name: Release stage builds
19+
name: Release builds (production config)
1920
uses: ./.github/workflows/build.yml
2021
needs: tests
2122
secrets: inherit
2223
with:
23-
environment: "staging"
24-
target: "all"
24+
environment: 'production'
25+
target: 'all'
2526

27+
# Upload to staging S3 for testing
2628
aws:
2729
uses: ./.github/workflows/aws-upload-dev.yml
2830
needs: [builds]
@@ -31,33 +33,21 @@ jobs:
3133
with:
3234
pre-release: true
3335

34-
# Remove artifacts from github actions
35-
remove-artifacts:
36-
name: Remove artifacts
37-
needs: [aws]
38-
if: always()
39-
runs-on: ubuntu-latest
40-
41-
steps:
42-
- uses: actions/checkout@v4
43-
- name: Remove all artifacts
44-
uses: ./.github/actions/remove-artifacts # Remove artifacts from github actions
45-
4636
approve-production-release:
4737
name: Approve production release
48-
needs: [tests, builds, aws, remove-artifacts]
38+
needs: [tests, builds, aws]
4939
if: |
5040
always() &&
5141
needs.tests.result == 'success' &&
5242
needs.builds.result == 'success' &&
53-
needs.aws.result == 'success' &&
54-
needs.remove-artifacts.result == 'success'
43+
needs.aws.result == 'success'
5544
runs-on: ubuntu-latest
5645
environment: 'production-approve'
5746
steps:
5847
- name: Approval for production release
5948
run: echo "Production release approved for branch ${{ github.ref_name }}"
6049

50+
# Release to production - reuses the same builds from staging
6151
release-prod:
6252
name: Release to production
6353
needs: [approve-production-release]

redisinsight/api/config/production.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030
],
3131
},
3232
server: {
33-
env: 'production',
33+
env: process.env.RI_SERVER_ENV || 'production',
3434
},
3535
analytics: {
3636
writeKey:

redisinsight/desktop/app.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import {
1616
initCloudHandlers,
1717
electronStore,
1818
} from 'desktopSrc/lib'
19-
import { wrapErrorMessageSensitiveData } from 'desktopSrc/utils'
19+
import {
20+
wrapErrorMessageSensitiveData,
21+
loadRuntimeConfig,
22+
} from 'desktopSrc/utils'
2023
import { configMain as config } from 'desktopSrc/config'
2124
import {
2225
deepLinkHandler,
@@ -32,6 +35,10 @@ if (!config.isProduction) {
3235
let deepLink: undefined | string
3336

3437
const init = async () => {
38+
// Load runtime config before starting the API server
39+
// This allows swapping configs at packaging time without rebuilding
40+
loadRuntimeConfig()
41+
3542
await launchApiServer()
3643
initLogging()
3744
initElectronHandlers()

redisinsight/desktop/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './wrapErrorSensitiveData'
33
export * from './getAssetPath'
44
export * from './showOrCreateWindow'
55
export * from './window-size'
6+
export * from './loadRuntimeConfig'

0 commit comments

Comments
 (0)