Skip to content

Commit 01f2c10

Browse files
Merge pull request #31 from iExecBlockchainComputing/migrate-to-github-actions
Migrate to GitHub actions
2 parents c55a36b + 39fb6bc commit 01f2c10

22 files changed

+689
-649
lines changed

.drone.yml

Lines changed: 0 additions & 446 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Conventional Commits
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
name: Conventional Commits
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- uses: webiny/[email protected]

.github/workflows/dapp-ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: web3telegram DApp - CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
paths:
8+
- 'dapp/**'
9+
10+
concurrency:
11+
group: ${{ github.ref }}-dapp-ci
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-code:
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./dapp
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 14
26+
cache: 'npm'
27+
cache-dependency-path: dapp/package-lock.json
28+
29+
- name: Install Dependencies
30+
run: npm ci
31+
32+
- name: Lint
33+
run: npm run lint
34+
35+
- name: Check formatting
36+
run: npm run check-format
37+
38+
test:
39+
runs-on: ubuntu-latest
40+
defaults:
41+
run:
42+
working-directory: ./dapp
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 14
49+
cache: 'npm'
50+
cache-dependency-path: dapp/package-lock.json
51+
52+
- name: Install Dependencies
53+
run: npm ci
54+
55+
- name: Test unit
56+
run: npm run test
57+
58+
- name: Test with coverage
59+
run: npm run ctest

