From e5cd1063d29cb8143095835fe76254a162a50c3a Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Mon, 13 Nov 2023 16:53:34 +0100 Subject: [PATCH] fix: forward build info in docker build --- .github/workflows/main.yml | 6 ++++++ Dockerfile | 5 +++++ src/app/pages/navigation/info/InfoDialog.vue | 2 +- src/types/env.d.ts | 4 ++-- vite.config.ts | 6 +----- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e3eebf..23f297b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,6 +73,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set outputs + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Build and push Docker image uses: docker/build-push-action@v5 with: @@ -83,3 +87,5 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | OCULAR_GENESIS_HOST=${{ env.OCULAR_GENESIS_HOST }} + OCULAR_BUILD_VERSION=${{ github.ref_name }} + OCULAR_BUILD_SHA=${{ steps.vars.outputs.sha_short }} diff --git a/Dockerfile b/Dockerfile index 0508ff5..6306851 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ FROM --platform=$BUILDPLATFORM node:20-alpine AS build ARG OCULAR_GENESIS_HOST +ARG OCULAR_BUILD_VERSION +ARG OCULAR_BUILD_SHA ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" +ENV OCULAR_BUILD_VERSION=${OCULAR_BUILD_VERSION} +ENV OCULAR_BUILD_SHA=${OCULAR_BUILD_SHA} + RUN npx pnpm install --global pnpm@8 WORKDIR /app diff --git a/src/app/pages/navigation/info/InfoDialog.vue b/src/app/pages/navigation/info/InfoDialog.vue index 96bedc9..4b4c862 100644 --- a/src/app/pages/navigation/info/InfoDialog.vue +++ b/src/app/pages/navigation/info/InfoDialog.vue @@ -39,6 +39,7 @@ const { t } = useI18n(); display: flex; flex-direction: column; font-size: var(--font-size-s); + text-align: center; gap: 2px; } @@ -51,7 +52,6 @@ const { t } = useI18n(); font-size: var(--font-size-xs); font-weight: var(--font-weight-l); margin-top: 8px; - text-align: center; } .meta { diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 3d9aa96..5695758 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -31,8 +31,8 @@ interface ImportMetaEnv { // Build information readonly OCULAR_BUILD_TIMESTAMP: number; - readonly OCULAR_BUILD_SHA: string; - readonly OCULAR_BUILD_VERSION: string; + readonly OCULAR_BUILD_VERSION?: string; + readonly OCULAR_BUILD_SHA?: string; } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index fe11593..1229b3d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,11 +18,7 @@ export default defineConfig({ } }, define: { - 'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now(), - 'import.meta.env.OCULAR_BUILD_SHA': JSON.stringify(execSync('git rev-parse --short HEAD').toString().trim()), - 'import.meta.env.OCULAR_BUILD_VERSION': JSON.stringify( - execSync('git describe --tags --always --abbrev=0').toString().trim() - ) + 'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now() }, plugins: [ tsconfigPaths({ loose: true }),