Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
103fbef
feat: add deploy workflow for TheGraph Network
Le-Caignec Jul 25, 2025
187b6a7
feat: add build-and-test job to subgraph deployment workflows
Le-Caignec Jul 25, 2025
2f66ee3
fix: update node-version input to be optional with default value
Le-Caignec Jul 25, 2025
abbc35d
feat: enhance subgraph deployment workflow with version label and slu…
Le-Caignec Jul 25, 2025
7288fe2
fix: remove push trigger from deploy workflow and add arbitrum-one ne…
Le-Caignec Jul 25, 2025
be77f70
fix: correct version label input key in deploy workflow
Le-Caignec Jul 25, 2025
e689dc3
fix: adjust working-directory for build step in subgraph CI workflow
Le-Caignec Jul 25, 2025
e960c35
feat: add deploy key and network name to subgraph deployment configur…
Le-Caignec Jul 25, 2025
e308f0f
fix: correct input key for version label in deploy workflow
Le-Caignec Jul 25, 2025
c3ea6fa
feat: add code generation step to subgraph deployment workflows
Le-Caignec Jul 25, 2025
b33d638
feat: add deployment success message and next steps to subgraph workflow
Le-Caignec Jul 25, 2025
b4e0e0f
fix: remove unnecessary whitespace in deploy subgraph workflow
Le-Caignec Jul 25, 2025
b3787f4
fix: reorder deploy-chainX script in package.json for consistency
Le-Caignec Jul 25, 2025
d4aee0d
fix: update build script to ensure code generation runs before building
Le-Caignec Jul 25, 2025
615a3e7
fix: remove hardcoded addresses and start blocks from data sources in…
Le-Caignec Jul 25, 2025
9230937
Update .github/workflows/deploy-subgraph-chainX.yml
Le-Caignec Jul 28, 2025
30c0f17
Merge branch 'main' into fix/subgraph-ci-deployment
Le-Caignec Jul 28, 2025
c69b56c
Merge branch 'main' into fix/subgraph-ci-deployment
zguesmi Jul 28, 2025
503ab67
feat: Add deploy workflow for Subgraph on TheGraph Network
Le-Caignec Jul 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/deploy-subgraph-studio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy Subgraph - on TheGraph Network

on:
workflow_dispatch: # Manual trigger
inputs:
network:
description: 'Network'
required: true
type: choice
options:
- arbitrumSepolia
- arbitrum
version_label:
description: 'Version label for the subgraph deployment'
required: true
type: string

jobs:
build-and-test:
uses: ./.github/workflows/subgraph-ci.yml
with:
node-version: 20

