diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..8ded435 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,18 @@ +name: build + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - run: corepack enable + - run: yarn install --immutable + - run: yarn codegen + - run: yarn build diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..14d2d7e --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,36 @@ +name: push docker image + +on: + push: + branches: + - "main" + +jobs: + build_and_push: + name: build_and_push (${{ matrix.docker.repo }}) + strategy: + matrix: + docker: + - repo: planetariumhq/9c-board + if: github.ref_type == 'branch' + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: login + run: | + docker login \ + --username '${{ secrets.DOCKER_USERNAME }}' \ + --password '${{ secrets.DOCKER_ACCESS_TOKEN }}' + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: build-and-push + run: | + docker buildx build . \ + --platform linux/arm64/v8,linux/amd64 \ + --tag ${{ matrix.docker.repo }}:git-${{ github.sha }} \ + --push diff --git a/Dockerfile b/Dockerfile index 3b84132..28db45c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -ARG NETWORK_MAP FROM node:22-alpine AS base # Install dependencies only when needed @@ -26,7 +25,6 @@ COPY . . # Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED 1 -ENV NETWORK_CONF_MAP ${NETWORK_MAP} RUN yarn build # Production image, copy all the files and run next diff --git a/pages/tools/apiClient.ts b/apiClient.ts similarity index 100% rename from pages/tools/apiClient.ts rename to apiClient.ts diff --git a/pages/[network]/tablesheet/[name].tsx b/pages/[network]/tablesheet/[name].tsx index a7b2e5a..7367710 100644 --- a/pages/[network]/tablesheet/[name].tsx +++ b/pages/[network]/tablesheet/[name].tsx @@ -1,5 +1,5 @@ import type { NextPage, GetServerSideProps } from "next"; -import { getSheet } from "../../tools/apiClient"; +import { getSheet } from "../../../apiClient"; interface TableSheetPageProps { tableSheet: string | null; diff --git a/pages/[network]/tablesheet/index.tsx b/pages/[network]/tablesheet/index.tsx index c37e6b2..e2be840 100644 --- a/pages/[network]/tablesheet/index.tsx +++ b/pages/[network]/tablesheet/index.tsx @@ -1,9 +1,7 @@ import type { NextPage, GetServerSideProps } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; -import { getSheetNames } from "../../tools/apiClient"; - -export const config = { runtime: "edge" }; +import { getSheetNames } from "../../../apiClient"; export const getServerSideProps: GetServerSideProps = async (context) => { const network = context.query.network as string; diff --git a/sdk.ts b/sdk.ts index 51136f2..551bde3 100644 --- a/sdk.ts +++ b/sdk.ts @@ -2,10 +2,6 @@ import { GetServerSidePropsContext } from "next/types"; import { getSdk } from "./generated/graphql-request"; import { GraphQLClient } from "graphql-request" -if (process.env.NETWORK_CONF_MAP === undefined) { - throw new Error("All required environment variables are not set."); -} - function parseNetworkConfMap(confMapString: string): Map> { const map = new Map(); for (const pair of confMapString.split(',')) { @@ -16,9 +12,14 @@ function parseNetworkConfMap(confMapString: string): Map { + if (process.env.NETWORK_CONF_MAP === undefined) { + throw new Error("All required environment variables are not set."); + } + + const networkToSdkMap = parseNetworkConfMap(process.env.NETWORK_CONF_MAP); + const network = context.query.network; if (typeof network !== "string") { throw new Error("Network name parameter is not a string.");