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

ci: deploy Docker image for every push on main branch #30

Merged
merged 6 commits into from
May 14, 2024
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
18 changes: 18 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG NETWORK_MAP
FROM node:22-alpine AS base

# Install dependencies only when needed
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/[network]/tablesheet/[name].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextPage, GetServerSideProps } from "next";
import { getSheet } from "../../tools/apiClient";
import { getSheet } from "../../../apiClient";

interface TableSheetPageProps {
tableSheet: string | null;
Expand Down
4 changes: 1 addition & 3 deletions pages/[network]/tablesheet/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 6 additions & 5 deletions sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ReturnType<typeof getSdk>> {
const map = new Map();
for (const pair of confMapString.split(',')) {
Expand All @@ -16,9 +12,14 @@ function parseNetworkConfMap(confMapString: string): Map<string, ReturnType<type
return map;
}

const networkToSdkMap = parseNetworkConfMap(process.env.NETWORK_CONF_MAP);

export const networkToSDK = (context: GetServerSidePropsContext) => {
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.");
Expand Down