Skip to content

Commit 7da4a89

Browse files
committed
fix: CI for subgraphs - dev deploy
1 parent 4b7968b commit 7da4a89

4 files changed

Lines changed: 35 additions & 27 deletions

File tree

.github/workflows/thegraph_dev_deploy.yml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ 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+
type:
14+
description: "Brige type: Home or Foreign"
15+
required: true
16+
options:
17+
- home
18+
- foreign
19+
type: choice
1320

1421
concurrency:
1522
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,6 +28,12 @@ jobs:
2128
runs-on: ubuntu-latest
2229
outputs:
2330
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 }}
2437
steps:
2538
- uses: actions/checkout@v4
2639

@@ -51,24 +64,13 @@ jobs:
5164
yarn install
5265
yarn codegen
5366
yarn build
54-
55-
- name: Authenticate to Subgraph Studio
56-
run: graph auth --studio ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
57-
58-
- name: Deploy Subgraph for ETH Mainnet
59-
if: ${{ inputs.network == 'Ethereum' }}
67+
68+
- name: Deploy Subgraphs
6069
env:
61-
SUBGRAPH_NAME: gbc-bridge-mainnet
62-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
63-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
70+
SUBGRAPH_LABELS: "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
71+
run: |
72+
yarn deploy
6473
65-
- name: Deploy Subgraph for Gnosis Chain
66-
if: ${{ inputs.network == 'Gnosis Chain' }}
67-
env:
68-
SUBGRAPH_NAME: gbc-bridge-gnosis
69-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
70-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
71-
7274
notify:
7375
uses: ./.github/workflows/slack_release_notification.yml
7476
if: ${{ always() }}

subgraph/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"version": "0.0.1",
44
"license": "MIT",
55
"scripts": {
6-
"codegen": "sh scripts/codegen.sh",
7-
"build": "sh scripts/build.sh",
8-
"deploy": "sh scripts/deploy.sh",
9-
"deploy:local": "sh scripts/deploy-local.sh",
10-
"deploy-test": "sh scripts/deploy-test.sh",
6+
"codegen": "./scripts/codegen.sh",
7+
"build": "./scripts/build.sh",
8+
"deploy": "./scripts/deploy.sh",
9+
"deploy:local": "./scripts/deploy-local.sh",
10+
"deploy-test": "./scripts/deploy-test.sh",
1111
"test": "graph test"
1212
},
1313
"dependencies": {

subgraph/scripts/deploy.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ 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"

subgraph/scripts/env.sh

Lines changed: 6 additions & 1 deletion
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

0 commit comments

Comments
 (0)