deploy:
needs: build-and-test
runs-on: ubuntu-latest
# Associate the job with a GitHub Environment which has pre-defined variables and secrets.
environment: ${{ github.event.inputs.network }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'packages/subgraph'

- name: Install dependencies
working-directory: packages/subgraph
run: npm ci

- name: Codegen
working-directory: packages/subgraph
run: npm run codegen

- name: Deploy Subgraph
working-directory: packages/subgraph
env:
SUBGRAPH_DEPLOY_KEY: ${{ secrets.SUBGRAPH_DEPLOY_KEY }}
SUBGRAPH_NETWORK_NAME: ${{ vars.SUBGRAPH_NETWORK_NAME }}
SUBGRAPH_SLUG: ${{ vars.SUBGRAPH_SLUG }}
VERSION_LABEL: ${{ github.event.inputs.version_label }}
run: npm run deploy-studio

- name: Deployment Success
run: |
echo "🎉 Subgraph deployment completed successfully!"
echo "📋 Next steps:"
echo "1. Go to TheGraph Studio: https://thegraph.com/studio/"
echo "2. Connect with the iExec wallet"
echo "3. Publish the subgraph to make it publicly available"
echo "4. Subgraph details:"
echo " - Slug: ${{ vars.SUBGRAPH_SLUG }}"
echo " - Network: ${{ vars.SUBGRAPH_NETWORK_NAME }}"
echo " - Version: ${{ github.event.inputs.version_label }}"
22 changes: 12 additions & 10 deletions .github/workflows/deploy-subgraph.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Subgraph
name: Deploy Subgraph - on self-hosted node

on:
workflow_dispatch: # Triggered manually but we can also trigger with an release event
Expand All @@ -12,27 +12,29 @@ on:
- staging
- tmp
- prod
# Add new networks when needed. Do not forget to add necessary data in the networks.json file.
networkName:
description: 'Network Name'
required: false
default: bellecour
type: choice
options:
- bellecour

jobs:
build-and-test:
uses: ./.github/workflows/subgraph-ci.yml
with:
node-version: 20

deploy:
needs: build-and-test
runs-on:
group: Azure_runners
labels: [ self-hosted, Linux, X64 ]
# Associate the job with a GitHub Environment which has pre-defined variables and secrets.
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'packages/subgraph'

- name: Install dependencies
working-directory: packages/subgraph
Expand All @@ -52,7 +54,7 @@ jobs:
- name: Deploy Subgraph
working-directory: packages/subgraph
env:
NETWORK_NAME: ${{ github.event.inputs.networkName }}
NETWORK_NAME: bellecour
VERSION_LABEL: ${{ steps.set_version.outputs.version }}
GRAPHNODE_URL: ${{ vars.GRAPHNODE_URL }}
IPFS_URL: ${{ vars.IPFS_URL }}
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/subgraph-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Core Smart Contract - Default

on:
pull_request:
branches:
- '*'
paths:
- 'packages/subgraph/**'
workflow_call:
inputs:
node-version:
description: Node.js version to use
required: false
type: number
default: 20

concurrency:
group: ${{ github.ref }}-subgraph-ci
cancel-in-progress: true

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'npm'
cache-dependency-path: 'packages/subgraph'

- name: Install dependencies
working-directory: packages/subgraph
run: npm ci

- name: Check Format
working-directory: packages/subgraph
run: npm run check-format

- name: Codegen
working-directory: packages/subgraph
run: npm run codegen

# TODO: fix test command
# - name: Run unit tests
# working-directory: packages/subgraph
# run: npm run test

- name: Build
working-directory: packages/subgraph
run: npm run build
9 changes: 9 additions & 0 deletions packages/subgraph/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ VERSION_LABEL=...

# Start block number for local testing
START_BLOCK=...

# The slug for the subgraph created on The Graph Network
SUBGRAPH_SLUG=...

# The deploy key for The Graph Network deployment
SUBGRAPH_DEPLOY_KEY=...

# The network name for The Graph Network deployment (e.g., arbitrum-sepolia, arbitrum)
SUBGRAPH_NETWORK_NAME=...
49 changes: 35 additions & 14 deletions packages/subgraph/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,45 @@ import 'dotenv/config';
import { z } from 'zod';

const envSchema = z.object({
NETWORK_NAME: z.string().min(1, 'NETWORK_NAME is required').default('bellecour'),
NETWORK_NAME: z
.string()
.min(1, 'NETWORK_NAME is required')
.default('bellecour'),

GRAPHNODE_URL: z
.string()
.url('GRAPHNODE_URL must be a valid URL')
.default('http://localhost:8020'),
GRAPHNODE_URL: z
.string()
.url('GRAPHNODE_URL must be a valid URL')
.default('http://localhost:8020'),

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

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

START_BLOCK: z
.string()
.transform((val) => parseInt(val, 10))
.refine((val) => !isNaN(val) && val >= 0, {
message: 'START_BLOCK must be a valid non-negative integer',
})
.or(z.undefined()),
START_BLOCK: z
.string()
.transform((val) => parseInt(val, 10))
.refine((val) => !isNaN(val) && val >= 0, {
message: 'START_BLOCK must be a valid non-negative integer',
})
.or(z.undefined()),

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

SUBGRAPH_DEPLOY_KEY: z
.string()
.min(1, 'SUBGRAPH_DEPLOY_KEY must not be empty')
.optional(),

SUBGRAPH_NETWORK_NAME: z
.string()
.min(1, 'SUBGRAPH_NETWORK_NAME must not be empty')
.optional(),
});

export const env = envSchema.parse(process.env);
22 changes: 22 additions & 0 deletions packages/subgraph/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@
"startBlock": 145960686
}
},
"arbitrum-one": {
"DataProtector": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
},
"DatasetRegistry": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
},
"DataProtectorSharing": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
},
"AppRegistry": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
},
"AddOnlyAppWhitelistRegistry": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
}
},
"bellecour": {
"DataProtector": {
"address": "0x3a4Ab33F3D605e75b6D00A32A0Fa55C3628F6A59",
Expand Down
4 changes: 2 additions & 2 deletions packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"license": "UNLICENSED",
"scripts": {
"codegen": "graph codegen subgraph.template.yaml",
"build": "dotenv -e .env -- sh -c 'graph codegen subgraph.template.yaml && graph build subgraph.template.yaml --network ${NETWORK_NAME:-bellecour}'",
"deploy-theGraph": "graph deploy --node https://api.thegraph.com/deploy/ DataProtector",
"build": "dotenv -e .env -- sh -c 'npm run codegen && graph build subgraph.template.yaml --network ${NETWORK_NAME:-bellecour}'",
"create": "dotenv -e .env -- sh -c 'graph create --node ${GRAPHNODE_URL:-http://localhost:8020} ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}dataprotector-v2'",
"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}'",
"deploy-studio": "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}'",
"clean": "rm -rf generated && rm -rf build",
"test": "npm run codegen && graph test",
"all": " dotenv -e .env -- sh -c 'tsx ./test-stack/prepare-test-env.ts && npm run clean && npm run codegen && npm run build && npm run create && npm run deploy'",
Expand Down
10 changes: 0 additions & 10 deletions packages/subgraph/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ dataSources:
kind: ethereum/contract
source:
abi: DataProtector
address: "0x3a4Ab33F3D605e75b6D00A32A0Fa55C3628F6A59"
startBlock: 25455501
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -31,8 +29,6 @@ dataSources:
kind: ethereum/contract
source:
abi: DatasetRegistry
address: "0x0000000000000000000000000000000000000000"
startBlock: 25455501
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -53,8 +49,6 @@ dataSources:
kind: ethereum/contract
source:
abi: AppRegistry
address: "0x0000000000000000000000000000000000000000"
startBlock: 28566236
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -75,8 +69,6 @@ dataSources:
kind: ethereum/contract
source:
abi: DataProtectorSharing
address: "0x1390c3c6a545198809F1C7c5Dd2600ef74D60925"
startBlock: 28566236
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down Expand Up @@ -127,8 +119,6 @@ dataSources:
kind: ethereum/contract
source:
abi: AddOnlyAppWhitelistRegistry
address: "0x498D324F711b8998Be81818742e268dEE30347c6"
startBlock: 28566234
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down
Loading