Skip to content

Commit 82afe8f

Browse files
Le-CaignecgfournierProTartanLeGrandzguesmi
authored
ci: fix deployment ci (#49)
Co-authored-by: gfournieriExec <[email protected]> Co-authored-by: gfournieriExec <[email protected]> Co-authored-by: Ugo Mignon <[email protected]> Co-authored-by: Zied Guesmi <[email protected]>
1 parent 16e1052 commit 82afe8f

File tree

9 files changed

+119
-16
lines changed

9 files changed

+119
-16
lines changed

.env.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ IPFS_URL=...
99

1010
# The version label for the deployment (e.g., v1.0.0)
1111
VERSION_LABEL=...
12+
13+
# The slug for the subgraph created on The Graph Network
14+
SUBGRAPH_SLUG=...
15+
16+
# The deploy key for The Graph Network deployment
17+
SUBGRAPH_DEPLOY_KEY=...
18+
19+
# The network name for The Graph Network deployment (e.g., arbitrum-sepolia, arbitrum)
20+
SUBGRAPH_NETWORK_NAME=...
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy Subgraph - on TheGraph Network
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
inputs:
6+
network:
7+
description: 'Network'
8+
required: true
9+
type: choice
10+
options:
11+
- arbitrumSepolia
12+
- arbitrum
13+
version_label:
14+
description: 'Version label for the subgraph deployment'
15+
required: true
16+
type: string
17+
18+
jobs:
19+
build-and-test:
20+
uses: ./.github/workflows/main.yml
21+
with:
22+
node-version: 20
23+
24+
deploy:
25+
needs: build-and-test
26+
runs-on: ubuntu-latest
27+
# Associate the job with a GitHub Environment which has pre-defined variables and secrets.
28+
environment: ${{ github.event.inputs.network }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: '20'
35+
cache: 'npm'
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Codegen
41+
run: npm run codegen
42+
43+
- name: Deploy Subgraph
44+
env:
45+
SUBGRAPH_DEPLOY_KEY: ${{ secrets.SUBGRAPH_DEPLOY_KEY }}
46+
SUBGRAPH_NETWORK_NAME: ${{ vars.SUBGRAPH_NETWORK_NAME }}
47+
SUBGRAPH_SLUG: ${{ vars.SUBGRAPH_SLUG }}
48+
VERSION_LABEL: ${{ github.event.inputs.version_label }}
49+
run: npm run deploy-studio
50+
51+
- name: Deployment Success
52+
run: |
53+
echo "🎉 Subgraph deployment completed successfully!"
54+
echo "📋 Next steps:"
55+
echo "1. Go to TheGraph Studio: https://thegraph.com/studio/"
56+
echo "2. Connect with the iExec wallet"
57+
echo "3. Publish the subgraph to make it publicly available"
58+
echo "4. Subgraph details:"
59+
echo " - Slug: ${{ vars.SUBGRAPH_SLUG }}"
60+
echo " - Network: ${{ vars.SUBGRAPH_NETWORK_NAME }}"
61+
echo " - Version: ${{ github.event.inputs.version_label }}"

.github/workflows/deploy-subgraph.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@ on:
1212
- staging
1313
- production
1414
- tmp
15-
# Add new networks when needed. Do not forget to add necessary data in the networks.json file.
16-
networkName:
17-
description: 'Network Name'
18-
required: false
19-
default: bellecour
20-
type: choice
21-
options:
22-
- bellecour
2315
versionLabel:
2416
description: 'Version Label for Subgraph Deployment'
25-
required: false
26-
default: develop
17+
required: true
2718
type: string
2819

2920
jobs:
21+
build-and-test:
22+
uses: ./.github/workflows/main.yml
23+
with:
24+
node-version: 20
25+
3026
deploy:
3127
runs-on: ubuntu-latest
3228
# Associate the job with a GitHub Environment which has pre-defined variables and secrets.
@@ -39,13 +35,14 @@ jobs:
3935
uses: actions/setup-node@v4
4036
with:
4137
node-version: '20'
38+
cache: 'npm'
4239

4340
- name: Install dependencies
4441
run: npm ci
4542

4643
- name: Deploy Subgraph
4744
env:
48-
NETWORK_NAME: ${{ github.event.inputs.networkName }}
45+
NETWORK_NAME: bellecour
4946
VERSION_LABEL: ${{ github.event.inputs.versionLabel }}
5047
GRAPHNODE_URL: ${{ vars.GRAPHNODE_URL }}
5148
IPFS_URL: ${{ vars.IPFS_URL }}

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: default
22

33
on:
44
pull_request:
5+
workflow_call:
6+
inputs:
7+
node-version:
8+
description: Node.js version to use
9+
required: false
10+
type: number
11+
default: 20
512

613
concurrency:
714
group: ci-${{ github.head_ref }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ node_modules
22
build
33
generated
44
yarn.lock
5-
subgraph.test.yaml
65
test-stack/.env
76
tests/.bin
87
tests/.latest.json

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.18
1+
20

config/env.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const envSchema = z.object({
1212
IPFS_URL: z.string().url('IPFS_URL must be a valid URL').default('http://localhost:5001'),
1313

1414
VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('bellecour/poco-v5'),
15+
16+
SUBGRAPH_SLUG: z.string().min(1, 'SUBGRAPH_SLUG must not be empty').optional(),
17+
18+
SUBGRAPH_DEPLOY_KEY: z.string().min(1, 'SUBGRAPH_DEPLOY_KEY must not be empty').optional(),
19+
20+
SUBGRAPH_NETWORK_NAME: z.string().min(1, 'SUBGRAPH_NETWORK_NAME must not be empty').optional(),
1521
});
1622

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

networks.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@
4343
"startBlock": 145249746
4444
}
4545
},
46+
"arbitrum-one": {
47+
"ERC1538": {
48+
"address": "0x0000000000000000000000000000000000000000",
49+
"startBlock": 0
50+
},
51+
"Core": {
52+
"address": "0x0000000000000000000000000000000000000000",
53+
"startBlock": 0
54+
},
55+
"AppRegistry": {
56+
"address": "0x0000000000000000000000000000000000000000",
57+
"startBlock": 0
58+
},
59+
"DatasetRegistry": {
60+
"address": "0x0000000000000000000000000000000000000000",
61+
"startBlock": 0
62+
},
63+
"WorkerpoolRegistry": {
64+
"address": "0x0000000000000000000000000000000000000000",
65+
"startBlock": 0
66+
}
67+
},
4668
"bellecour": {
4769
"ERC1538": {
4870
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
"scripts": {
88
"prepare": "husky",
99
"generate:typechain": "typechain --target ethers-v6 --out-dir generated/typechain './node_modules/@iexec/poco/build/contracts/*.json' --ts-nocheck",
10-
"build": "dotenv -e .env -- rm -rf generated && rm -rf build && npm run generate:typechain && graph codegen && graph build --network ${NETWORK_NAME:-bellecour}",
10+
"codegen": " npm run generate:typechain && graph codegen",
11+
"build": "dotenv -e .env -- sh -c 'npm run codegen && graph build --network ${NETWORK_NAME:-bellecour}'",
1112
"test": "npm run test:unit && npm run test:e2e",
1213
"test:unit": "graph test unit",
1314
"test:e2e": "mocha tests/e2e/**/*.ts",
1415
"coverage": "graph test -- -c",
15-
"create": "dotenv -e .env -- graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
16-
"deploy": "dotenv -e .env -- graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}",
16+
"create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}'",
17+
"deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-bellecour/poco-v5}'",
18+
"deploy-studio": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'",
1719
"all": "npm run build && npm run create && npm run deploy",
1820
"stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes",
1921
"start-test-stack": "npm run stop-test-stack && cd test-stack && export NETWORK_NAME=${NETWORK_NAME:-bellecour} && tsx prepare-test-env.ts && docker compose build && docker compose up -d",

0 commit comments

Comments
 (0)