Skip to content

Commit

Permalink
chore: test version injection
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Jul 13, 2023
1 parent 7582ec5 commit c15a087
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 29 deletions.
83 changes: 54 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 3 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 8 additions & 0 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 (
<>
Expand All @@ -20,6 +23,11 @@ const Home: FCRoute = () => {
<meta name="description" content="Home page" />
</Meta>
<div>SPA, SSR, Mobx, Consistent Suspense, Meta tags</div>
{hasVersion && (
<div>
Version: <strong>{APP_VERSION}</strong>
</div>
)}
<div>
<a href="https://vitejs.dev/" target="_blank">
<img src="/vite.svg" className={styles.logo} alt="Vite logo" />
Expand Down

0 comments on commit c15a087

Please sign in to comment.