Skip to content

Deploy VestingScheduler Subgraphs (Goldsky) #15

Deploy VestingScheduler Subgraphs (Goldsky)

Deploy VestingScheduler Subgraphs (Goldsky) #15

name: Deploy VestingScheduler Subgraphs (Goldsky)
on:
workflow_dispatch:
inputs:
network:
description: 'Network to deploy (select "all" for all networks)'
required: true
type: choice
options:
- all
- avalanche-c
- arbitrum-one
- bsc-mainnet
- eth-mainnet
- xdai-mainnet
- optimism-mainnet
- polygon-mainnet
- optimism-sepolia
- base-mainnet
default: 'all'
push:
branches:
- "release-v1/*"
paths:
- "subgraphs/vesting-scheduler/**"
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: subgraphs/vesting-scheduler
strategy:
fail-fast: false
matrix:
networks: ${{ github.event.inputs.network == 'all' && fromJson('["avalanche-c", "arbitrum-one", "bsc-mainnet", "eth-mainnet", "xdai-mainnet", "optimism-mainnet", "polygon-mainnet", "optimism-sepolia", "base-mainnet"]') || fromJson(format('["{0}"]', github.event.inputs.network)) }}
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Install
run: pnpm install
- name: Generate YAML & Types
run: pnpm gen
- name: Build
run: pnpm exec graph build ${{format('./{0}.subgraph.yaml', matrix.networks)}}
- name: Test
run: pnpm test
- name: Get Version
id: get-version
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('./subgraphs/vesting-scheduler/package.json'));
return packageJson.version;
- name: Goldsky Login
run: pnpm exec goldsky login --token ${{secrets.GOLDSKY_API_KEY}}
- name: Goldsky Deploy
run: pnpm exec goldsky subgraph deploy ${{format('vesting-v1-{0}/{1}', matrix.networks, steps.get-version.outputs.result) }} --path ./build
continue-on-error: true # We still want to tag the latest deployment if it was already deployed.
- name: Check Subgraph Sync Status
id: check-sync
run: |
SYNC=$(pnpm exec goldsky subgraph list ${{format('vesting-v1-{0}/{1}', matrix.networks, steps.get-version.outputs.result) }} | grep "Synced:" | awk '{print $2}' | cut -d'%' -f1)
if (( $(echo "$SYNC > 98" | bc -l) )); then
echo "::set-output name=sync::true"
else
echo "::set-output name=sync::false"
fi
- name: Goldsky Tag
if: steps.check-sync.outputs.sync == 'true'
run: pnpm exec goldsky subgraph tag create ${{format('vesting-v1-{0}/{1}', matrix.networks, steps.get-version.outputs.result) }} --tag prod