Skip to content

Commit

Permalink
ci: multiplee docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
osiastedian committed Oct 3, 2024
1 parent 79d800c commit bb55587
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 31 deletions.
40 changes: 33 additions & 7 deletions .github/workflows/ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,49 @@ name: Github Image Build and Push
on:
push:
branches:
- 'main'
- 'testnet-support'
- "main"
- "testnet-support"

jobs:
docker:
# i f: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
network:
- mainnet
- testnet
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set environment variables
run: |
if [ "${{ matrix.network }}" == "mainnet" ]; then
echo "NEXT_PUBLIC_NEVM_RPC_URL=https://rpc.syscoin.org" >> $GITHUB_ENV
echo "NEXT_PUBLIC_IS_TESTNET=false" >> $GITHUB_ENV
echo "NEXT_PUBLIC_NEVM_EXPLORER_URL=https://explorer.syscoin.org" >> $GITHUB_ENV
echo "NEXT_PUBLIC_CHAIN_ID=57" >> $GITHUB_ENV
echo "NEXT_PUBLIC_BLOCKBOOK_API_URL=https://blockbook.syscoin.org" >> $GITHUB_ENV
elif [ "${{ matrix.network }}" == "testnet" ]; then
echo "NEXT_PUBLIC_NEVM_RPC_URL=https://rpc.tanenbaum.io" >> $GITHUB_ENV
echo "NEXT_PUBLIC_IS_TESTNET=true" >> $GITHUB_ENV
echo "NEXT_PUBLIC_NEVM_EXPLORER_URL=https://tanenbaum.io" >> $GITHUB_ENV
echo "NEXT_PUBLIC_CHAIN_ID=5700" >> $GITHUB_ENV
echo "NEXT_PUBLIC_BLOCKBOOK_API_URL=https://blockbook-dev.syscoin.org" >> $GITHUB_ENV
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/syscoin/syscoin-bridge
# generate Docker tags based on the following events/attributes
ghcr.io/syscoin/syscoin-bridge-${{ matrix.network }}
tags: |
type=schedule
type=ref,event=branch
Expand All @@ -35,6 +54,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -45,9 +65,16 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
NEXT_PUBLIC_NEVM_RPC_URL=$NEXT_PUBLIC_NEVM_RPC_URL
NEXT_PUBLIC_IS_TESTNET=$NEXT_PUBLIC_IS_TESTNET
NEXT_PUBLIC_NEVM_EXPLORER_URL=$NEXT_PUBLIC_NEVM_EXPLORER_URL
NEXT_PUBLIC_CHAIN_ID=$NEXT_PUBLIC_CHAIN_ID
NEXT_PUBLIC_BLOCKBOOK_API_URL=$NEXT_PUBLIC_BLOCKBOOK_API_URL
- name: Write metadata
run: "cp $DOCKER_METADATA_OUTPUT_BAKE_FILE metadata.json"
Expand All @@ -57,4 +84,3 @@ jobs:
with:
name: metadata
path: metadata.json

5 changes: 2 additions & 3 deletions components/Bridge/NEVMStepWrapepr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNEVM } from "@contexts/ConnectedWallet/NEVMProvider";
import { usePaliWalletV2 } from "@contexts/PaliWallet/usePaliWallet";
import { Button } from "@mui/material";
import { isValidEthereumAddress } from "@pollum-io/sysweb3-utils";
import { useFeatureFlags } from "./hooks/useFeatureFlags";
import { CHAIN_ID } from "@constants";

