Skip to content

Commit ae44147

Browse files
committed
Fix CIs and scripts for subgraphs
1 parent c22e703 commit ae44147

7 files changed

Lines changed: 43 additions & 42 deletions

File tree

.github/workflows/thegraph_dev_deploy.yml

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,36 @@ on:
44
workflow_dispatch:
55
inputs:
66
network:
7-
description: "Network for Subgraph deployment - (Gnosis Chain or Ethereum)"
7+
description: "Network for Subgraph deployment - Ethereum Mainnet (Mainnet) or Gnosis Chain (Gnosis)"
88
required: true
99
options:
10-
- Ethereum
11-
- Gnosis Chain
10+
- mainnet
11+
- gnosis
1212
type: choice
13-
14-
15-
defaults:
16-
run:
17-
working-directory: subgraph/
13+
type:
14+
description: "Brige type: Home or Foreign"
15+
required: true
16+
options:
17+
- home
18+
- foreign
19+
type: choice
1820

1921
concurrency:
2022
group: ${{ github.workflow }}-${{ github.ref }}
2123
cancel-in-progress: true
2224

23-
2425
jobs:
2526
deploy:
2627
name: Deployment
2728
runs-on: ubuntu-latest
2829
outputs:
2930
random_id: ${{ steps.random_id.outputs.random_id }}
31+
env:
32+
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
33+
TYPE: ${{ inputs.type }}
34+
NETWORK: ${{ inputs.network }}
35+
DEBUG: true
36+
SUBGRAPH_NAME: gbc-bridge-${{ inputs.type }}
3037
steps:
3138
- uses: actions/checkout@v4
3239

@@ -51,31 +58,18 @@ jobs:
5158
with:
5259
node-version-file: '.nvmrc'
5360

54-
- name: Install graph-cli & dependencies
61+
- name: Install dependencies & build subgraphs
5562
run: |
56-
yarn global add @graphprotocol/graph-cli
63+
cd subgraph
5764
yarn install
58-
59-
- name: Build Subgraph
60-
run: yarn codegen && yarn build
61-
62-
- name: Authenticate to Subgraph Studio
63-
run: graph auth --studio ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
64-
65-
- name: Deploy Subgraph for ETH Mainnet
66-
if: ${{ inputs.network == 'Ethereum' }}
67-
env:
68-
SUBGRAPH_NAME: gbc-bridge-mainnet
69-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
70-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
71-
72-
- name: Deploy Subgraph for Gnosis Chain
73-
if: ${{ inputs.network == 'Gnosis Chain' }}
74-
env:
75-
SUBGRAPH_NAME: gbc-bridge-gnosis
76-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
77-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
65+
yarn codegen
66+
yarn build
7867
68+
- name: Deploy Subgraphs
69+
env:
70+
SUBGRAPH_LABELS: "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
71+
run: |
72+
yarn deploy
7973
8074
notify:
8175
uses: ./.github/workflows/slack_release_notification.yml

subgraph/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
"build": "./scripts/build.sh",
88
"deploy": "./scripts/deploy.sh",
99
"deploy:local": "./scripts/deploy-local.sh",
10+
"deploy-test": "./scripts/deploy-test.sh",
1011
"test": "graph test"
1112
},
1213
"dependencies": {
13-
"@graphprotocol/graph-cli": "^0.60.0",
14+
"@graphprotocol/graph-cli": "^0.97.0",
1415
"@graphprotocol/graph-ts": "0.31.0",
15-
"ejs": "^3.1.10"
16+
"ejs": "^3.1.10"
1617
},
1718
"devDependencies": {
1819
"matchstick-as": "0.5.0",
1920
"mustache": "^4.2.0"
2021
}
21-
}
22+
}

subgraph/scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ if [ -d "build" ]; then
1010
fi
1111

1212
# Run build to generate deployable version
13-
graph build
13+
graph build

subgraph/scripts/codegen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ fi
2828
mustache $CONFIG_FILE $SUBGRAPH_TEMPLATE > subgraph.yaml
2929

3030
# Run codegen to generate Types
31-
graph codegen
31+
graph codegen

subgraph/scripts/deploy-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ GENERATED_FILE="subgraph.yaml"
2525
if [[ $DEBUG = false && -f $GENERATED_FILE ]]; then
2626
echo "Cleaning generated file"
2727
rm $GENERATED_FILE
28-
fi
28+
fi

subgraph/scripts/deploy.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ source "./scripts/build.sh"
55

66
if [ -z $SUBGRAPH_NAME ]; then echo "No Subgraph Name Environment Variable!"; exit 1; fi
77
if [ -z $ACCESS_TOKEN ]; then echo "No ACCESS_TOKEN Environment Variable!"; exit 1; fi
8+
if [ -z $SUBGRAPH_LABELS ]; then echo "No SUBGRAPH_LABELS Environment Variable!"; exit 1; fi
89

9-
graph auth --product subgraph-studio $ACCESS_TOKEN
10+
graph auth --studio $ACCESS_TOKEN
1011

1112
# @TODO deploying directly to $SUBGRAPH_NAME is prone to errors
1213
# @TODO use GRAPH_ADMIN_NODE_ENDPOINT var to deploy multiple envs (local, etc)
1314
echo "Deploying to $SUBGRAPH_NAME"
14-
graph deploy --product subgraph-studio $SUBGRAPH_NAME
15+
graph deploy --studio $SUBGRAPH_NAME -l $SUBGRAPH_LABELS
1516

1617
# @TODO we might reuse subgraph.yaml only removing when TYPE is diff from previous
1718
GENERATED_FILE="subgraph.yaml"
1819
if [[ $DEBUG = false && -f $GENERATED_FILE ]]; then
1920
echo "Cleaning generated file"
2021
rm $GENERATED_FILE
21-
fi
22+
fi

subgraph/scripts/env.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ set -o errexit
55

66
# Exporting variables from the env file and making them available in the code below
77
set -a
8-
source .env
8+
9+
if [ -f .env ]; then
10+
echo "Loading .env file"
11+
source .env
12+
fi
13+
914
set +a
1015

1116
# Type is required to Generate Specific subgraph.yaml
@@ -17,4 +22,4 @@ SUBGRAPH_TEMPLATE=subgraph-$TYPE.template.yaml
1722
CONFIG_FILE=config/$NETWORK.json
1823

1924
if [ ! -f "$CONFIG_FILE" ]; then echo "Config $CONFIG_FILE file does not exist."; exit 1; fi
20-
if [ ! -f "$SUBGRAPH_TEMPLATE" ]; then echo "Template $SUBGRAPH_TEMPLATE file does not exist."; exit 1; fi
25+
if [ ! -f "$SUBGRAPH_TEMPLATE" ]; then echo "Template $SUBGRAPH_TEMPLATE file does not exist."; exit 1; fi

0 commit comments

Comments
 (0)