Skip to content

Commit 478b0f7

Browse files
committed
CI: subgraphs - update prod workflow, update readme
1 parent 44d816b commit 478b0f7

4 files changed

Lines changed: 26 additions & 38 deletions

File tree

.github/workflows/thegraph_dev_deploy.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
outputs:
3030
random_id: ${{ steps.random_id.outputs.random_id }}
3131
env:
32-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
32+
DEPLOY_API_KEY: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
3333
TYPE: ${{ inputs.type }}
3434
NETWORK: ${{ inputs.network }}
3535
DEBUG: true
@@ -48,11 +48,6 @@ jobs:
4848
echo "This branch is excluded from workflow dispatch."
4949
exit 1
5050
51-
- name: Generate Random ID
52-
id: random_id
53-
run: |
54-
echo "random_id=$(openssl rand -hex 4)" >> $GITHUB_OUTPUT
55-
5651
- name: Setup Node.js
5752
uses: actions/setup-node@v4
5853
with:
@@ -64,7 +59,12 @@ jobs:
6459
yarn install
6560
yarn codegen
6661
yarn build
67-
62+
63+
- name: Generate Random ID
64+
id: random_id
65+
run: |
66+
echo "random_id=$(openssl rand -hex 4)" >> $GITHUB_OUTPUT
67+
6868
- name: Deploy Subgraphs
6969
env:
7070
SUBGRAPH_LABELS: "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"

.github/workflows/thegraph_prod_deploy.yml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ jobs:
2323
deploy:
2424
name: Deployment
2525
runs-on: ubuntu-latest
26-
defaults:
27-
run:
28-
shell: bash
29-
working-directory: ./subgraph
26+
env:
27+
DEPLOY_API_KEY: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
28+
TYPE: ${{ inputs.type }}
29+
NETWORK: ${{ inputs.network }}
30+
DEBUG: true
31+
SUBGRAPH_NAME: gbc-bridge-${{ inputs.type }}
3032
if: github.ref == 'refs/heads/main'
3133
steps:
3234
- uses: actions/checkout@v4
@@ -61,31 +63,17 @@ jobs:
6163
yarn codegen
6264
yarn build
6365
64-
- name: Authenticate to Subgraph Studio
65-
run: graph auth --studio ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
66-
67-
# Script to deploy to production environment
6866
- name: Generate Random ID for buildcode
6967
id: random_id
7068
run: |
7169
echo "random_id=$(openssl rand -hex 4)" >> $GITHUB_OUTPUT
7270
73-
- name: Deploy Subgraph
74-
run: yarn deploy -l "${{ steps.release_tag.outputs.tag }}-${{ steps.random_id.outputs.random_id }}"
75-
76-
- name: Deploy Subgraph for ETH Mainnet
77-
if: ${{ inputs.network == 'Ethereum' }}
78-
env:
79-
SUBGRAPH_NAME: gbc-bridge-mainnet
80-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
81-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
82-
83-
- name: Deploy Subgraph for Gnosis Chain
84-
if: ${{ inputs.network == 'Gnosis Chain' }}
71+
- name: Deploy Subgraphs
8572
env:
86-
SUBGRAPH_NAME: gbc-bridge-gnosis
87-
ACCESS_TOKEN: ${{ secrets.THEGRAPH_DEPLOY_API_KEY }}
88-
run: yarn deploy -l "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
73+
SUBGRAPH_LABELS: "${{ github.ref_name }}-${{ steps.random_id.outputs.random_id }}"
74+
run: |
75+
cd subgraph
76+
yarn deploy
8977
9078
notify:
9179
uses: ./.github/workflows/slack_release_notification.yml

subgraph/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Generate Types
3737

3838
- yarn codegen
3939

40-
Deploy (Remember to edit ACCESS_TOKEN and SUBGRAPH_NAME env vars)
40+
Deploy (Remember to edit THEGRAPH_DEPLOY_API_KEY and SUBGRAPH_NAME env vars)
4141

4242
- yarn deploy
4343

@@ -69,11 +69,11 @@ NETOWRK=mainnet
6969

7070
### GNOSIS
7171

72-
- set $ACCESS_TOKEN at .env file ($ACCESS_TOKEN != $DEPLOY_KEY) $ACCESS_TOKEN value comes from subgraph created on HostedService
72+
- set $DEPLOY_API_KEY at .env file. $DEPLOY_API_KEY value comes from subgraph created on HostedService
7373
- run yarn deploy
7474

7575
### MAINNET
7676

77-
- run graph auth --studio \$DEPLOY_KEY
78-
- take \$DEPLOY_KEY from created subgraph on Subgraph Studio
79-
- run graph deploy --studio <subgraph_slug>
77+
- run graph auth \$DEPLOY_API_KEY
78+
- take \$DEPLOY_API_KEY from created subgraph on Subgraph Studio
79+
- run graph deploy <subgraph_slug>

subgraph/scripts/deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ set -e
44
source "./scripts/build.sh"
55

66
if [ -z $SUBGRAPH_NAME ]; then echo "No Subgraph Name Environment Variable!"; exit 1; fi
7-
if [ -z $ACCESS_TOKEN ]; then echo "No ACCESS_TOKEN Environment Variable!"; exit 1; fi
7+
if [ -z $DEPLOY_API_KEY ]; then echo "No DEPLOY_API_KEY Environment Variable!"; exit 1; fi
88
if [ -z $SUBGRAPH_LABELS ]; then echo "No SUBGRAPH_LABELS Environment Variable!"; exit 1; fi
99

10-
graph auth --studio $ACCESS_TOKEN
10+
graph auth $DEPLOY_API_KEY
1111

1212
# @TODO deploying directly to $SUBGRAPH_NAME is prone to errors
1313
# @TODO use GRAPH_ADMIN_NODE_ENDPOINT var to deploy multiple envs (local, etc)
1414
echo "Deploying to $SUBGRAPH_NAME"
15-
graph deploy --studio $SUBGRAPH_NAME -l $SUBGRAPH_LABELS
15+
graph deploy $SUBGRAPH_NAME -l $SUBGRAPH_LABELS
1616

1717
# @TODO we might reuse subgraph.yaml only removing when TYPE is diff from previous
1818
GENERATED_FILE="subgraph.yaml"

0 commit comments

Comments
 (0)