Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Update CI workflows #108

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check | PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build and Test
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: lts/hydrogen
- name: Install [email protected]
run: |
corepack enable
corepack prepare [email protected] --activate

- name: Install
run: yarn install

- name: Lint
run: yarn lint
80 changes: 0 additions & 80 deletions .github/workflows/deploy-prod.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/deploy-uat.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/sync-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Utility | Sync
run-name: Sync `main` branch
on:
push:
branches: ["main"]
jobs:
sync_branch:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- uat/porcini
- uat/mainnet
- prod/porcini

steps:
- name: Checkout latest code
uses: actions/checkout@v3
- name: Sync `main` to `${{ matrix.branch }}`
run: |
git fetch
git checkout ${{ matrix.branch }}
git reset --hard main
git push origin ${{ matrix.branch }} --force-with-lease
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.next
yarn.lock
node_modules
.yarn
.yarn
.vercel
*.sublime-*
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ yarn && yarn dev

- Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Deployment

### UAT Environments

All commits merged to `main` branch will trigger deployments on Vercel for the following environments:

- UAT/Porcini: https://trn-block-explorer-porcini.vercel.app
- UAT/Mainnet: https://trn-block-explorer-mainnet.vercel.app

### PROD Environment

A commit that starts with `Release v` message will trigger production deployment on Vercel when merge to `main`

- PROD/Porcini: https://explorer.rootnet.cloud
- PROD/Mainnet: https://explorer.rootnet.live

## 📥 Provide Feedback

- [Start a Discussion](https://github.com/futureversecom/trn-block-explorer/discussions) with a question, piece of feedback, or idea you want to share with the team.
- [Open an Issue](https://github.com/futureversecom/trn-block-explorer/issues) if you believe you've encountered a bug that you want to flag for the team.
- [Open an Issue](https://github.com/futureversecom/trn-block-explorer/issues) if you believe you've encountered a bug that you want to flag for the team.
36 changes: 21 additions & 15 deletions libs/hooks/useStakedBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,27 @@ export const useStakedBalance = (address: string) => {

const subscribeToLedger = async (address: string) => {
const bondedAccount = await api.query.staking.bonded(address);
const stakedAccount = bondedAccount.toString() === address ? address : bondedAccount.toString();
const unsub = await api.query.staking.ledger(stakedAccount, (res: Codec) => {
const ledger = res.toJSON() as unknown as Ledger;
const { total, active } = ledger ?? { total: 0, active: 0 };

setStateWithRef(
{
total,
active,
unlocking: total - active,
},
setBalance,
balanceRef
);
});
const stakedAccount =
bondedAccount.toString() === address
? address
: bondedAccount.toString();
const unsub = await api.query.staking.ledger(
stakedAccount,
(res: Codec) => {
const ledger = res.toJSON() as unknown as Ledger;
const { total, active } = ledger ?? { total: 0, active: 0 };

setStateWithRef(
{
total,
active,
unlocking: total - active,
},
setBalance,
balanceRef
);
}
);

setStateWithRef(unsubsRef.current.concat(unsub), setUnsubs, unsubsRef);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint": "prettier --config .prettierrc.js --check . && next lint",
"format": "prettier --config .prettierrc.js --write .",
"gen": "graphql-codegen --config codegen.yml",
"schema": "gq $GRAPHQL_ENDPOINT --introspect > libs/schema.graphql"
Expand Down
13 changes: 13 additions & 0 deletions tools/vercel-build-control.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { VERCEL_ENV, VERCEL_GIT_COMMIT_REF, VERCEL_GIT_COMMIT_MESSAGE } =
process.env;

const isProduction =
VERCEL_ENV === "production" || VERCEL_GIT_COMMIT_REF.indexOf("prod") >= 0;

const isReleaseCommit = VERCEL_GIT_COMMIT_MESSAGE.indexOf("Release v") >= 0;

// If deployment is production, build if it's a "release" commit
if (isProduction) process.exit(isReleaseCommit ? 1 : 0);

// If deployment is not production, build if it's NOT a "release" commit
process.exit(!isReleaseCommit ? 1 : 0);