Skip to content

Commit

Permalink
chore: improved the subgraph deployment workflow to use branch-specif…
Browse files Browse the repository at this point in the history
…ic protected envs
  • Loading branch information
jaybuidl committed Jan 4, 2024
1 parent 5cbffee commit a2a7b5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/deploy-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: Deploy the Subgraph
on:
workflow_dispatch:
inputs:
network:
description: The network to deploy the subgraph to
graph_environment:
description: The Graph environment to deploy to
required: true
default: 'arbitrum-sepolia'
default: 'graph-studio-devnet'
type: choice
options:
- arbitrum-sepolia-devnet
- arbitrum-sepolia
- arbitrum
- graph-studio-devnet
- graph-studio-testnet
- graph-studio-mainnet
subgraph:
description: The name of the subgraph to deploy
required: true
Expand All @@ -32,13 +32,17 @@ permissions:
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
environment: kleros-org-subgraph
environment: ${{ inputs.graph_environment }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
with:
egress-policy: audit

- name: Validate Network environment variable
if: ${{!startsWith(vars.NETWORK, 'arbitrum')}}
run: echo ${{vars.NETWORK}} && exit 1

- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

Expand Down Expand Up @@ -66,7 +70,7 @@ jobs:
if: ${{ inputs.update }}
run: |
export PATH=$PWD/../bin:$PATH
yarn update:${{ inputs.subgraph }}:${{ inputs.network }}
yarn update:${{ inputs.subgraph }}:${{ vars.NETWORK }}
working-directory: subgraph

- name: Build the subgraph
Expand All @@ -75,10 +79,10 @@ jobs:
yarn build:${{ inputs.subgraph }}
working-directory: subgraph

- name: Authenticate with TheGraph
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --product hosted-service
- name: Authenticate with TheGraph Studio
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --studio
working-directory: subgraph

- name: Deploy the subgraph
run: yarn deploy:${{ inputs.subgraph }}:${{ inputs.network }}
run: yarn deploy:${{ inputs.subgraph }}:${{ vars.NETWORK }}
working-directory: subgraph
2 changes: 1 addition & 1 deletion scripts/act-subgraph.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

act workflow_dispatch -j buildAndDeploy --input network=arbitrum-sepolia,update=true
act workflow_dispatch -j buildAndDeploy --input graph_environment=graph-studio-devnet,update=true --env network=arbitrum-sepolia-devnet
10 changes: 5 additions & 5 deletions subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"build:core": "graph build --output-dir core/build/ core/subgraph.yaml",
"test:core": "cd core && graph test",
"clean:core": "graph clean --codegen-dir core/generated/ --build-dir core/build/ && rm core/subgraph.yaml.bak.*",
"deploy:core:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-core-devnet -l v0.0.2 core/subgraph.yaml",
"deploy:core:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-core-testnet -l v0.0.2 core/subgraph.yaml",
"deploy:core:arbitrum": "graph deploy --product subgraph-studio kleros-v2-core -l v0.0.2 core/subgraph.yaml",
"deploy:core:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-core-devnet -l v0.0.3 core/subgraph.yaml",
"deploy:core:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-core-testnet -l v0.0.3 core/subgraph.yaml",
"deploy:core:arbitrum": "graph deploy --product subgraph-studio kleros-v2-core -l v0.0.3 core/subgraph.yaml",
"": "------------------------------------------------------------------------------------------",
"update:drt:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia dispute-template-registry/subgraph.yaml",
"update:drt:arbitrum-sepolia": "./scripts/update.sh arbitrumSepolia arbitrum-sepolia dispute-template-registry/subgraph.yaml",
Expand All @@ -22,8 +22,8 @@
"build:drt": "graph build --output-dir dispute-template-registry/generated/ dispute-template-registry/subgraph.yaml",
"test:drt": "cd dispute-template-registry && graph test ",
"clean:drt": "graph clean --codegen-dir dispute-template-registry/generated/ --build-dir dispute-template-registry/build/ && rm dispute-template-registry/subgraph.yaml.bak.*",
"deploy:drt:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-devnet -l v0.0.2 dispute-template-registry/subgraph.yaml",
"deploy:drt:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-testnet -l v0.0.2 dispute-template-registry/subgraph.yaml",
"deploy:drt:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-devnet -l v0.0.3 dispute-template-registry/subgraph.yaml",
"deploy:drt:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-testnet -l v0.0.3 dispute-template-registry/subgraph.yaml",
" ": "-----------------------------------------------------------------------------------------",
"update:arbitrum-sepolia-devnet": "./scripts/all.sh update arbitrum-sepolia-devnet",
"update:arbitrum-sepolia": "./scripts/all.sh update arbitrum-sepolia",
Expand Down

0 comments on commit a2a7b5d

Please sign in to comment.