.github/workflows/dapp-deploy.yml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: 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+
- dapp-dev
12+
- dapp-prod
13+
image-tag:
14+
description: 'Tag for the dapp image to sconify'
15+
required: true
16+
type: string
17+
default: 'latest'
18+
sconify-version:
19+
description: 'Version of the sconify image to use'
20+
type: string
21+
default: '5.7.6-v15'
22+
23+
env:
24+
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
25+
26+
jobs:
27+
sconify:
28+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
29+
with:
30+
image-name: product/web3telegram-dapp
31+
image-tag: ${{ inputs.image-tag }}
32+
sconify-debug: false
33+
sconify-prod: true
34+
docker-registry: docker.io
35+
sconify-version: ${{ inputs.sconify-version }}
36+
binary: /usr/local/bin/node
37+
command: node /app/src/app.js
38+
host-path: |
39+
/etc/hosts
40+
/etc/resolv.conf
41+
binary-fs: true
42+
fs-dir: /app
43+
heap: 1G
44+
dlopen: 1
45+
mprotect: 1
46+
docker-username: ${{ vars.DOCKERHUB_USERNAME }}
47+
scontain-username: ${{ secrets.SCONTAIN_REGISTRY_USERNAME }}
48+
secrets:
49+
docker-password: ${{ secrets.DOCKERHUB_PAT }}
50+
scontain-password: ${{ secrets.SCONTAIN_REGISTRY_PAT }}
51+
scone-signing-key: ${{ secrets.SCONIFY_SIGNING_PRIVATE_KEY }}
52+
53+
display-sconify-results:
54+
runs-on: ubuntu-latest
55+
needs: sconify
56+
steps:
57+
- name: Display Sconify Results
58+
run: |
59+
echo "## Sconify Results" >> $GITHUB_STEP_SUMMARY
60+
echo "" >> $GITHUB_STEP_SUMMARY
61+
62+
echo "### Production Image" >> $GITHUB_STEP_SUMMARY
63+
echo "- **Image**: ${{ needs.sconify.outputs.prod-image }}" >> $GITHUB_STEP_SUMMARY
64+
echo "- **Checksum**: ${{ needs.sconify.outputs.prod-checksum }}" >> $GITHUB_STEP_SUMMARY
65+
echo "- **MrEnclave**: ${{ needs.sconify.outputs.prod-mrenclave }}" >> $GITHUB_STEP_SUMMARY
66+
echo "" >> $GITHUB_STEP_SUMMARY
67+
68+
echo "### Summary" >> $GITHUB_STEP_SUMMARY
69+
echo "Sconification completed successfully!" >> $GITHUB_STEP_SUMMARY
70+
71+
deploy-dapp:
72+
runs-on: ubuntu-latest
73+
needs: sconify
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Setup Node.js
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: '18.19'
82+
cache: 'npm'
83+
84+
- name: Install dependencies
85+
run: |
86+
npm ci
87+
cd node_modules/whitelist-smart-contract
88+
npm install --save-dev ts-node
89+
cd ../../deployment-dapp
90+
npm ci
91+
92+
- name: Create scone fingerprint file
93+
run: |
94+
MRENCLAVE="${{ needs.sconify.outputs.prod-mrenclave }}"
95+
echo "$MRENCLAVE" > deployment-dapp/.scone-fingerprint
96+
97+
- name: Deploy dapp contract
98+
env:
99+
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
100+
WALLET_PRIVATE_KEY_DEV: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_DEV_PRIVATEKEY }}
101+
WALLET_PRIVATE_KEY_PROD: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_PROD_PRIVATEKEY }}
102+
DOCKER_IMAGE_CHECKSUM_DEV: ${{ needs.sconify.outputs.prod-checksum }}
103+
DOCKER_IMAGE_CHECKSUM_PROD: ${{ needs.sconify.outputs.prod-checksum }}
104+
run: |
105+
cd deployment-dapp
106+
npm run deploy-dapp
107+
108+
- name: Push dapp secret
109+
env:
110+
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
111+
WALLET_PRIVATE_KEY_DEV: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_DEV_PRIVATEKEY }}
112+
WALLET_PRIVATE_KEY_PROD: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_PROD_PRIVATEKEY }}
113+
TELEGRAM_BOT_TOKEN_DEV: ${{ secrets.TELEGRAM_BOT_TOKEN_DEV }}
114+
TELEGRAM_BOT_TOKEN_PROD: ${{ secrets.TELEGRAM_BOT_TOKEN_PROD }}
115+
run: |
116+
cd deployment-dapp
117+
npm run push-dapp-secret
118+
119+
- name: Publish free sell order
120+
env:
121+
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
122+
WALLET_PRIVATE_KEY_DEV: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_DEV_PRIVATEKEY }}
123+
WALLET_PRIVATE_KEY_PROD: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_PROD_PRIVATEKEY }}
124+
PRICE: '0'
125+
VOLUME: '1000000000'
126+
run: |
127+
cd deployment-dapp
128+
npm run publish-sell-order
129+
130+
- name: Add resource to whitelist (dev)
131+
if: inputs.environment == 'dapp-dev'
132+
env:
133+
WALLET_PRIVATE_KEY: ${{ secrets.DEPLOYER_DEV_PRIVATEKEY }}
134+
CONTRACT_ADDRESS: ${{ secrets.WEB3TELEGRAM_WHITELIST_DEV_ADDRESS }}
135+
run: |
136+
cd node_modules/whitelist-smart-contract
137+
export ADDRESS_TO_ADD=$(cat ../../deployment-dapp/.app-address) && npm run addResourceToWhitelist
138+
139+
- name: Add resource to whitelist (prod)
140+
if: inputs.environment == 'dapp-prod'
141+
env:
142+
WALLET_PRIVATE_KEY: ${{ secrets.DEPLOYER_PROD_PRIVATEKEY }}
143+
CONTRACT_ADDRESS: ${{ secrets.WEB3TELEGRAM_WHITELIST_PROD_ADDRESS }}
144+
run: |
145+
cd node_modules/whitelist-smart-contract
146+
export ADDRESS_TO_ADD=$(cat ../../deployment-dapp/.app-address) && npm run addResourceToWhitelist
147+
148+
- name: Configure ENS
149+
env:
150+
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
151+
WALLET_PRIVATE_KEY_DEV: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_DEV_PRIVATEKEY }}
152+
WALLET_PRIVATE_KEY_PROD: ${{ secrets.WEB3TELEGRAM_DAPP_OWNER_PROD_PRIVATEKEY }}
153+
run: |
154+
cd deployment-dapp
155+
npm run configure-ens
156+
157+
- name: Upload deployment artifacts
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: deployment-artifacts
161+
path: |
162+
deployment-dapp/.app-address
163+
deployment-dapp/.scone-fingerprint
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: web3telegram Deployment DApp - CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
paths:
8+
- 'deployment-dapp/**'
9+
- 'deployment-dapp/package.json'
10+
- 'deployment-dapp/package-lock.json'
11+
- 'deployment-dapp/.eslintrc.json'
12+
- 'deployment-dapp/.prettierrc'
13+
14+
concurrency:
15+
group: ${{ github.ref }}-deployment-dapp-ci
16+
cancel-in-progress: true
17+
18+
jobs:
19+
check-code:
20+
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
working-directory: ./deployment-dapp
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 18
30+
cache: 'npm'
31+
cache-dependency-path: deployment-dapp/package-lock.json
32+
33+
- name: Install Dependencies
34+
run: npm ci
35+
36+
- name: Lint
37+
run: npm run lint
38+
39+
- name: Check formatting
40+
run: npm run check-format
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish Package NPM - web3telegram
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'NPM tag to publish (latest or nightly)'
8+
required: true
9+
type: choice
10+
options:
11+
- latest
12+
- nightly
13+
default: nightly
14+
15+
jobs:
16+
set-publish-version:
17+
# Run only on main branch
18+
if: github.ref == 'refs/heads/main'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
- name: Set publish version
26+
id: set-publish-version
27+
if: github.event.inputs.tag == 'nightly'
28+
run: |
29+
if [ "${{ github.event.inputs.tag }}" == "nightly" ]; then
30+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
31+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
32+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
33+
else
34+
echo "VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT
35+
fi
36+
outputs:
37+
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
38+
39+
publish-npm:
40+
# Run only on main branch
41+
if: github.ref == 'refs/heads/main'
42+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
43+
needs: set-publish-version
44+
with:
45+
scope: '@iexec/web3telegram'
46+
registry: 'https://registry.npmjs.org'
47+
node-version: '18'
48+
environment: ${{ github.event.inputs.target }}
49+
tag: ${{ github.event.inputs.tag }}
50+
version: ${{ needs.set-publish-version.outputs.VERSION }}
51+
install-command: |
52+
npm ci
53+
secrets:
54+
npm-token: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
issues: write
9+
pull-requests: write
10+
11+
name: release-please
12+
13+
jobs:
14+
release-please:
15+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
16+
secrets: inherit

0 commit comments

Comments
 (0)