Skip to content

Commit cc2ba98

Browse files
committed
ci(subgraph): add GitHub Actions workflow for deploying subgraph
1 parent 42e7a52 commit cc2ba98

File tree

2 files changed

+78
-99
lines changed

2 files changed

+78
-99
lines changed

.drone.yml

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -611,105 +611,6 @@ steps:
611611
password:
612612
from_secret: dockerhub-password
613613

614-
---
615-
kind: pipeline
616-
type: docker
617-
name: subgraph deploy
618-
619-
trigger:
620-
event:
621-
- promote
622-
target:
623-
# deploy the dataprotector subgraph for the staging environment
624-
- subgraph-deploy-staging
625-
# deploy the dataprotector subgraph
626-
- subgraph-deploy-tmp
627-
# deploy the dataprotector subgraph for the prod environment
628-
- subgraph-deploy-prod
629-
branch:
630-
- develop
631-
- main
632-
633-
steps:
634-
- name: install deps
635-
image: node:18.19
636-
pull: always
637-
commands:
638-
- cd packages/subgraph
639-
- npm ci
640-
641-
- name: deploy-v2-staging
642-
image: node:18.19
643-
params:
644-
- START_BLOCK
645-
environment:
646-
GRAPHNODE_URL:
647-
from_secret: graphnode-url-staging
648-
IPFS_URL:
649-
from_secret: ipfs-url-staging
650-
ENV: staging
651-
commands:
652-
- cd packages/subgraph
653-
- export SUBGRAPH_NAME=bellecour/staging-dataprotector-v2
654-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
655-
- npm run codegen
656-
- npm run build
657-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
658-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $(npm pkg get version)
659-
when:
660-
target:
661-
- subgraph-deploy-staging
662-
branch:
663-
- develop
664-
665-
- name: deploy-v2-tmp
666-
image: node:18.19
667-
params:
668-
- START_BLOCK
669-
environment:
670-
GRAPHNODE_URL:
671-
from_secret: graphnode-url
672-
IPFS_URL:
673-
from_secret: ipfs-url
674-
ENV: prod
675-
commands:
676-
- cd packages/subgraph
677-
- export SUBGRAPH_NAME=bellecour/tmp-dataprotector-v2
678-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
679-
- npm run codegen
680-
- npm run build
681-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
682-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $DRONE_COMMIT
683-
when:
684-
target:
685-
- subgraph-deploy-tmp
686-
branch:
687-
- main
688-
689-
- name: deploy-v2-prod
690-
image: node:18.19
691-
params:
692-
- START_BLOCK
693-
environment:
694-
GRAPHNODE_URL:
695-
from_secret: graphnode-url
696-
IPFS_URL:
697-
from_secret: ipfs-url
698-
ENV: prod
699-
commands:
700-
- cd packages/subgraph
701-
- export SUBGRAPH_NAME=bellecour/dataprotector-v2
702-
- echo "deploying commit $DRONE_COMMIT on subgraph $SUBGRAPH_NAME"
703-
- npm run codegen
704-
- npm run build
705-
- npx graph create --node $GRAPHNODE_URL $SUBGRAPH_NAME
706-
- npx graph deploy --node $GRAPHNODE_URL $SUBGRAPH_NAME --ipfs $IPFS_URL --version-label $(npm pkg get version)
707-
when:
708-
target:
709-
- subgraph-deploy-prod
710-
branch:
711-
- main
712-
713614
---
714615
#pipeline to deploy app whitelist on iexec
715616
kind: pipeline
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy Subgraph
2+
3+
on:
4+
push:
5+
branches: # Only run on these branches but also allow manual trigger of the workflow
6+
- develop
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
subgraph:
16+
- target: staging
17+
subgraph_name: "bellecour/staging-dataprotector-v2"
18+
branch: develop
19+
env_name: staging
20+
graphnode_url: ${{ secrets.GRAPHNODE_URL_STAGING }}
21+
ipfs_url: ${{ secrets.IPFS_URL_STAGING }}
22+
version_method: npm_version
23+
- target: tmp
24+
subgraph_name: "bellecour/tmp-dataprotector-v2"
25+
branch: main
26+
env_name: prod
27+
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
28+
ipfs_url: ${{ secrets.IPFS_URL }}
29+
version_method: commit
30+
- target: prod
31+
subgraph_name: "bellecour/dataprotector-v2"
32+
branch: main
33+
env_name: prod
34+
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
35+
ipfs_url: ${{ secrets.IPFS_URL }}
36+
version_method: npm_version
37+
38+
# Run only if the current branch matches the matrix branch
39+
if: github.ref == format('refs/heads/{0}', matrix.subgraph.branch)
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v3
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: 18
48+
49+
- name: Install Dependencies
50+
working-directory: packages/subgraph
51+
run: npm ci
52+
53+
- name: Run Codegen and Build
54+
working-directory: packages/subgraph
55+
run: |
56+
npm run codegen
57+
npm run build
58+
59+
- name: Set Version Label
60+
id: set_version
61+
working-directory: packages/subgraph
62+
run: |
63+
if [ "${{ matrix.subgraph.version_method }}" = "commit" ]; then
64+
echo "version=${GITHUB_SHA}" >> $GITHUB_OUTPUT
65+
else
66+
version=$(npm pkg get version | sed 's/"//g')
67+
echo "version=${version}" >> $GITHUB_OUTPUT
68+
fi
69+
70+
- name: Create Subgraph
71+
working-directory: packages/subgraph
72+
run: |
73+
npx graph create --node ${{ matrix.subgraph.graphnode_url }} ${{ matrix.subgraph.subgraph_name }}
74+
75+
- name: Deploy Subgraph
76+
working-directory: packages/subgraph
77+
run: |
78+
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)