From c15a0872e96fce14ec26454f8266928341d281ae Mon Sep 17 00:00:00 2001 From: Mikhail Yarmaliuk Date: Thu, 13 Jul 2023 20:57:59 +0200 Subject: [PATCH] chore: test version injection --- .github/workflows/release.yml | 83 +++++++++++++++++++++++------------ src/constants/index.ts | 3 ++ src/pages/home/index.tsx | 8 ++++ 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 39826ac..29e767c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,34 +10,59 @@ jobs: with: app-build-args: --unlock-robots - release: - needs: [build] - uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-release.yml@staging - with: - has-release-asset: true - secrets: - github-token: ${{ secrets.GITHUB_TOKEN }} + # inject actual version to app + inject-version: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.ref }}-inject-version + cancel-in-progress: true - docker-build: - needs: [build, release] - uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-docker-build.yml@staging - with: - registry: ghcr.io - image-name: ${{ github.repository }}/web - version: ${{ needs.release.outputs.version }} - app-build-path: ./build - secrets: - github-token: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/download-artifact@v3 + with: + name: build-artifact - deploy-aws: - needs: [docker-build] - uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-deploy-aws.yml@staging - with: - image: ${{ needs.docker-build.outputs.image-tag }} - service: vite-template - cluster: Development - task-container-name: web - secrets: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} + - name: Inject version + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: '"APP_VERSION"' + replace: '"5.5.5"' + regex: false + + - name: App build + uses: actions/upload-artifact@v3 + with: + name: build-artifact + path: ${{ github.workspace }} + +# release: +# needs: [build] +# uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-release.yml@staging +# with: +# has-release-asset: true +# secrets: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# +# docker-build: +# needs: [build, release] +# uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-docker-build.yml@staging +# with: +# registry: ghcr.io +# image-name: ${{ github.repository }}/web +# version: ${{ needs.release.outputs.version }} +# app-build-path: ./build +# secrets: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# +# deploy-aws: +# needs: [docker-build] +# uses: Lomray-Software/vite-ssr-boost/.github/workflows/ssr-boost-deploy-aws.yml@staging +# with: +# image: ${{ needs.docker-build.outputs.image-tag }} +# service: vite-template +# cluster: Development +# task-container-name: web +# secrets: +# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} +# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# AWS_REGION: ${{ secrets.AWS_REGION }} diff --git a/src/constants/index.ts b/src/constants/index.ts index 26676e0..1a786ca 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -5,3 +5,6 @@ export const IS_CLIENT = typeof window !== 'undefined'; export const IS_PROD = import.meta.env.MODE === 'production'; export const API_GATEWAY = import.meta.env.VITE_API_GATEWAY; + +// will be replaced in github workflows +export const APP_VERSION = 'APP_VERSION'; diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index b0343df..d7ea62e 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -3,6 +3,7 @@ import type { FCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route'; import { useState } from 'react'; import { Link } from 'react-router-dom'; import ReactLogoImg from '@assets/images/react.svg'; +import { APP_VERSION, IS_PROD } from '@constants/index'; import RouteManager from '@services/route-manager'; import styles from './styles.module.scss'; @@ -12,6 +13,8 @@ import styles from './styles.module.scss'; */ const Home: FCRoute = () => { const [count, setCount] = useState(0); + // show only on deployed application + const hasVersion = IS_PROD && APP_VERSION !== 'APP_VERSION'; return ( <> @@ -20,6 +23,11 @@ const Home: FCRoute = () => {
SPA, SSR, Mobx, Consistent Suspense, Meta tags
+ {hasVersion && ( +
+ Version: {APP_VERSION} +
+ )}
Vite logo