Skip to content

Commit

Permalink
feat: add automation to non-ipfs deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Feb 27, 2023
1 parent 4d83c38 commit 284df1f
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 47 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy-goerli-arbitrum-subgraph-no-ipfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Production Subgraph (Arbitrum Goerli)

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: production-arbitrum-goerli-no-ipfs
CONFIG: arbitrumGoerliAddressScript.ts
secrets:
NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
ACCESS_TOKEN: ${{ secrets.access_token }}
20 changes: 20 additions & 0 deletions .github/workflows/deploy-goerli-subgraph-no-ipfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Production Subgraph (Goerli)

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: production-goerli-no-ipfs
CONFIG: goerliAddressScript.ts
secrets:
NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
ACCESS_TOKEN: ${{ secrets.access_token }}
20 changes: 20 additions & 0 deletions .github/workflows/deploy-production-arbitrum-subgraph-no-ipfs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Production Subgraph (Arbitrum)

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: production-arbitrum-no-ipfs
CONFIG: mainnetArbitrumAddressScript.ts
secrets:
NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
ACCESS_TOKEN: ${{ secrets.access_token }}
20 changes: 20 additions & 0 deletions .github/workflows/deploy-production-subgraph-no-ipfs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Production Subgraph (Mainnet)

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: production-no-ipfs
CONFIG: mainnetAddressScript.ts
secrets:
NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
ACCESS_TOKEN: ${{ secrets.access_token }}
34 changes: 27 additions & 7 deletions .github/workflows/template-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,52 @@ jobs:
- name: Set arbitrum staging environment variables
if: ${{ inputs.ENVIRONMENT == 'staging-arbitrum' }}
run: |
echo "ENV_SUFFIX=-arbitrum-staging" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-arbitrum-staging" >> $GITHUB_ENV
- name: Set mainnet staging environment variables
if: ${{ inputs.ENVIRONMENT == 'staging-mainnet' }}
run: |
echo "ENV_SUFFIX=-mainnet-staging" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-mainnet-staging" >> $GITHUB_ENV
- name: Set mainnet environment variables
if: ${{ inputs.ENVIRONMENT == 'production' }}
run: |
echo "ENV_SUFFIX=-mainnet" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-mainnet" >> $GITHUB_ENV
- name: Set arbitrum environment variables
if: ${{ inputs.ENVIRONMENT == 'production-arbitrum' }}
run: |
echo "ENV_SUFFIX=-arbitrum" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-arbitrum" >> $GITHUB_ENV
- name: Set goerli production environment variables
if: ${{ inputs.ENVIRONMENT == 'production-goerli' }}
run: |
echo "ENV_SUFFIX=-goerli" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-goerli" >> $GITHUB_ENV
- name: Set arbitrum goerli production environment variables
if: ${{ inputs.ENVIRONMENT == 'production-arbitrum-goerli' }}
run: |
echo "ENV_SUFFIX=-arbitrum-goerli" >> $GITHUB_ENV
echo "ENV_SUFFIX=graph-network-arbitrum-goerli" >> $GITHUB_ENV
- name: Set mainnet environment variables no ipfs
if: ${{ inputs.ENVIRONMENT == 'production-no-ipfs' }}
run: |
echo "ENV_SUFFIX=no-ipfs-network-ethereum" >> $GITHUB_ENV
- name: Set arbitrum environment variables no ipfs
if: ${{ inputs.ENVIRONMENT == 'production-arbitrum-no-ipfs' }}
run: |
echo "ENV_SUFFIX=no-ipfs-network-arbitrum" >> $GITHUB_ENV
- name: Set goerli production environment variables no ipfs
if: ${{ inputs.ENVIRONMENT == 'production-goerli-no-ipfs' }}
run: |
echo "ENV_SUFFIX=no-ipfs-network-goerli" >> $GITHUB_ENV
- name: Set arbitrum goerli production environment variables no ipfs
if: ${{ inputs.ENVIRONMENT == 'production-arbitrum-goerli-no-ipfs' }}
run: |
echo "ENV_SUFFIX=no-ipfs-network-arb-goerli" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -79,4 +99,4 @@ jobs:
run: ./node_modules/.bin/mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && ./node_modules/@graphprotocol/graph-cli/dist/bin.js codegen --output-dir src/types/

