Skip to content

Commit 3797608

Browse files
authored
fix/deploy-subgraph-ci (#458)
1 parent 5367bb3 commit 3797608

File tree

3 files changed

+645
-582
lines changed

3 files changed

+645
-582
lines changed
Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,68 @@
11
name: Deploy Subgraph
22

33
on:
4-
workflow_dispatch:
4+
workflow_dispatch: # Triggered manually but we can also trigger with an release event
5+
inputs:
6+
environment:
7+
description: 'Deployment environment (must match a GitHub Environment name)'
8+
required: true
9+
default: staging
10+
type: choice
11+
options:
12+
- staging
13+
- tmp
14+
- prod
15+
# Add new networks when needed. Do not forget to add necessary data in the networks.json file.
16+
networkName:
17+
description: 'Network Name'
18+
required: false
19+
default: bellecour
20+
type: choice
21+
options:
22+
- bellecour
523

624
jobs:
725
deploy:
826
runs-on:
927
group: Azure_runners
1028
labels: [ self-hosted, Linux, X64 ]
11-
strategy:
12-
matrix:
13-
include:
14-
- target: staging
15-
subgraph_name: 'bellecour/staging-dataprotector-v2'
16-
env_name: staging
17-
graphnode_url: ${{ secrets.GRAPHNODE_URL_STAGING }}
18-
ipfs_url: ${{ secrets.IPFS_URL_STAGING }}
19-
version_method: npm_version
20-
- target: tmp
21-
subgraph_name: 'bellecour/tmp-dataprotector-v2'
22-
env_name: prod
23-
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
24-
ipfs_url: ${{ secrets.IPFS_URL }}
25-
version_method: commit
26-
- target: prod
27-
subgraph_name: 'bellecour/dataprotector-v2'
28-
env_name: prod
29-
graphnode_url: ${{ secrets.GRAPHNODE_URL }}
30-
ipfs_url: ${{ secrets.IPFS_URL }}
31-
version_method: npm_version
32-
33-
# Run only on main branch
34-
if: github.ref == 'refs/heads/main'
29+
# Associate the job with a GitHub Environment which has pre-defined variables and secrets.
30+
environment: ${{ github.event.inputs.environment }}
3531
steps:
3632
- uses: actions/checkout@v4
3733
- uses: actions/setup-node@v4
3834
with:
39-
node-version: 18
35+
node-version: '20'
4036

41-
- name: Install Dependencies
37+
- name: Install dependencies
4238
working-directory: packages/subgraph
4339
run: npm ci
4440

45-
- name: Run Codegen and Build
46-
working-directory: packages/subgraph
47-
run: |
48-
npm run codegen
49-
npm run build
50-
5141
- name: Set Version Label
52-
id: set_version
5342
working-directory: packages/subgraph
43+
id: set_version
5444
run: |
55-
if [ "${{ matrix.subgraph.version_method }}" = "commit" ]; then
45+
if [[ "${{ github.event.inputs.environment }}" == "staging" ]]; then
5646
echo "version=${GITHUB_SHA}" >> $GITHUB_OUTPUT
5747
else
5848
version=$(npm pkg get version | sed 's/"//g')
59-
echo "version=${version}" >> $GITHUB_OUTPUT
49+
echo "version=$version" >> $GITHUB_OUTPUT
6050
fi
6151
62-
- name: Create Subgraph
63-
working-directory: packages/subgraph
64-
run: |
65-
npx graph create --node ${{ matrix.subgraph.graphnode_url }} ${{ matrix.subgraph.subgraph_name }}
66-
6752
- name: Deploy Subgraph
6853
working-directory: packages/subgraph
54+
env:
55+
NETWORK_NAME: ${{ github.event.inputs.networkName }}
56+
VERSION_LABEL: ${{ steps.set_version.outputs.version }}
57+
GRAPHNODE_URL: ${{ vars.GRAPHNODE_URL }}
58+
IPFS_URL: ${{ vars.IPFS_URL }}
59+
DEPLOY_ENV: ${{ vars.ENV_NAME }}
6960
run: |
70-
npx graph deploy --node ${{ matrix.subgraph.graphnode_url }} ${{ matrix.subgraph.subgraph_name }} --ipfs ${{ matrix.subgraph.ipfs_url }} --version-label ${{ steps.set_version.outputs.version }}
61+
echo "Starting deployment with the following parameters:"
62+
echo " Network Name: $NETWORK_NAME"
63+
echo " Version Label: $VERSION_LABEL"
64+
echo " DEPLOY_ENV: $DEPLOY_ENV"
65+
echo " GRAPHNODE_URL: $GRAPHNODE_URL"
66+
echo " IPFS_URL: $IPFS_URL"
67+
npm run all
68+
shell: bash

0 commit comments

Comments
 (0)