Skip to content

Commit e960c35

Browse files
committed
feat: add deploy key and network name to subgraph deployment configuration
1 parent e689dc3 commit e960c35

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

.github/workflows/deploy-subgraph-chainX.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
environment: ${{ github.event.inputs.network }}
2828
steps:
2929
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
3032
- uses: actions/setup-node@v4
3133
with:
3234
node-version: '20'
@@ -41,5 +43,5 @@ jobs:
4143
SUBGRAPH_DEPLOY_KEY: ${{ secrets.SUBGRAPH_DEPLOY_KEY }}
4244
SUBGRAPH_NETWORK_NAME: ${{ vars.SUBGRAPH_NETWORK_NAME }}
4345
SUBGRAPH_SLUG: ${{ vars.SUBGRAPH_SLUG }}
44-
VERSION_LABEL: ${{ github.event.inputs.version_label }}
45-
run: npm run deploy-chainX -- --deploy-key $SUBGRAPH_DEPLOY_KEY --network $SUBGRAPH_NETWORK_NAME --version-label $VERSION_LABEL
46+
VERSION_LABEL: ${{ github.event.inputs.version-label }}
47+
run: npm run deploy-chainX

.github/workflows/deploy-subgraph.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ jobs:
2828
environment: ${{ github.event.inputs.environment }}
2929
steps:
3030
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
3133
- uses: actions/setup-node@v4
3234
with:
3335
node-version: '20'
36+
cache: 'npm'
37+
cache-dependency-path: 'packages/subgraph'
3438

3539
- name: Install dependencies
3640
working-directory: packages/subgraph

packages/subgraph/.env.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ START_BLOCK=...
1515

1616
# The slug for the subgraph created on The Graph Network
1717
SUBGRAPH_SLUG=...
18+
19+
# The deploy key for The Graph Network deployment
20+
SUBGRAPH_DEPLOY_KEY=...
21+
22+
# The network name for The Graph Network deployment (e.g., arbitrum-sepolia, arbitrum)
23+
SUBGRAPH_NETWORK_NAME=...

packages/subgraph/config/env.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ const envSchema = z.object({
3131
.string()
3232
.min(1, 'SUBGRAPH_SLUG must not be empty')
3333
.optional(),
34+
35+
SUBGRAPH_DEPLOY_KEY: z
36+
.string()
37+
.min(1, 'SUBGRAPH_DEPLOY_KEY must not be empty')
38+
.optional(),
39+
40+
SUBGRAPH_NETWORK_NAME: z
41+
.string()
42+
.min(1, 'SUBGRAPH_NETWORK_NAME must not be empty')
43+
.optional(),
3444
});
3545

3646
export const env = envSchema.parse(process.env);

packages/subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"codegen": "graph codegen subgraph.template.yaml",
77
"build": "dotenv -e .env -- sh -c 'graph codegen subgraph.template.yaml && graph build subgraph.template.yaml --network ${NETWORK_NAME:-bellecour}'",
8-
"deploy-chainX": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} subgraph.template.yaml'",
8+
"deploy-chainX": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} subgraph.template.yaml --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'",
99
"create": "dotenv -e .env -- sh -c 'graph create --node ${GRAPHNODE_URL:-http://localhost:8020} ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}dataprotector-v2'",
1010
"deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}dataprotector-v2 subgraph.template.yaml --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'",
1111
"clean": "rm -rf generated && rm -rf build",

0 commit comments

Comments
 (0)