-
Notifications
You must be signed in to change notification settings - Fork 261
125 lines (110 loc) · 4.14 KB
/
call.deploy-subgraph.yml
File metadata and controls
125 lines (110 loc) · 4.14 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Reusable Workflow | Deploy Subgraph
on:
workflow_call:
inputs:
vendor:
required: true
description: "Where to deploy subgraph to; superfluid, goldsky, or graph"
type: string
deployment_env:
required: true
type: string
description: "The subgraph deployment env: v1, dev, feature"
network:
required: true
type: string
description: "The network you want to deploy to (matic, xdai, eth-mainnet, etc.) or `all` for all networks."
secrets:
SUBGRAPH_URL_TEMPLATE:
description: "Subgraph endpoint url template"
required: false
SATSUMA_DEPLOY_KEY:
description: "Satsuma deploy key"
required: false
THE_GRAPH_ACCESS_TOKEN:
description: "The Graph access token for deploying subgraphs"
required: false
GOLDSKY_API_KEY:
description: "Goldsky API key for deploying subgraphs"
required: false
AIRSTACK_API_KEY:
description: "Airstack API key for deploying subgraphs"
required: false
SUPERFLUID_IPFS_API:
description: "Superfluid IPFS API endpoint"
required: false
jobs:
show-contexts:
name: Show Contexts
runs-on: ubuntu-22.04
steps:
- name: Show contexts
env:
HEAD_REF: ${{ github.head_ref }}
GITHUB_REF: ${{ github.ref }}
run: |
echo github.event_name: ${{ github.event_name }}
echo github.sha: ${{ github.sha }}
echo github.repository: ${{ github.repository }}
echo github.ref: "$GITHUB_REF"
echo github.head_ref: "$HEAD_REF"
echo github.base_ref: ${{ github.base_ref }}
determine-networks:
name: Determine Networks
runs-on: ubuntu-22.04
outputs:
networks: ${{ steps.determine.outputs.networks }}
steps:
- uses: actions/checkout@v4
- name: "Determine vendors for the network"
id: determine
run: |
networks=$(jq -r --arg vendor "${{ inputs.vendor }}" --arg network "${{ inputs.network }}" '
if $network == "all" then
.[$vendor] | @json
else
[$network] | @json
end' packages/subgraph/tasks/vendorNetworkMap.json)
if [ -z "$networks" ] || [ "$networks" == "null" ]; then
echo "Unsupported vendor or network: ${{ inputs.vendor }} / ${{ inputs.network }}"
exit 1
fi
echo "networks=$networks" >> "$GITHUB_OUTPUT"
deploy-subgraph:
name: Build and Deploy Subgraph
runs-on: ubuntu-22.04
needs: determine-networks
strategy:
matrix:
network: ${{ fromJson(needs.determine-networks.outputs.networks) }}
fail-fast: false
defaults:
run:
shell: nix develop .#ci-default -c bash {0}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v19
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: "Install dependencies"
run: yarn install --frozen-lockfile
- name: "Build contracts"
run: yarn build
working-directory: ./packages/ethereum-contracts
# Version is from subgraph@<version> git tag if exists, else short git commit revision
- name: "Deploy to a node"
run: |
shortRev=$(git rev-parse --short ${{ github.sha }})
versionTag=$(git tag --contains ${{ github.sha }} | grep "^subgraph@" | sed 's/^subgraph@//')
versionLabel="${versionTag:-$shortRev}"
./tasks/deploy.sh -o ${{ inputs.vendor }} -n ${{ matrix.network }} -r ${{ inputs.deployment_env }} -v $versionLabel
working-directory: ./packages/subgraph
env:
SUBGRAPH_URL_TEMPLATE: ${{ secrets.SUBGRAPH_URL_TEMPLATE }}
SUPERFLUID_IPFS_API: ${{ secrets.SUPERFLUID_IPFS_API }}
THE_GRAPH_ACCESS_TOKEN: ${{ secrets.THE_GRAPH_ACCESS_TOKEN }}
SATSUMA_DEPLOY_KEY: ${{ secrets.SATSUMA_DEPLOY_KEY }}
GOLDSKY_API_KEY: ${{ secrets.GOLDSKY_API_KEY }}
AIRSTACK_API_KEY: ${{ secrets.AIRSTACK_API_KEY }}
COMMIT_HASH: ${{ github.sha }}
CONFIGURATION: ${{ inputs.deployment_env }}