- name: Deploy to ${{ inputs.ENVIRONMENT }}
run: ./node_modules/@graphprotocol/graph-cli/dist/bin.js deploy graphprotocol/graph-network${{ env.ENV_SUFFIX }} --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ${{ secrets.ACCESS_TOKEN }}
run: ./node_modules/@graphprotocol/graph-cli/dist/bin.js deploy graphprotocol/${{ env.ENV_SUFFIX }} --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ${{ secrets.ACCESS_TOKEN }}
21 changes: 7 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,24 @@
"scripts": {
"prepublishOnly": "yarn & yarn build:ipfs",
"build": "graph build",
"build:ipfs:rinkeby": "yarn && yarn prep:ipfs && yarn prepare:rinkeby && graph build --ipfs https://ipfs.network.thegraph.com/",
"build:ipfs:mainnet": "yarn && yarn prep:ipfs && yarn prepare:mainnet && graph build --ipfs https://ipfs.network.thegraph.com",
"build:ipfs:rinkeby-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:rinkeby && graph build --ipfs https://ipfs.network.thegraph.com/",
"build:ipfs:mainnet-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:mainnet && graph build --ipfs https://ipfs.network.thegraph.com",
"deploy-mainnet-staging": "yarn && yarn prep:ipfs && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet-staging --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-mainnet-staging-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet-staging --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-mainnet": "yarn && yarn prep:ipfs && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-mainnet-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-mainnet-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:mainnet && graph deploy graphprotocol/no-ipfs-network-ethereum --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum": "yarn && yarn prep:ipfs && yarn prepare:arbitrum && graph deploy graphprotocol/graph-network-arbitrum --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:arbitrum && graph deploy graphprotocol/graph-network-arbitrum --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-rinkeby": "yarn && yarn prep:ipfs && yarn prepare:rinkeby && graph deploy graphprotocol/graph-network-testnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-rinkeby-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:rinkeby && graph deploy graphprotocol/graph-network-testnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:arbitrum && graph deploy graphprotocol/no-ipfs-network-arbitrum --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-goerli": "yarn && yarn prep:ipfs && yarn prepare:goerli && graph deploy graphprotocol/graph-network-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-goerli-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:goerli && graph deploy graphprotocol/graph-network-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-goerli-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:goerli && graph deploy graphprotocol/no-ipfs-network-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum-goerli": "yarn && yarn prep:ipfs && yarn prepare:arbitrum-goerli && graph deploy graphprotocol/graph-network-arbitrum-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum-goerli-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:arbitrum-goerli && graph deploy graphprotocol/graph-network-arbitrum-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-arbitrum-goerli-no-ipfs": "yarn && yarn prep:no-ipfs && yarn prepare:arbitrum-goerli && graph deploy graphprotocol/no-ipfs-network-arb-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy-testing": "yarn && yarn prep:<ipfs/no-ipfs> && yarn prepare:<mainnet/arbitrum/goerli/arbitrum-goerli> && graph deploy <subgraph name> --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prep:addresses:rinkeby": "ts-node config/rinkebyAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:rinkeby": "yarn prep:addresses:rinkeby && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:addresses:goerli": "ts-node config/goerliAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:goerli": "yarn prep:addresses:goerli && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prepare:mainnet": "yarn prep:addresses:mainnet && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prepare:arbitrum": "yarn prep:addresses:arbitrum && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:addresses:mainnet": "ts-node config/mainnetAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:mainnet": "yarn prep:addresses:mainnet && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:addresses:arbitrum": "ts-node config/mainnetArbitrumAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:arbitrum": "yarn prep:addresses:arbitrum && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:addresses:arbitrum-goerli": "ts-node config/arbitrumGoerliAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts",
"prepare:arbitrum-goerli": "yarn prep:addresses:arbitrum-goerli && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/",
"prep:ipfs": "mustache ./config/ipfs.json ./src/mappings/helpers/metadata.template.ts > ./src/mappings/helpers/metadata.ts",
Expand All @@ -49,7 +42,7 @@
},
"devDependencies": {
"@graphprotocol/contracts": "2.3.0",
"@graphprotocol/graph-cli": "^0.37.5",
"@graphprotocol/graph-cli": "^0.42.2",
"@graphprotocol/graph-ts": "^0.29.1",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "^3.3.0",
Expand Down
Loading

0 comments on commit 284df1f

Please sign in to comment.