-
Notifications
You must be signed in to change notification settings - Fork 46
99 lines (86 loc) · 2.96 KB
/
deploy-subgraph.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Deploy the Subgraph
on:
workflow_dispatch:
inputs:
graph_environment:
description: The Graph environment to deploy to
required: true
default: 'graph-studio-devnet'
type: choice
options:
- graph-studio-devnet
- graph-studio-testnet
- graph-studio-mainnet
subgraph:
description: The name of the subgraph to deploy
required: true
default: 'core'
type: choice
options:
- core
- drt
update:
description: Whether to update the subgraph with the current artifacts for the selected network.
required: true
default: true
type: boolean
permissions:
contents: read
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
environment: ${{ inputs.graph_environment }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
with:
egress-policy: audit
- name: Validate Network environment variable
if: ${{!startsWith(vars.NETWORK, 'arbitrum')}}
run: echo ${{vars.NETWORK}} && exit 1
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 20
- name: Install Yarn if running locally
if: ${{ env.ACT }}
run: npm install -g yarn
- name: Install the dependencies
run: yarn install
- name: Install jq and yq
if: ${{ inputs.update }}
run: |
mkdir bin
wget -qO bin/jq https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64
wget -qO bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
chmod a+x bin/jq bin/yq
- name: Update the subgraph definition
if: ${{ inputs.update }}
run: |
export PATH=$PWD/../bin:$PATH
yarn update:${{ inputs.subgraph }}:${{ vars.NETWORK }}
working-directory: subgraph
- name: Build the subgraph
run: |
yarn codegen:${{ inputs.subgraph }}
yarn build:${{ inputs.subgraph }}
working-directory: subgraph
- name: Authenticate with TheGraph Studio
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --studio
working-directory: subgraph
- name: Deploy the subgraph
run: |
# working around a graph bug which doesn't exit 1 on error: https://github.com/graphprotocol/graph-tooling/issues/1570
error=$(yarn deploy:${{ inputs.subgraph }}:${{ vars.NETWORK }})
echo "$error"
if [[ $error == *"Error"* ]]
then
echo "exiting..."
exit 1
else
echo "deployed successfully"
exit 0
fi
working-directory: subgraph