Skip to content

Commit 2cc0d60

Browse files
committed
feat: add DEPLOY_ENV variable for environment-specific deployment configurations
1 parent aa1e86a commit 2cc0d60

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

.env.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ SUBGRAPH_DEPLOY_KEY=...
1818

1919
# The network name for The Graph Network deployment (e.g., arbitrum-sepolia, arbitrum)
2020
SUBGRAPH_NETWORK_NAME=...
21+
22+
# DEPLOY_ENV specifies the deployment environment.
23+
# Possible values:
24+
# - empty: For production deployment.
25+
# - tmp: For temporary indexing and avoiding downtime during production deployment.
26+
# - staging: For staging environment deployment.
27+
DEPLOY_ENV=...

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,43 @@ docker run --rm \
114114
poco-subgraph-deployer
115115
```
116116

117+
#### Manual Deployment with Custom Values
118+
119+
To deploy the subgraph manually using the deploy script, follow these steps:
120+
121+
1. Set up environment variables in the `.env` file:
122+
123+
```bash
124+
NETWORK_NAME=<network-name>
125+
DEPLOY_ENV=<deploy-environment>
126+
IPFS_URL=<ipfs-url>
127+
GRAPHNODE_URL=<graphnode-url>
128+
VERSION_LABEL=<version-label>
129+
```
130+
131+
Example:
132+
133+
```bash
134+
NETWORK_NAME=bellecour
135+
DEPLOY_ENV=staging
136+
IPFS_URL=http://localhost:5001
137+
GRAPHNODE_URL=http://localhost:8020
138+
VERSION_LABEL=1.0.0
139+
```
140+
141+
**DEPLOY_ENV Possible Values:**
142+
- `empty`: For production deployment.
143+
- `tmp`: For temporary indexing and avoiding downtime during production deployment.
144+
- `staging`: For staging environment deployment.
145+
146+
2. Run the deploy script:
147+
148+
```bash
149+
npm run deploy
150+
```
151+
152+
This will deploy the subgraph using the specified values, including the `DEPLOY_ENV` variable for environment-specific configurations.
153+
117154
#### Github Actions pipeline deployment
118155

119156
The subgraph can be deployed using Github Actions (recommended). The dedicated job can be triggered with the desired configuration (environment, version, ...).

config/env.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import 'dotenv/config';
22
import { z } from 'zod';
33

44
const envSchema = z.object({
5+
DEPLOY_ENV: z
6+
.string()
7+
.default('staging')
8+
.refine((value) => ['tmp', 'staging', ''].includes(value), {
9+
message: 'DEPLOY_ENV must be one of: tmp, staging, or empty',
10+
}),
11+
512
NETWORK_NAME: z.string().min(1, 'NETWORK_NAME is required').default('bellecour'),
613

714
GRAPHNODE_URL: z
@@ -11,7 +18,7 @@ const envSchema = z.object({
1118

1219
IPFS_URL: z.string().url('IPFS_URL must be a valid URL').default('http://localhost:5001'),
1320

14-
VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('bellecour/poco-v5'),
21+
VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('dev'),
1522

1623
SUBGRAPH_SLUG: z.string().min(1, 'SUBGRAPH_SLUG must not be empty').optional(),
1724

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test:e2e": "mocha tests/e2e/**/*.ts",
1515
"coverage": "graph test -- -c",
1616
"create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}/${DEPLOY_ENV:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'",
17-
"deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'",
17+
"deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}/${DEPLOY_ENV:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'",
1818
"deploy-studio": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'",
1919
"all": "npm run build && npm run create && npm run deploy",
2020
"stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes",

0 commit comments

Comments
 (0)