Skip to content

Commit a8392b8

Browse files
committed
refactor: streamline deployment workflow and update node version
1 parent 5367bb3 commit a8392b8

File tree

1 file changed

+39
-44
lines changed

1 file changed

+39
-44
lines changed
Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,65 @@
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
42-
working-directory: packages/subgraph
37+
- name: Install dependencies
4338
run: npm ci
4439

45-
- name: Run Codegen and Build
46-
working-directory: packages/subgraph
47-
run: |
48-
npm run codegen
49-
npm run build
50-
5140
- name: Set Version Label
5241
id: set_version
53-
working-directory: packages/subgraph
5442
run: |
55-
if [ "${{ matrix.subgraph.version_method }}" = "commit" ]; then
43+
if [[ "${{ github.event.inputs.environment }}" == "staging" ]]; then
5644
echo "version=${GITHUB_SHA}" >> $GITHUB_OUTPUT
5745
else
5846
version=$(npm pkg get version | sed 's/"//g')
59-
echo "version=${version}" >> $GITHUB_OUTPUT
47+
echo "version=$version" >> $GITHUB_OUTPUT
6048
fi
6149
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-
6750
- name: Deploy Subgraph
68-
working-directory: packages/subgraph
51+
env:
52+
NETWORK_NAME: ${{ github.event.inputs.networkName }}
53+
VERSION_LABEL: ${{ steps.set_version.outputs.version }}
54+
GRAPHNODE_URL: ${{ vars.GRAPHNODE_URL }}
55+
IPFS_URL: ${{ vars.IPFS_URL }}
56+
DEPLOY_ENV: ${{ vars.ENV_NAME }}
6957
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 }}
58+
echo "Starting deployment with the following parameters:"
59+
echo " Network Name: $NETWORK_NAME"
60+
echo " Version Label: $VERSION_LABEL"
61+
echo " DEPLOY_ENV: $DEPLOY_ENV"
62+
echo " GRAPHNODE_URL: $GRAPHNODE_URL"
63+
echo " IPFS_URL: $IPFS_URL"
64+
npm run all
65+
shell: bash

0 commit comments

Comments
 (0)