Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate subgraphs deploy process to Subgraph Studio #268

Merged
merged 7 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/deploy-subgraph-to-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ jobs:
# fix for EndBug/add-and-commit
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}


- name: Read version from package.json and set version variables
run: |
VER=$(grep version packages/subgraph/package.json | cut -d ':' -f 2 | cut -d '"' -f 2)
echo "VERSION=$VER" >> $GITHUB_ENV

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
Expand All @@ -39,10 +44,12 @@ jobs:

- name: Deploy subgraph
env:
SUBGRAPH_ACCESS_TOKEN: ${{ secrets.SUBGRAPH_ACCESS_TOKEN }}
SUBGRAPH_ENVIRONMENT: ${{ vars.SUBGRAPH_ENVIRONMENT }} # eonian-bsc-development or eonian-bsc-staging
VERSION: ${{ env.VERSION }}
SUBGRAPH_DEPLOY_KEY: ${{ secrets.SUBGRAPH_DEPLOY_KEY }}
SUBGRAPH_ENVIRONMENT: ${{ vars.SUBGRAPH_ENVIRONMENT }} # eonian-sepolia-testnet
# Use warapper for yarn deploy command to highlight step failure
run: |-
cd packages/subgraph
output=$(yarn graph deploy --product hosted-service eonian-core/$SUBGRAPH_ENVIRONMENT ./deploy/environments/$SUBGRAPH_ENVIRONMENT.yaml --access-token $SUBGRAPH_ACCESS_TOKEN 2>&1); echo "$output"; if echo "$output" | grep -q "UNCAUGHT EXCEPTION"; then exit 1; fi

output=$(yarn graph deploy --studio $SUBGRAPH_ENVIRONMENT ./deploy/environments/$SUBGRAPH_ENVIRONMENT.yaml --version-label=$VERSION --deploy-key $SUBGRAPH_DEPLOY_KEY 2>&1); echo "$output"; if echo "$output" | grep -q "UNCAUGHT EXCEPTION"; then exit 1; fi


84 changes: 84 additions & 0 deletions .github/workflows/generate-subgraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Generate Subgraphs

on:
pull_request:
branches:
- development
types:
- opened
- labeled
paths:
- "packages/subgraph/**"

jobs:
generate:
name: Generate Schemas and Configs
runs-on: ubuntu-latest
environment: preview

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
# fix for EndBug/add-and-commit
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Resolve bump label
id: bump
uses: zwaldowski/match-label-action@v1
with:
allowed: major,minor,patch

- name: Read version from package.json and set version variables
run: |
VER=$(grep version packages/subgraph/package.json | cut -d ':' -f 2 | cut -d '"' -f 2)
echo "VERSION=$VER" >> $GITHUB_ENV

- name: Generate new version
id: next_version
uses: leovs09/semver-release-action@v3
with:
version: ${{ env.VERSION }}
bump: ${{ steps.bump.outputs.match }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Save new version in package.json
run: |-
cd packages/subgraph
sed -i -E 's/"version": "(.*)",/"version": "${{ steps.next_version.outputs.version }}",/g' package.json

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "yarn"

- name: Install dependencies
run: yarn --ignore-scripts

# TODO: split schema and code generation from version bump. Currently impossuble due to github commit limitations in jobs
- name: Generate subgraph environments configurations
run: |-
cd packages/subgraph
yarn gen:configs

# TODO: add step that load contracts ABIs before generating schema

- name: Generate subgraph schema code
run: |-
cd packages/subgraph
yarn gen:code

- name: Build subgraph
run: |-
cd packages/subgraph
yarn build

- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: '[skip ci] Generate subgraph configs and schema'
fetch: --no-tags --recurse-submodules=no # Prevent failure due to submodules
pull: '--rebase --autostash'
Loading
Loading