Skip to content

Commit 8dc7111

Browse files
ci(subgraph): add GitHub Actions workflow for deploying subgraph (#415)
1 parent 57b8998 commit 8dc7111

File tree

2 files changed

+71
-99
lines changed

2 files changed

+71
-99
lines changed

.drone.yml

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -531,105 +531,6 @@ steps:
531531
password:
532532
from_secret: dockerhub-password
533533

534-
---
535-
kind: pipeline
536-
type: docker
537-
name: subgraph deploy
538-
539-
trigger:
540-
event:
541-
- promote
542-
target:
543-
# deploy the dataprotector subgraph for the staging environment
544-
- subgraph-deploy-staging
545-
# deploy the dataprotector subgraph
546-
- subgraph-deploy-tmp
547-
# deploy the dataprotector subgraph for the prod environment
548-
- subgraph-deploy-prod
549-
branch:
550-
- develop
551-
- main
552-
553-
steps:
554-
- name: install deps
555-
image: node:18.19
556-
pull: always
557-
commands:
558-
- cd packages/subgraph
559-
- npm ci
560-
561-
- name: deploy-v2-staging
562-
image: node:18.19
563-
params:
564-
- START_BLOCK
565-
environment:
566-
GRAPHNODE_URL:
567-
from_secret: graphnode-url-staging
568-
IPFS_URL:
569-
from_secret: ipfs-url-staging
570-
ENV: staging
571-
commands:
572-
- cd packages/subgraph
573-
- export SUBGRAPH_NAME=bellecour/staging-dataprotector-v2
574-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
575-
- npm run codegen
576-
- npm run build
577-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
578-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $(npm pkg get version)
579-
when:
580-
target:
581-
- subgraph-deploy-staging
582-
branch:
583-
- develop
584-
585-
- name: deploy-v2-tmp
586-
image: node:18.19
587-
params:
588-
- START_BLOCK
589-
environment:
590-
GRAPHNODE_URL:
591-
from_secret: graphnode-url
592-
IPFS_URL:
593-
from_secret: ipfs-url
594-
ENV: prod
595-
commands:
596-
- cd packages/subgraph
597-
- export SUBGRAPH_NAME=bellecour/tmp-dataprotector-v2
598-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
599-
- npm run codegen
600-
- npm run build
601-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
602-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $DRONE_COMMIT
603-
when:
604-
target:
605-
- subgraph-deploy-tmp
606-
branch:
607-
- main
608-
609-
- name: deploy-v2-prod
610-
image: node:18.19
611-
params:
612-
- START_BLOCK
613-
environment:
614-
GRAPHNODE_URL:
615-
from_secret: graphnode-url
616-
IPFS_URL:
617-
from_secret: ipfs-url
618-
ENV: prod
619-
commands:
620-
- cd packages/subgraph
621-
- export SUBGRAPH_NAME=bellecour/dataprotector-v2
622-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
623-
- npm run codegen
624-
- npm run build
625-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
626-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $(npm pkg get version)
627-
when:
628-
target:
629-
- subgraph-deploy-prod
630-
branch:
631-
- main
632-
633534
---
634535
#pipeline to deploy app whitelist on iexec
635536
kind: pipeline
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy Subgraph
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
include:
12+
- target: staging
13+
subgraph_name: "bellecour/staging-dataprotector-v2"
14+
branch: develop
15+
env_name: staging
16+
graphnode_url: ${{ secrets.GRAPHNODE_URL_STAGING }}
17+
ipfs_url: ${{ secrets.IPFS_URL_STAGING }}
18+
version_method: npm_version
19+
- target: tmp
20+
subgraph_name: "bellecour/tmp-dataprotector-v2"
21+
branch: main
22+
env_name: prod
23+
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
24+
ipfs_url: ${{ secrets.IPFS_URL }}
25+
version_method: commit
26+
- target: prod
27+
subgraph_name: "bellecour/dataprotector-v2"
28+
branch: main
29+
env_name: prod
30+
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
31+
ipfs_url: ${{ secrets.IPFS_URL }}
32+
version_method: npm_version
33+
34+
# Run only if the current branch matches the matrix branch
35+
if: github.ref == format('refs/heads/{0}', matrix.subgraph.branch)
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version: 18
41+
42+
- name: Install Dependencies
43+
working-directory: packages/subgraph
44+
run: npm ci
45+
46+
- name: Run Codegen and Build
47+
working-directory: packages/subgraph
48+
run: |
49+
npm run codegen
50+
npm run build
51+
52+
- name: Set Version Label
53+
id: set_version
54+
working-directory: packages/subgraph
55+
run: |
56+
if [ "${{ matrix.subgraph.version_method }}" = "commit" ]; then
57+
echo "version=${GITHUB_SHA}" >> $GITHUB_OUTPUT
58+
else
59+
version=$(npm pkg get version | sed 's/"//g')
60+
echo "version=${version}" >> $GITHUB_OUTPUT
61+
fi
62+
63+
- name: Create Subgraph
64+
working-directory: packages/subgraph
65+
run: |
66+
npx graph create --node ${{ matrix.subgraph.graphnode_url }} ${{ matrix.subgraph.subgraph_name }}
67+
68+
- name: Deploy Subgraph
69+
working-directory: packages/subgraph
70+
run: |
71+
npx graph deploy --node ${{ matrix.subgraph.graphnode_url }} ${{ matrix.subgraph.subgraph_name }} --ipfs ${{ matrix.subgraph.ipfs_url }} --version-label ${{ steps.set_version.outputs.version }}

0 commit comments

Comments
 (0)