Skip to content

Deploy the Subgraph #26

Deploy the Subgraph

Deploy the Subgraph #26

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: 16
- 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: yarn deploy:${{ inputs.subgraph }}:${{ vars.NETWORK }}
working-directory: subgraph