type Props = {
children: React.ReactNode;
Expand All @@ -11,7 +11,6 @@ type Props = {
const NEVMStepWrapper: React.FC<Props> = ({ children }) => {
const { version, isBitcoinBased, switchTo, isEVMInjected, connectWallet } =
usePaliWalletV2();
const { chainId: expectedChainId } = useFeatureFlags();

const { connect, account, chainId, switchToMainnet } = useNEVM();

Expand All @@ -35,7 +34,7 @@ const NEVMStepWrapper: React.FC<Props> = ({ children }) => {
);
}

if (chainId !== `0x${Number(expectedChainId).toString(16)}`) {
if (chainId !== `0x${Number(CHAIN_ID).toString(16)}`) {
return (
<Button variant="contained" onClick={switchToMainnet}>
Switch to NEVM Network
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MIN_AMOUNT } from "@constants";
import { CHAIN_ID, MIN_AMOUNT } from "@constants";
import { SYSX_ASSET_GUID } from "@contexts/Transfer/constants";
import { ITransfer } from "@contexts/Transfer/types";
import { CheckCircleOutline } from "@mui/icons-material";
Expand All @@ -23,7 +23,6 @@ export const ConnectValidateStartTransferButton: React.FC<{
transfer: ITransfer;
isSaving: boolean;
}> = ({ isSaving, transfer }) => {
const { chainId: CHAIN_ID } = useFeatureFlags();
const {
watch,
formState: { errors, isValid },
Expand Down
4 changes: 1 addition & 3 deletions components/Bridge/UTXOStepWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CHAIN_ID } from "@constants";
import { usePaliWalletV2 } from "@contexts/PaliWallet/usePaliWallet";
import { Button } from "@mui/material";
import { isValidSYSAddress } from "@pollum-io/sysweb3-utils";
import { useFeatureFlags } from "./hooks/useFeatureFlags";

type UTXOStepWrapperProps = {
children: React.ReactNode;
Expand All @@ -17,8 +17,6 @@ const UTXOStepWrapper: React.FC<UTXOStepWrapperProps> = ({ children }) => {
changeAccount,
} = usePaliWalletV2();

const { chainId: CHAIN_ID } = useFeatureFlags();

if (version === "v2" && !isBitcoinBased) {
return (
<Button variant="contained" onClick={() => switchTo("bitcoin")}>
Expand Down
2 changes: 0 additions & 2 deletions components/Bridge/hooks/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useQuery } from "react-query";
type FeatureFlags = {
foundationFundingAvailable: boolean;
adminEnabled: boolean;
chainId: string;
};

export const useFeatureFlags = () => {
Expand All @@ -14,6 +13,5 @@ export const useFeatureFlags = () => {
return {
isEnabled: (flag: keyof FeatureFlags) =>
(flags.isFetched && flags.data?.[flag]) ?? false,
chainId: flags.data?.chainId ? parseInt(flags.data.chainId) : 57,
};
};
5 changes: 1 addition & 4 deletions constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ export const NEVM_TX_BLOCKCHAIN_URL = `${process.env.NEXT_PUBLIC_NEVM_EXPLORER}/

export const ADMIN_LOGIN_MESSAGE = "Login to Syscoin Bridge Admin";

export const CHAIN_ID =
`${process.env.NEXT_PUBLIC_IS_TESTNET}` === "true" ? 5700 : 57;

console.log("next is testnet", process.env.NEXT_PUBLIC_IS_TESTNET, CHAIN_ID);
export const CHAIN_ID = parseInt(process.env.NEXT_PUBLIC_CHAIN_ID || "57");
9 changes: 4 additions & 5 deletions contexts/PaliWallet/V2Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { utils as syscoinUtils } from "syscoinjs-lib";
import { PaliWallet } from "./types";
import MetamaskProvider from "@contexts/Metamask/Provider";
import { isValidSYSAddress } from "@pollum-io/sysweb3-utils";
import { useFeatureFlags } from "components/Bridge/hooks/useFeatureFlags";
import { CHAIN_ID } from "@constants";

export interface ProviderState {
xpub: string;
Expand Down Expand Up @@ -76,7 +76,6 @@ export const PaliWalletV2Provider: React.FC<{
children: React.ReactElement;
}> = ({ children }) => {
const queryClient = useQueryClient();
const { chainId } = useFeatureFlags();
const installed = useQuery(["pali", "is-installed"], {
queryFn: () => {
return Boolean(window.pali) && window.pali.wallet === "pali-v2";
Expand Down Expand Up @@ -153,7 +152,7 @@ export const PaliWalletV2Provider: React.FC<{
() =>
connectedAccount.isSuccess &&
connectedAccount.data &&
isValidSYSAddress(connectedAccount.data.address, chainId)
isValidSYSAddress(connectedAccount.data.address, CHAIN_ID)
? connectedAccount.data.address
: undefined,
[connectedAccount.data, connectedAccount.isSuccess]
Expand Down Expand Up @@ -221,7 +220,7 @@ export const PaliWalletV2Provider: React.FC<{
method: "sys_changeUTXOEVM",
params: [
{
chainId,
chainId: CHAIN_ID,
},
],
})
Expand All @@ -234,7 +233,7 @@ export const PaliWalletV2Provider: React.FC<{
method: "eth_changeUTXOEVM",
params: [
{
chainId,
chainId: CHAIN_ID,
},
],
})
Expand Down
8 changes: 3 additions & 5 deletions contexts/Transfer/constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { utils as syscoinUtils } from "syscoinjs-lib";
export const SYSX_ASSET_GUID = "123456";
const isTestnet = process.env.NEXT_PUBLIC_IS_TESTNET === "true";
export const BlockbookAPIURL = isTestnet
? "https://blockbook-dev.syscoin.org"
: "https://blockbook.syscoin.org";
export const BlockbookAPIURL = process.env.NEXT_PUBLIC_BLOCKBOOK_API_URL;

export const UTXO_NETWORK = isTestnet
? syscoinUtils.syscoinNetworks.testnet
Expand All @@ -17,6 +15,6 @@ export const NEVMNetwork = {
symbol: isTestnet ? "TSYS" : "SYS",
decimals: 18,
},
rpcUrls: [process.env.NEVM_RPC_URL!],
blockExplorerUrls: [process.env.NEXT_PUBLIC_NEVM_EXPLORER],
rpcUrls: [process.env.NEXT_PUBLIC_NEVM_RPC_URL!],
blockExplorerUrls: [process.env.NEXT_PUBLIC_NEVM_EXPLORER_URL],
};

0 comments on commit bb55587

Please sign in to comment.