Skip to content

Commit 79dae78

Browse files
ci: publish subgraph deployer docker image (#535)
* ci: build subgraph deployer image * ci: publish subgraph deployer image on dispatch (staging) or release (stable)
1 parent dfa669c commit 79dae78

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: docker workflow for dataprotector subgraph deployer
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dry-run:
7+
description: 'Run in dry-run mode (the docker image will not be published)'
8+
default: false
9+
type: boolean
10+
tag:
11+
description: 'Tag of Docker Image'
12+
default: 'latest'
13+
type: string
14+
secrets:
15+
docker-username:
16+
description: 'Docker registry username (required unless `dry-run: true`)'
17+
required: false
18+
docker-password:
19+
description: 'Docker registry password or PAT (required unless `dry-run: true`)'
20+
required: false
21+
22+
jobs:
23+
docker-publish:
24+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
25+
with:
26+
image-name: 'iexechub/dataprotector-subgraph-deployer'
27+
registry: 'docker.io'
28+
dockerfile: 'packages/subgraph/deployer.Dockerfile'
29+
context: 'packages/subgraph'
30+
security-scan: true
31+
security-report: 'sarif'
32+
hadolint: true
33+
push: ${{ !inputs.dry-run }}
34+
image-tag: ${{ inputs.tag }}
35+
secrets:
36+
username: ${{ secrets.docker-username }}
37+
password: ${{ secrets.docker-password }}

.github/workflows/subgraph-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ jobs:
5252
- name: Build
5353
working-directory: packages/subgraph
5454
run: npm run build
55+
56+
deployer-docker-dry-run:
57+
uses: ./.github/workflows/reusable-subgraph-deployer-docker.yml
58+
with:
59+
dry-run: true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Subgraph - deployer Docker Image
2+
3+
on:
4+
# For staging releases
5+
workflow_dispatch:
6+
# For latest releases
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
get-version:
12+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref_name,'subgraph-v')) }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
- name: compute version
22+
id: compute-publish-version
23+
run: |
24+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
25+
if [ "${{ github.event_name }}" = "release" ]; then
26+
echo "Release detected, setting version to ${CURRENT_VERSION}"
27+
echo "VERSION=${CURRENT_VERSION}" | tee -a $GITHUB_OUTPUT
28+
else
29+
echo "Manual dispatch detected, setting staging version"
30+
BRANCH=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
31+
COMMIT_SHA="${{ github.sha }}"
32+
echo "VERSION=${CURRENT_VERSION}-${BRANCH}-${COMMIT_SHA::7}" | tee -a $GITHUB_OUTPUT
33+
fi
34+
outputs:
35+
version: ${{ steps.compute-publish-version.outputs.VERSION }}
36+
37+
docker-publish:
38+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref_name,'subgraph-v')) }}
39+
uses: ./.github/workflows/reusable-subgraph-deployer-docker.yml
40+
needs: get-version
41+
with:
42+
tag: ${{ needs.get-version.outputs.version }}
43+
secrets:
44+
docker-username: ${{ secrets.DOCKERHUB_USERNAME }}
45+
docker-password: ${{ secrets.DOCKERHUB_PAT }}

packages/subgraph/deployer.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20.18
1+
FROM node:20
22

33
RUN mkdir /app
44

0 commit comments

Comments
 (0)