Skip to content

Commit

Permalink
Version number in the footer points to the helm chart version
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Sep 27, 2023
1 parent fe921cf commit aa137b0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
push: true
context: .
tags: ${{needs.prepare_release.outputs.new_web_docker_image_tags}}
build-args: CHART_VERSION="${{needs.prepare_release.outputs.new_chart_version}}"


release:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COPY .compatibility ./.compatibility
RUN yarn install --frozen-lockfile
COPY config-overrides.js tsconfig.json ./
COPY src ./src
ARG CHART_VERSION=""
RUN yarn build
COPY nginx.conf ./

Expand Down
12 changes: 11 additions & 1 deletion web/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file is picked up by react-app-rewired that we use in place or react-script
// This is an webpack extension to detect circular import (example: A imports B that imports A)
const CircularDependencyPlugin = require("circular-dependency-plugin");
const { DefinePlugin, ProvidePlugin } = require("webpack");
const YAML = require("yaml");

module.exports = function override(config) {
if (!config.resolve.fallback) {
Expand Down Expand Up @@ -42,7 +43,16 @@ module.exports = function override(config) {
}),
new DefinePlugin({
// This let us display the version number in the footer of the app.
"process.env.VERSION": JSON.stringify(process.env.npm_package_version),
"process.env.CHART_VERSION": (()=>{
const { CHART_VERSION } = process.env;

if( CHART_VERSION === undefined ){
return '""';
}

return JSON.stringify(process.env.CHART_VERSION);

})()
}),
],
);
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"_comment": "Yes... We're still using CRA. We'll migrate to Vite as soon as Keycloakify gets support for it",
"start": "react-app-rewired start",
"build": "react-app-rewired build yarn",
"build": "react-app-rewired build",
"build-keycloak-theme": "yarn build && keycloakify",
"storybook": "start-storybook -p 6006",
"postinstall": "cp -rf .compatibility/fs node_modules/ && generate-env-getter && copy-keycloak-resources-to-public",
Expand Down
2 changes: 1 addition & 1 deletion web/src/stories/App/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { meta, getStory } = getStoryFactory({
export default meta;

export const View1 = getStory({
"packageJsonVersion": "0.9.3",
"chartVersion": "4.1.1",
"contributeUrl": "#",
"termsLink": {
"href": "https://example.com",
Expand Down
2 changes: 1 addition & 1 deletion web/src/ui/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function ContextualizedApp() {
<Footer
className={classes.footer}
//NOTE: Defined in ./config-overrides.js
packageJsonVersion={process.env.VERSION!}
chartVersion={process.env.CHART_VERSION || undefined}
contributeUrl={"https://github.com/inseefrlab/onyxia"}
termsLink={routes.terms().link}
/>
Expand Down
20 changes: 11 additions & 9 deletions web/src/ui/App/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import type { Link } from "type-route";
export type Props = {
className?: string;
contributeUrl: string;
packageJsonVersion: string;
chartVersion: string | undefined;
termsLink: Link;
};

export const Footer = memo((props: Props) => {
const { className, contributeUrl, packageJsonVersion, termsLink } = props;
const { className, contributeUrl, chartVersion, termsLink } = props;

const { classes, cx } = useStyles(props);

Expand Down Expand Up @@ -52,13 +52,15 @@ export const Footer = memo((props: Props) => {
<Text typo="body 2">{t("terms of service")}</Text>{" "}
</a>
{spacing}
<a
href={`https://github.com/inseefrlab/onyxia/tree/v${packageJsonVersion}`}
target="_blank"
rel="noreferrer"
>
<Text typo="body 2">v{packageJsonVersion} </Text>
</a>
{chartVersion !== undefined && (
<a
href={`https://github.com/InseeFrLab/onyxia/tree/${chartVersion}/helm-chart`}
target="_blank"
rel="noreferrer"
>
<Text typo="body 2">v{chartVersion} </Text>
</a>
)}
{spacing}
<DarkModeSwitch
size="extra small"
Expand Down

0 comments on commit aa137b0

Please sign in to comment.