From 2d2f3bc8e64817baaa07bc22d8ed55678ef78a49 Mon Sep 17 00:00:00 2001 From: Robert Leonard Date: Wed, 28 Jun 2023 13:13:18 -0400 Subject: [PATCH 1/5] add subgraph readme --- subgraph/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 subgraph/README.md diff --git a/subgraph/README.md b/subgraph/README.md new file mode 100644 index 00000000..1f0f6534 --- /dev/null +++ b/subgraph/README.md @@ -0,0 +1,20 @@ +# Forta Subgraph +The Forta subgraph is currently hosted on chainstack (both dev and production enviornments) and provides visibility to on-chain events around the forta protocol such as staking, rewards, node pools, etc. + +## Deployment + +We use [theGraph's cli](https://thegraph.com/docs/en/deploying/deploying-a-subgraph-to-studio/#deploying-a-subgraph-to-subgraph-studio) in our development and production github actions to deploy the Forta subgraph. + +### Dev Deployment + +The development deployment occurs on every pull request that is merged to master via a github action. + +Dev subgraph url: `https://polygon-mumbai.graph-eu.p2pify.com/6dbdbeb3262ca5fa43773df1e690bd53/forta-dev` + +### Production Deployment + +There are two production subgraphs which we follow a [blue/green deployment pattern](https://www.redhat.com/en/topics/devops/what-is-blue-green-deployment) via a github action. + +Forta-a subgraph url: `https://polygon-mainnet.graph-eu.p2pify.com/49e5eba171ac70bd41578331e4d65cfc/forta-a` + +Forta-b subgraph url: `https://polygon-mainnet.graph-eu.p2pify.com/62563b45923ea9d259c5c16d1f73f804/forta-b` \ No newline at end of file From e613c925b6276a5a1e3e615a0800f082336f0d8d Mon Sep 17 00:00:00 2001 From: Robert Leonard Date: Tue, 11 Jul 2023 13:41:12 -0400 Subject: [PATCH 2/5] Adding deployment to thegraph hosted service --- .../workflows/deploy-subgraph-theGraph.yml | 34 +++++++++++++++++++ subgraph/package.json | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-subgraph-theGraph.yml diff --git a/.github/workflows/deploy-subgraph-theGraph.yml b/.github/workflows/deploy-subgraph-theGraph.yml new file mode 100644 index 00000000..edbd3974 --- /dev/null +++ b/.github/workflows/deploy-subgraph-theGraph.yml @@ -0,0 +1,34 @@ +name: Prod Deploy Subgraph +on: + workflow_dispatch: + branches: [ master ] +jobs: + deploy-subgraph: + name: Deploy subgraph workflow + runs-on: ubuntu-latest + environment: production + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "16" + + - name: Install the graph cli + run: npm install @graphprotocol/graph-cli + + - name: Authenticate with prod subgraph + run: | + npx graph auth --product hosted-service ${{ secrets.PROD_SUBGRAPH_API_KEY }} + + - name: Install subgraph dependencies + working-directory: ./subgraph + run: npm install + + - name: Prepare for subgraph deployment + working-directory: ./subgraph + run: npm run prepare + + - name: Deploy subgraph + working-directory: ./subgraph + run: npm run deploy diff --git a/subgraph/package.json b/subgraph/package.json index fc9c5412..8df9ea87 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -12,6 +12,7 @@ "prepare-dev": "yarn prepare-dev:schema && yarn prepare-dev:codegen && yarn prepare-dev:compile", "deploy-dev": "graph deploy --node https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/deploy --ipfs https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/ipfs forta-dev", "deploy": "graph deploy -l v0.0.1 --node https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/deploy --ipfs https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/ipfs forta-b", + "deploy-theGraph": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network", "create-local": "graph create --node http://localhost:8020/ forta-network/forta-network", "remove-local": "graph remove --node http://localhost:8020/ forta-network/forta-network", "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 forta-network/forta-network", @@ -25,4 +26,4 @@ "matchstick-as": "^0.5.0", "source-map-support": "^0.5.21" } -} +} \ No newline at end of file From 001d57abedd2e5d278081781443c19f0354e0b3b Mon Sep 17 00:00:00 2001 From: Robert Leonard Date: Tue, 11 Jul 2023 13:43:45 -0400 Subject: [PATCH 3/5] allow deployment on any branch --- .github/workflows/deploy-subgraph-theGraph.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy-subgraph-theGraph.yml b/.github/workflows/deploy-subgraph-theGraph.yml index edbd3974..2945fdb8 100644 --- a/.github/workflows/deploy-subgraph-theGraph.yml +++ b/.github/workflows/deploy-subgraph-theGraph.yml @@ -1,7 +1,6 @@ name: Prod Deploy Subgraph on: workflow_dispatch: - branches: [ master ] jobs: deploy-subgraph: name: Deploy subgraph workflow From f789470f75ace84dcf203661e66008a3c75d0618 Mon Sep 17 00:00:00 2001 From: Robert Leonard Date: Tue, 11 Jul 2023 13:44:34 -0400 Subject: [PATCH 4/5] deploy to correct subgraph --- .github/workflows/deploy-subgraph-theGraph.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-subgraph-theGraph.yml b/.github/workflows/deploy-subgraph-theGraph.yml index 2945fdb8..ba1f9107 100644 --- a/.github/workflows/deploy-subgraph-theGraph.yml +++ b/.github/workflows/deploy-subgraph-theGraph.yml @@ -30,4 +30,4 @@ jobs: - name: Deploy subgraph working-directory: ./subgraph - run: npm run deploy + run: npm run deploy-theGraph From 121a3b2459d65d76f3a4fcc9737d0e67505dd7f0 Mon Sep 17 00:00:00 2001 From: Robert Leonard Date: Tue, 11 Jul 2023 13:53:35 -0400 Subject: [PATCH 5/5] rename github action --- .github/workflows/deploy-subgraph-theGraph.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-subgraph-theGraph.yml b/.github/workflows/deploy-subgraph-theGraph.yml index ba1f9107..410e24da 100644 --- a/.github/workflows/deploy-subgraph-theGraph.yml +++ b/.github/workflows/deploy-subgraph-theGraph.yml @@ -1,4 +1,4 @@ -name: Prod Deploy Subgraph +name: Prod Deploy theGraph Subgraph on: workflow_dispatch: jobs: