From 8b2873f8522df9e9ed30706e7acfa201680b1f47 Mon Sep 17 00:00:00 2001 From: Facu Spagnuolo Date: Sun, 12 Nov 2023 18:07:18 +0300 Subject: [PATCH] chore: setup studio deployments --- .github/workflows/deploy.yml | 24 ++++++++++++----------- scripts/build.sh | 38 +++++++++++++++++++++++++++++------- scripts/deploy.sh | 31 ++++++++++++++++++++++++----- 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fd4c2a1..f46bf05 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,7 +16,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Arbitrum env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:arbitrum deploy-aurora: @@ -29,7 +29,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Aurora env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:aurora deploy-avalanche: @@ -42,7 +42,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Avalanche env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:avalanche deploy-base: @@ -55,7 +55,8 @@ jobs: uses: ./.github/actions/setup - name: Deploy Base env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + VERSION_LABEL: ${{ github.sha }} + GRAPH_KEY: ${{ secrets.GRAPH_STUDIO_KEY }} run: yarn deploy:base deploy-bsc: @@ -68,7 +69,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy BSC env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:bsc deploy-fantom: @@ -81,7 +82,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Fantom env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:fantom deploy-gnosis: @@ -94,7 +95,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Gnosis env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:gnosis deploy-mainnet: @@ -107,7 +108,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Mainnet env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:mainnet deploy-optimism: @@ -120,7 +121,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Optimism env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:optimism deploy-polygon: @@ -133,7 +134,7 @@ jobs: uses: ./.github/actions/setup - name: Deploy Polygon env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_HOSTED_KEY }} run: yarn deploy:polygon deploy-zkevm: @@ -146,5 +147,6 @@ jobs: uses: ./.github/actions/setup - name: Deploy zkEVM env: - GRAPH_KEY: ${{ secrets.GRAPH_KEY }} + GRAPH_KEY: ${{ secrets.GRAPH_STUDIO_KEY }} + VERSION_LABEL: ${{ github.sha }} run: yarn deploy:zkevm diff --git a/scripts/build.sh b/scripts/build.sh index d0ed3bb..010c454 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -163,7 +163,7 @@ fi # Remove previous manifest if there is any if [ -f subgraph.yaml ]; then - echo 'Removing previous subgraph manifest...' + echo 'Removing previous subgraph manifest' rm subgraph.yaml fi @@ -178,10 +178,34 @@ sed -i -e "s/{{feeControllerAddress}}/${FEE_CONTROLLER_ADDRESS}/g" subgraph.yaml sed -i -e "s/{{blockNumber}}/${BLOCK_NUMBER}/g" subgraph.yaml rm -f subgraph.yaml-e -# Build functions selector dictionary -echo "Building functions selector dictionary" -yarn ts-node ./scripts/build-permissions-dictionary.ts +# Build functions selectors dictionary +echo "Building functions selectors dictionary" +output=$(yarn ts-node ./scripts/build-permissions-dictionary.ts) -# Run codegen and build -rm -rf ./types && yarn graph codegen -o types -yarn graph build +# Check dictionary build status +if [ $? -ne 0 ]; then + echo "Error trying to build funcitons selectors dictionary with exit status $?" + echo "$output" + exit $? +fi + +# Run codegen +echo "Generating graph types" +output=$(rm -rf ./types && yarn graph codegen -o types 2>&1) + +# Check codegen status +if [ $? -ne 0 ]; then + echo "Error trying to run codegen with exit status $?" + echo "$output" + exit $? +fi + +# Run build +output=$(yarn graph build 2>&1) + +# Check build status +if [ $? -ne 0 ]; then + echo "Error trying to build subgraph with exit status $?" + echo "$output" + exit $? +fi diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 35d0761..b48568e 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -6,11 +6,32 @@ set -o errexit # Run graph build yarn build:$NETWORK -# Require $GRAPH_KEY to be set -if [[ -z "${GRAPH_KEY}" ]]; then - echo "Please set \$GRAPH_KEY to your The Graph deploy key to run this command." - exit 1 +# Studio deployments +platform_base=studio +platform_zkevm=studio + +# Load platform +if [[ -z $PLATFORM ]]; then + PLATFORM_VAR=platform_$NETWORK + PLATFORM=${!PLATFORM_VAR} fi # Deploy subgraph -graph deploy mimic-fi/v3-$NETWORK --product hosted-service --access-token "$GRAPH_KEY" +if [ "$PLATFORM" == "studio" ]; then + echo "Deploying $NETWORK to subgraph studio" + if [[ -z $VERSION_LABEL ]]; then + echo 'Please make sure a version label is provided' + exit 1 + fi + yarn graph deploy mimic-v3-$NETWORK --studio --deploy-key $GRAPH_KEY -l $VERSION_LABEL +else + echo "Deploying $NETWORK to hosted service" + yarn graph deploy mimic-fi/v3-$NETWORK --product hosted-service --deploy-key $GRAPH_KEY +fi + +# Check deployer status +if [ $? -ne 0 ]; then + echo "Error trying to deploy subgraph with exit status $?" + echo "$output" + exit $? +fi