Skip to content

Commit bf5a605

Browse files
feat: add modular deployment workflows
- Create separate deployment workflows instead of single dapp-deploy
1 parent 9781290 commit bf5a605

File tree

8 files changed

+578
-0
lines changed

8 files changed

+578
-0
lines changed

.github/workflows/README.md

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# GitHub Workflows - Web3Telegram SDK
2+
3+
Complete documentation of GitHub Actions workflows for the Web3Telegram SDK project.
4+
5+
## 📋 Overview
6+
7+
The project uses 3 categories of workflows:
8+
9+
- **SDK** : CI, build, NPM publication of the SDK
10+
- **DApp** : CI and application deployment
11+
- **Release** : Version management and releases
12+
13+
## 🚀 SDK Workflows
14+
15+
### `sdk-ci.yml`
16+
17+
**SDK CI** - Automatic validation on every PR
18+
19+
- **Trigger** : Pull Request on `src/`, `tests/`, configs
20+
- **Actions** : Lint, unit tests, TypeScript build
21+
- **Concurrency** : Cancels previous runs
22+
23+
### `sdk-npm-publish.yml`
24+
25+
**Manual NPM Publication** - Deploy to NPM
26+
27+
- **Trigger** : `workflow_dispatch`
28+
- **Inputs** : `tag` (latest/nightly)
29+
- **Restriction** : `main` branch only
30+
31+
### `sdk-release.yml`
32+
33+
**Automatic NPM Publication** - Official release
34+
35+
- **Trigger** : Tag `web3telegram-v*`
36+
- **Action** : Publication with `latest` tag
37+
38+
### `reusable-sdk-npm.yml`
39+
40+
**Reusable Workflow** - Template for NPM publication
41+
42+
- **Type** : `workflow_call`
43+
- **Usage** : Used by `sdk-npm-publish.yml` and `sdk-release.yml`
44+
45+
## 🏗️ DApp Workflows
46+
47+
### `dapp-ci.yml`
48+
49+
**Application CI** - DApp code validation
50+
51+
- **Trigger** : Pull Request on `dapp/`
52+
- **Actions** : Lint, tests, validation
53+
54+
### `deployment/deployment-dapp-ci.yml`
55+
56+
**Deployment CI** - Deployment scripts validation
57+
58+
- **Trigger** : Pull Request on `deployment-dapp/`
59+
- **Actions** : Lint, TypeScript scripts tests
60+
61+
## 🚀 Deployment Workflows
62+
63+
### `deployment/dapp-deploy.yml` (Main)
64+
65+
**Complete Deployment**
66+
67+
- **Trigger** : `workflow_dispatch`
68+
- **Inputs** : `environment` (bellecour-dev, arbitrum-sepolia-dev, etc.)
69+
- **Process** :
70+
1. Docker build + Sconify
71+
2. Contract deployment
72+
3. Push secrets
73+
4. Publish sell order
74+
5. Whitelist
75+
6. ENS configuration
76+
77+
### `deployment/01-deploy-dapp-contract.yml`
78+
79+
**Contract Deployment** - Deploy the smart contract
80+
81+
- **Trigger** : `workflow_dispatch`
82+
- **Inputs** : `environment`, `docker_image_tag`, `checksum`, `fingerprint`
83+
- **Outputs** : `app_address`
84+
85+
### `deployment/02-push-dapp-secret.yml`
86+
87+
**Push Secrets** - Push secrets to SMS (Secret Management Service)
88+
89+
- **Trigger** : `workflow_dispatch`
90+
- **Inputs** : `environment`, `app_address`
91+
92+
### `deployment/03-publish-sell-order.yml`
93+
94+
**Sell Order** - Publish a free sell order
95+
96+
- **Trigger** : `workflow_dispatch`
97+
- **Inputs** : `environment`, `app_address`, `price`, `volume`
98+
99+
### `deployment/04-add-resource-whitelist.yml`
100+
101+
**Whitelist** - Add app to a whitelist already deployed on whitelist-smartcontract repo and transfer ownership to web3telegram wallet
102+
103+
- **Trigger** : `workflow_dispatch`
104+
- **Inputs** : `environment`, `app_address`, `whitelist_contract_address`
105+
106+
### `deployment/05-configure-ens.yml`
107+
108+
**ENS Configuration** - Configure ENS name (only on bellecour environment)
109+
110+
- **Trigger** : `workflow_dispatch`
111+
- **Inputs** : `environment`, `app_address`, `ens_name`
112+
113+
## 📦 Release Workflows
114+
115+
### `release.yml`
116+
117+
**Release Please** - Automatic version management
118+
119+
- **Trigger** : Push on `main`
120+
- **Action** : Automatic release PR creation
121+
122+
### `conventional-commits.yml`
123+
124+
**Commit Validation** - Check conventional commits
125+
126+
- **Trigger** : Pull Request
127+
- **Action** : Commit format validation
128+
129+
## 🎯 Usage
130+
131+
### Complete Deployment
132+
133+
```bash
134+
gh workflow run deployment/dapp-deploy.yml -f environment=bellecour-dev
135+
```
136+
137+
### SDK Publication
138+
139+
```bash
140+
# Manual publication
141+
gh workflow run sdk-npm-publish.yml -f tag=nightly
142+
143+
# Automatic publication (via tag)
144+
git tag web3telegram-v1.0.0
145+
git push origin web3telegram-v1.0.0
146+
```
147+
148+
## 🔧 Environments
149+
150+
| Environment | Network | Usage |
151+
| ----------------------- | ----------------- | --------------- |
152+
| `bellecour-dev` | Bellecour Testnet | Development |
153+
| `arbitrum-sepolia-dev` | Arbitrum Sepolia | Testing |
154+
| `bellecour-prod` | Bellecour Mainnet | Production |
155+
| `arbitrum-sepolia-prod` | Arbitrum Sepolia | Production test |
156+
| `arbitrum-prod` | Arbitrum Mainnet | Production |
157+
158+
## 📁 Structure
159+
160+
```
161+
.github/workflows/
162+
├── sdk-ci.yml # SDK CI
163+
├── sdk-npm-publish.yml # Manual NPM publication
164+
├── sdk-release.yml # Automatic NPM publication
165+
├── reusable-sdk-npm.yml # NPM template
166+
├── dapp-ci.yml # DApp CI
167+
├── release.yml # Release Please
168+
├── conventional-commits.yml # Commit validation
169+
└── deployment/ # Deployment workflows
170+
├── dapp-deploy.yml # Main orchestrator
171+
├── 01-deploy-dapp-contract.yml
172+
├── 02-push-dapp-secret.yml
173+
├── 03-publish-sell-order.yml
174+
├── 04-add-resource-whitelist.yml
175+
├── 05-configure-ens.yml
176+
└── deployment-dapp-ci.yml # Deployment CI
177+
```
178+
179+
## ⚡ Benefits
180+
181+
- **Modularity** : Each step can be executed independently
182+
- **Recovery** : In case of failure, restart only the concerned step
183+
- **Flexibility** : Reusable and configurable workflows
184+
- **Security** : Automatic validation and separate environments
185+
- **Traceability** : Detailed logs for each step
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: 01-deploy-dapp-contract
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Deployment environment'
8+
required: true
9+
type: choice
10+
options:
11+
# dev environments
12+
- bellecour-dev
13+
- arbitrum-sepolia-dev
14+
# prod environments (requires a tag starting with dapp-v)
15+
- bellecour-prod
16+
- arbitrum-sepolia-prod
17+
- arbitrum-prod
18+
# Optional inputs for manual override
19+
docker_image_tag:
20+
description: 'Docker image tag (if not provided, will build from scratch)'
21+
required: false
22+
type: string
23+
checksum:
24+
description: 'Docker image checksum (if not provided, will build from scratch)'
25+
required: false
26+
type: string
27+
fingerprint:
28+
description: 'Docker image fingerprint (if not provided, will build from scratch)'
29+
required: false
30+
type: string
31+
32+
jobs:
33+
extract-tag:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
clean_tag: ${{ steps.tag.outputs.clean_tag }}
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
- name: Check and extract tag
41+
id: tag
42+
run: |
43+
if [[ "${{ github.event.inputs.environment }}" == *-prod ]]; then
44+
if [[ "${GITHUB_REF}" != refs/tags/dapp-v* ]]; then
45+
echo "Error: The ref must be a tag starting with 'dapp-v' for production deployments."
46+
exit 1
47+
fi
48+
TAG=${GITHUB_REF#refs/tags/dapp-v}-$(date +%s)
49+
echo "clean_tag=${TAG}" | tee -a $GITHUB_OUTPUT
50+
else
51+
echo "clean_tag=dev" | tee -a $GITHUB_OUTPUT
52+
fi
53+
54+
docker-publish:
55+
if: ${{ !github.event.inputs.docker_image_tag }}
56+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
57+
needs: [extract-tag]
58+
with:
59+
image-name: 'iexechub/web3telegram-dapp'
60+
registry: 'docker.io'
61+
dockerfile: 'dapp/Dockerfile'
62+
context: 'dapp'
63+
security-scan: true
64+
security-report: 'sarif'
65+
hadolint: true
66+
push: true
67+
image-tag: ${{ needs.extract-tag.outputs.clean_tag }}
68+
secrets:
69+
username: ${{ secrets.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_PAT }}
71+
72+
sconify:
73+
if: ${{ !github.event.inputs.docker_image_tag }}
74+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
75+
needs: [docker-publish, extract-tag]
76+
with:
77+
image-name: 'iexechub/web3telegram-dapp'
78+
image-tag: ${{ needs.extract-tag.outputs.clean_tag }}
79+
sconify-debug: false
80+
sconify-prod: true
81+
docker-registry: docker.io
82+
sconify-version: ${{ vars.SCONIFY_VERSION }}
83+
binary: /usr/local/bin/node
84+
command: node
85+
host-path: |
86+
/etc/hosts
87+
/etc/resolv.conf
88+
binary-fs: true
89+
fs-dir: /app
90+
heap: 1G
91+
dlopen: 1
92+
mprotect: 0
93+
secrets:
94+
docker-username: ${{ secrets.DOCKERHUB_USERNAME }}
95+
docker-password: ${{ secrets.DOCKERHUB_PAT }}
96+
scontain-username: ${{ secrets.SCONTAIN_REGISTRY_USERNAME }}
97+
scontain-password: ${{ secrets.SCONTAIN_REGISTRY_PAT }}
98+
scone-signing-key: ${{ secrets.SCONIFY_SIGNING_PRIVATE_KEY }}
99+
100+
deploy-dapp:
101+
needs: [extract-tag, sconify]
102+
runs-on: ubuntu-latest
103+
environment: ${{ inputs.environment }}
104+
outputs:
105+
app_address: ${{ steps.deploy.outputs.app_address }}
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v4
109+
110+
- name: Setup Node.js
111+
uses: actions/setup-node@v4
112+
with:
113+
node-version: '20.19.0'
114+
cache: 'npm'
115+
116+
- name: Install dependencies
117+
run: |
118+
npm ci
119+
cd node_modules/whitelist-smart-contract
120+
npm install --save-dev ts-node
121+
cd ../../deployment-dapp
122+
npm ci
123+
124+
- name: Deploy dapp contract
125+
id: deploy
126+
env:
127+
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
128+
DOCKER_IMAGE_TAG: ${{ github.event.inputs.docker_image_tag || needs.sconify.outputs.prod-image-tag }}
129+
CHECKSUM: ${{ github.event.inputs.checksum || needs.sconify.outputs.prod-checksum }}
130+
FINGERPRINT: ${{ github.event.inputs.fingerprint || needs.sconify.outputs.prod-mrenclave }}
131+
RPC_URL: ${{ secrets.RPC_URL }}
132+
SCONIFY_VERSION: ${{ vars.SCONIFY_VERSION }}
133+
run: |
134+
cd deployment-dapp
135+
npm run deploy-dapp
136+
echo "app_address=$(cat .app-address)" >> $GITHUB_OUTPUT
137+
138+
- name: Upload app address artifact
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: app-address
142+
path: deployment-dapp/.app-address
143+
retention-days: 30
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 02-push-dapp-secret.yml
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Deployment environment'
8+
required: true
9+
type: choice
10+
options:
11+
# dev environments
12+
- bellecour-dev
13+
- arbitrum-sepolia-dev
14+
# prod environments
15+
- bellecour-prod
16+
- arbitrum-sepolia-prod
17+
- arbitrum-prod
18+
app_address:
19+
description: 'App contract address'
20+
required: true
21+
type: string
22+
23+
jobs:
24+
push-secret:
25+
runs-on: ubuntu-latest
26+
environment: ${{ inputs.environment }}
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '20.19.0'
35+
cache: 'npm'
36+
37+
- name: Install dependencies
38+
run: |
39+
npm ci
40+
cd deployment-dapp
41+
npm ci
42+
43+
- name: Create app address file
44+
run: |
45+
echo "${{ inputs.app_address }}" > deployment-dapp/.app-address
46+
echo "Using app address: ${{ inputs.app_address }}"
47+
48+
- name: Push dapp secret
49+
env:
50+
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
51+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
52+
RPC_URL: ${{ secrets.RPC_URL }}
53+
run: |
54+
cd deployment-dapp
55+
npm run push-dapp-secret

0 commit comments

Comments
 (0)