1+ name : Build and Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - github-actions
8+ pull_request :
9+ branches :
10+ - main
11+
12+ env :
13+ NODE_VERSION : ' 22'
14+
15+ jobs :
16+ lint-and-test :
17+ name : Lint and Test
18+ runs-on : ubuntu-latest
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+
25+ - name : Setup Node and Dependencies
26+ uses : ./.github/actions/setup-node-and-deps
27+ with :
28+ node-version : ${{ env.NODE_VERSION }}
29+
30+ - name : Lint
31+ run : yarn lint
32+ continue-on-error : true
33+
34+ - name : Run tests
35+ run : yarn test
36+ continue-on-error : true
37+
38+ deploy :
39+ name : Deploy ${{ matrix.service }} (${{ matrix.environment }})
40+ runs-on : ubuntu-latest
41+ needs : lint-and-test
42+ if : github.event_name == 'push'
43+ environment : ${{ matrix.environment }}
44+ concurrency :
45+ group : deploy-${{ matrix.environment }}-${{ matrix.service }}
46+ cancel-in-progress : false
47+ strategy :
48+ matrix :
49+ include :
50+ # Development environment
51+ - service : notifications-service
52+ environment : dev
53+ pulumi_stack : public-dev-us-east-2
54+ db_secret : NOTIFICATIONS_SERVICE_DATABASE_URL
55+ cpu_limit : 250m
56+ memory_limit : 250Mi
57+ replicas : 1
58+ - service : swap-service
59+ environment : dev
60+ pulumi_stack : public-dev-us-east-2
61+ db_secret : SWAP_SERVICE_DATABASE_URL
62+ cpu_limit : 250m
63+ memory_limit : 250Mi
64+ replicas : 1
65+ - service : user-service
66+ environment : dev
67+ pulumi_stack : public-dev-us-east-2
68+ db_secret : USER_SERVICE_DATABASE_URL
69+ cpu_limit : 250m
70+ memory_limit : 250Mi
71+ replicas : 1
72+ # Production environment
73+ # - service: notifications-service
74+ # environment: prod
75+ # pulumi_stack: public-us-east-2
76+ # db_secret: NOTIFICATIONS_SERVICE_DATABASE_URL
77+ # cpu_limit: 250m
78+ # memory_limit: 250Mi
79+ # replicas: 2
80+ # - service: swap-service
81+ # environment: prod
82+ # pulumi_stack: public-us-east-2
83+ # db_secret: SWAP_SERVICE_DATABASE_URL
84+ # cpu_limit: 250m
85+ # memory_limit: 250Mi
86+ # replicas: 2
87+ # - service: user-service
88+ # environment: prod
89+ # pulumi_stack: public-us-east-2
90+ # db_secret: USER_SERVICE_DATABASE_URL
91+ # cpu_limit: 250m
92+ # memory_limit: 250Mi
93+ # replicas: 2
94+ steps :
95+ - name : Checkout code
96+ uses : actions/checkout@v4
97+ with :
98+ fetch-depth : 0
99+
100+ - name : Setup Node and Dependencies
101+ uses : ./.github/actions/setup-node-and-deps
102+ with :
103+ node-version : ${{ env.NODE_VERSION }}
104+
105+ - name : Set up Docker Buildx
106+ uses : docker/setup-buildx-action@v3
107+
108+ - name : Configure AWS Credentials
109+ uses : aws-actions/configure-aws-credentials@v4
110+ with :
111+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
112+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
113+ aws-region : us-east-2
114+
115+ - name : Install Pulumi CLI
116+ uses : pulumi/actions@v5
117+
118+ - name : Configure and Deploy with Pulumi
119+ working-directory : apps/${{ matrix.service }}/pulumi
120+ run : |
121+ pulumi stack select unchained/${{ matrix.pulumi_stack }}
122+ pulumi config set --path unchained:coinstack.assetName ${{ matrix.service }}
123+ pulumi config set --path unchained:coinstack.stack unchained/common/dependencies-us-east-2
124+ ${{ matrix.environment == 'dev' && 'pulumi config set --path unchained:coinstack.environment dev' || 'echo "Skipping environment config for prod"' }}
125+ pulumi config set --path unchained:coinstack.network mainnet
126+ pulumi config set --path unchained:coinstack.api.cpuLimit ${{ matrix.cpu_limit }}
127+ pulumi config set --path unchained:coinstack.api.memoryLimit ${{ matrix.memory_limit }}
128+ pulumi config set --path unchained:coinstack.api.replicas ${{ matrix.replicas }}
129+ pulumi up -f --yes --refresh --suppress-outputs
130+ env :
131+ NODE_OPTIONS : ' --no-experimental-strip-types'
132+ ADDITIONAL_ROOT_DOMAIN_NAME : shapeshift.com
133+ DOCKER_BUILDKIT : 1
134+ PULUMI_ACCESS_TOKEN : ${{ secrets.PULUMI_ACCESS_TOKEN }}
135+
136+ # Service URLs
137+ USER_SERVICE_URL : http://user-service-svc.unchained${{ matrix.environment == 'dev' && '-dev' || '' }}.svc.cluster.local:3000
138+ NOTIFICATIONS_SERVICE_URL : http://notifications-service-svc.unchained${{ matrix.environment == 'dev' && '-dev' || '' }}.svc.cluster.local:3000
139+ SWAP_SERVICE_URL : http://swap-service-svc.unchained${{ matrix.environment == 'dev' && '-dev' || '' }}.svc.cluster.local:3000
140+
141+ # Unchained API URLs (dynamic based on environment)
142+ VITE_UNCHAINED_ETHEREUM_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.ethereum.shapeshift.com
143+ VITE_UNCHAINED_ETHEREUM_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.ethereum.shapeshift.com
144+ VITE_UNCHAINED_AVALANCHE_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.avalanche.shapeshift.com
145+ VITE_UNCHAINED_AVALANCHE_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.avalanche.shapeshift.com
146+ VITE_UNCHAINED_OPTIMISM_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.optimism.shapeshift.com
147+ VITE_UNCHAINED_OPTIMISM_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.optimism.shapeshift.com
148+ VITE_UNCHAINED_BNBSMARTCHAIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bnbsmartchain.shapeshift.com
149+ VITE_UNCHAINED_BNBSMARTCHAIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bnbsmartchain.shapeshift.com
150+ VITE_UNCHAINED_POLYGON_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.polygon.shapeshift.com
151+ VITE_UNCHAINED_POLYGON_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.polygon.shapeshift.com
152+ VITE_UNCHAINED_GNOSIS_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.gnosis.shapeshift.com
153+ VITE_UNCHAINED_GNOSIS_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.gnosis.shapeshift.com
154+ VITE_UNCHAINED_ARBITRUM_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum.shapeshift.com
155+ VITE_UNCHAINED_ARBITRUM_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum.shapeshift.com
156+ VITE_UNCHAINED_ARBITRUM_NOVA_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum-nova.shapeshift.com
157+ VITE_UNCHAINED_ARBITRUM_NOVA_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum-nova.shapeshift.com
158+ VITE_UNCHAINED_BASE_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.base.shapeshift.com
159+ VITE_UNCHAINED_BASE_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.base.shapeshift.com
160+ VITE_UNCHAINED_BITCOIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bitcoin.shapeshift.com
161+ VITE_UNCHAINED_BITCOIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bitcoin.shapeshift.com
162+ VITE_UNCHAINED_DOGECOIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.dogecoin.shapeshift.com
163+ VITE_UNCHAINED_DOGECOIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.dogecoin.shapeshift.com
164+ VITE_UNCHAINED_LITECOIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.litecoin.shapeshift.com
165+ VITE_UNCHAINED_LITECOIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.litecoin.shapeshift.com
166+ VITE_UNCHAINED_BITCOINCASH_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bitcoincash.shapeshift.com
167+ VITE_UNCHAINED_BITCOINCASH_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bitcoincash.shapeshift.com
168+ VITE_UNCHAINED_COSMOS_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.cosmos.shapeshift.com
169+ VITE_UNCHAINED_COSMOS_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.cosmos.shapeshift.com
170+ VITE_UNCHAINED_THORCHAIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.thorchain.shapeshift.com
171+ VITE_UNCHAINED_THORCHAIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.thorchain.shapeshift.com
172+ VITE_UNCHAINED_MAYACHAIN_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.mayachain.shapeshift.com
173+ VITE_UNCHAINED_MAYACHAIN_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.mayachain.shapeshift.com
174+ VITE_UNCHAINED_SOLANA_HTTP_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.solana.shapeshift.com
175+ VITE_UNCHAINED_SOLANA_WS_URL : wss://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.solana.shapeshift.com
176+
177+ # Node URLs (dynamic based on environment)
178+ VITE_ETHEREUM_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.ethereum.shapeshift.com/api/v1/jsonrpc
179+ VITE_AVALANCHE_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.avalanche.shapeshift.com/api/v1/jsonrpc
180+ VITE_OPTIMISM_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.optimism.shapeshift.com/api/v1/jsonrpc
181+ VITE_BNBSMARTCHAIN_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.bnbsmartchain.shapeshift.com/api/v1/jsonrpc
182+ VITE_POLYGON_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.polygon.shapeshift.com/api/v1/jsonrpc
183+ VITE_GNOSIS_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.gnosis.shapeshift.com/api/v1/jsonrpc
184+ VITE_ARBITRUM_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum.shapeshift.com/api/v1/jsonrpc
185+ VITE_ARBITRUM_NOVA_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.arbitrum-nova.shapeshift.com/api/v1/jsonrpc
186+ VITE_BASE_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.base.shapeshift.com/api/v1/jsonrpc
187+ VITE_THORCHAIN_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.thorchain.shapeshift.com/lcd
188+ VITE_MAYACHAIN_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.mayachain.shapeshift.com/lcd
189+ VITE_SOLANA_NODE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.solana.shapeshift.com/api/v1/jsonrpc
190+
191+ # Midgard URLs (dynamic based on environment)
192+ VITE_THORCHAIN_MIDGARD_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.thorchain.shapeshift.com/midgard/v2
193+ VITE_MAYACHAIN_MIDGARD_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.mayachain.shapeshift.com/midgard/v2
194+
195+ # DEX/Swapper URLs
196+ VITE_CHAINFLIP_API_URL : https://chainflip-broker.io
197+ VITE_COWSWAP_BASE_URL : https://api.cow.fi
198+ VITE_JUPITER_API_URL : https://quote-api.jup.ag/v6
199+ VITE_PORTALS_BASE_URL : https://api.portals.fi
200+ VITE_RELAY_API_URL : https://api.relay.link
201+ VITE_ZRX_BASE_URL : https://${{ matrix.environment == 'dev' && 'dev-' || '' }}api.proxy.shapeshift.com/api/v1/zrx/
202+
203+ # Secrets (from GitHub Secrets)
204+ ACCOUNT_ID_SALT : ${{ secrets.ACCOUNT_ID_SALT }}
205+ DATABASE_URL : ${{ secrets[matrix.db_secret] }}
206+ EXPO_ACCESS_TOKEN : ${{ secrets.EXPO_ACCESS_TOKEN }}
207+ VITE_BEBOP_API_KEY : ${{ secrets.BEBOP_API_KEY }}
208+ VITE_CHAINFLIP_API_KEY : ${{ secrets.CHAINFLIP_API_KEY }}
209+ VITE_NEAR_INTENTS_API_KEY : ${{ secrets.NEAR_INTENTS_API_KEY }}
0 commit comments