Skip to content

Commit 41ab920

Browse files
committed
feat: Add GitHub Actions workflows for deploying and testing Subgraph Docker images
1 parent 57b8998 commit 41ab920

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Subgraph
2+
3+
on:
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+
- production
14+
- tmp
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
23+
versionLabel:
24+
description: 'Version Label for Subgraph Deployment'
25+
required: false
26+
default: develop
27+
type: string
28+
29+
jobs:
30+
deploy:
31+
runs-on: ubuntu-latest
32+
environment: ${{ github.event.inputs.environment }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Set up Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 18
41+
cache: 'npm'
42+
cache-dependency-path: 'packages/subgraph/package-lock.json'
43+
44+
- name: Install dependencies
45+
working-directory: packages/subgraph
46+
run: npm ci
47+
48+
- name: Deploy Subgraph
49+
working-directory: packages/subgraph
50+
env:
51+
NETWORK_NAME: ${{ github.event.inputs.networkName }}
52+
VERSION_LABEL: ${{ github.event.inputs.versionLabel }}
53+
GRAPHNODE_URL: ${{ vars.GRAPHNODE_URL }}
54+
IPFS_URL: ${{ vars.IPFS_URL }}
55+
DEPLOY_ENV: ${{ vars.ENV_NAME }}
56+
run: |
57+
echo "Starting deployment with the following parameters:"
58+
echo " Network Name: $NETWORK_NAME"
59+
echo " Version Label: $VERSION_LABEL"
60+
echo " DEPLOY_ENV: $DEPLOY_ENV"
61+
echo " GRAPHNODE_URL: $GRAPHNODE_URL"
62+
echo " IPFS_URL: $IPFS_URL"
63+
npm run all
64+
shell: bash

.github/workflows/docker-push.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and Push Subgraph Deployer Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*' # Trigger on tag push
7+
branches:
8+
- main
9+
- develop
10+
paths:
11+
- 'packages/subgraph/**'
12+
- 'packages/subgraph/deployer.Dockerfile'
13+
workflow_dispatch:
14+
15+
jobs:
16+
# Compute the tag based on the event type
17+
compute-tag:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
computed_tag: ${{ steps.set_tag.outputs.computed_tag }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Fetch all history for tags
26+
27+
- name: Set image tag
28+
id: set_tag
29+
run: |
30+
set -e
31+
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
32+
latest_tag=$(git describe --tags --abbrev=0)
33+
echo "computed_tag=${latest_tag}+dev+${GITHUB_SHA}" >> $GITHUB_OUTPUT
34+
else
35+
echo "computed_tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
36+
37+
build:
38+
needs: compute-tag
39+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
40+
with:
41+
image-name: 'dataprotector-subgraph-deployer'
42+
image-tag: ${{ needs.compute-tag.outputs.computed_tag }}
43+
dockerfile: './packages/subgraph/deployer.Dockerfile'
44+
security-scan: false
45+
hadolint: false
46+
push: ${{ needs.compute-tag.outputs.should_push == 'true' }}
47+
secrets:
48+
username: ${{ secrets.DOCKERHUB_USERNAME }}
49+
password: ${{ secrets.DOCKERHUB_PAT }}

.github/workflows/docker-test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Test Docker Image
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'packages/subgraph/**'
7+
- 'packages/subgraph/deployer.Dockerfile'
8+
build-test:
9+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
10+
with:
11+
image-name: 'dataprotector-subgraph-deployer'
12+
image-tag: ${{ github.sha }}
13+
dockerfile: './packages/subgraph/deployer.Dockerfile'
14+
push: false
15+
security-scan: true

0 commit comments

Comments
 (0)