Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Feb 1, 2024
2 parents 70da202 + 8093f2d commit 4de890a
Show file tree
Hide file tree
Showing 17 changed files with 947 additions and 451 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build and deploy

on:
push:
branches: [main, develop]
workflow_dispatch:

jobs:
build:
runs-on: sg
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Restore Cache
id: cache-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.yaml') }}

- name: Install dependency
run: npm install

- name: List the state of node modules
if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' }}
continue-on-error: true
run: npm list

- name: Build
run: npm run build

- name: Archive file
uses: TheDoctor0/[email protected]
with:
filename: thq-${{ github.sha }}.zip
exclusions: '/*node_modules/*'

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: thq-${{ github.sha }}.zip
path: ./thq-${{ github.sha }}.zip

deploy-to-testnet:
runs-on: sg
needs: build
if: ${{ github.ref_name == 'develop' }}
environment: testnet
strategy:
matrix:
target: [SERVER_1, SERVER_2]
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: thq-${{ github.sha }}.zip

- name: Unzip artifact
run: rm -rf ./dist && unzip -q thq-${{ github.sha }}.zip -d ./dist

- name: Deploy to server contract
run: ls -la ./dist && rsync -a ./dist/ ${{ vars[matrix.target] }}:/mnt/ckb/ckb-time-generator

- name: Restart pm2 on server contract
run: ssh ${{ vars[matrix.target] }} 'source ~/.zshrc && cd /mnt/ckb/ckb-time-generator && npm install --omit=dev && npm run reload_testnet'

deploy-to-mainnet:
runs-on: sg
needs: build
if: ${{ github.ref_name == 'main' }}
environment: mainnet
strategy:
matrix:
target: [SERVER_1, SERVER_2]
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: thq-${{ github.sha }}.zip

- name: Unzip artifact
run: rm -rf ./dist && unzip -q thq-${{ github.sha }}.zip -d ./dist

- name: Deploy to server contract
run: ls -la ./dist && rsync -a ./dist/ ${{ vars[matrix.target] }}:/mnt/ckb/ckb-time-generator

- name: Restart pm2 on server contract
run: ssh ${{ vars[matrix.target] }} 'source ~/.zshrc && cd /mnt/ckb/ckb-time-generator && npm install --omit=dev && npm run reload_mainnet'

63 changes: 0 additions & 63 deletions .github/workflows/cd.yaml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/ci.yaml

This file was deleted.

35 changes: 22 additions & 13 deletions config/default.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
---
CKB_NODE_RPC: 'http://127.0.0.1:8114'
CKB_NODE_INDEXER: 'http://127.0.0.1:8114'
CKB_WS_URL: 'ws://127.0.0.1:28114'
LARK_API_KEY: ''
CkbNodeRpc: 'http://127.0.0.1:8114'
CkbNodeIndexer: 'http://127.0.0.1:8114'
CkbOfficialNodeRpc: ''
CkbWsUrl: 'ws://127.0.0.1:28114'
LarkApiKey: ''

loglevel: 'info'
env: ''
Loglevel: 'info'
Env: ''

# Define the servers and its IP address, mainly used for making notification much more readable in lark.
servers: {}
Servers: {}

# Transaction fee used for creating and updating cells.
fee:
create: 1000
update: 1000
Fee:
create: 30000
update: 30000

Notification:
# Unit: block
maxTolerableBehindBlock: 3
# Unit: second
newBlockNotifyLimit: 120
# Unit: second
newBlockWarnLimit: 240

CellDeps:
# The type script used by IndexStateCell.
IndexStateTypeScript:
# The type script used by TimeCell, HeightCell and QuoteCell.
InfoTypeScript:
timestamp:
blocknumber:
quote:
Timestamp:
Blocknumber:
Quote:
15 changes: 11 additions & 4 deletions config/mainnet.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
env: mainnet
CkbOfficialNodeRpc: 'https://mainnet.ckb.dev/'

Env: mainnet

# Transaction fee used for creating and updating cells.
Fee:
create: 30000
update: 30000

CellDeps:
# index-state-cell-type
Expand All @@ -22,21 +29,21 @@ InfoTypeScript:
hashType: 'type'
args: '0x'

timestamp:
Timestamp:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
args: '0x2228dae340f587647362d31e3f04d7a51f8168dc'
PayersPrivateKey: ''

blocknumber:
Blocknumber:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
args: '0xfed559f2f93e5e7958d8a62b0b148cb18bc484bf'
PayersPrivateKey: ''

quote:
Quote:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
Expand Down
15 changes: 11 additions & 4 deletions config/testnet.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
env: testnet
CkbOfficialNodeRpc: 'https://testnet.ckb.dev/'

Env: testnet

# Transaction fee used for creating and updating cells.
Fee:
create: 30000
update: 30000

CellDeps:
# index-state-cell-type
Expand All @@ -22,21 +29,21 @@ InfoTypeScript:
hashType: 'type'
args: '0x'

timestamp:
Timestamp:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
args: '0x6a21bc1b72d1e654f8e2ded400cffa46075494c6'
PayersPrivateKey: ''

blocknumber:
Blocknumber:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
args: '0xa897829e60ee4e3fb0e4abe65549ec4a5ddafad7'
PayersPrivateKey: ''

quote:
Quote:
PayersLockScript:
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
hashType: 'type'
Expand Down
Loading

0 comments on commit 4de890a

Please sign in to comment.