Skip to content

Commit dade316

Browse files
Merge pull request #19 from malgorzatatanska/feat/app-version-component
version name
2 parents 68ffb9f + 5812d22 commit dade316

File tree

10 files changed

+76
-18
lines changed

10 files changed

+76
-18
lines changed

.github/actions/playwright/action.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Playwright Tests
2+
description: Playwright Tests
3+
4+
5+
runs:
6+
using: 'composite'
7+
steps:
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
11+
with:
12+
node-version: 18
13+
- name: Install dependencies
14+
run: npm ci
15+
- name: Install Playwright
16+
run: npx playwright install --with-deps
17+
- name: Run Playwright tests
18+
run: npx playwright test
19+
env:
20+
PLAYWRIGHT_TEST_BASE_URL: 'https://przeprogramowani-frontend-bootstrap.vercel.app/'
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Verify and test
2+
description: Verify and test project
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Lint code
8+
run: npm run lint
9+
shell: bash
10+
11+
- name: Test code
12+
run: npm run test
13+
shell: bash

.github/workflows/deploy-netlify.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ jobs:
1515
- name: Configure node
1616
uses: ./.github/actions/setup-project
1717

18-
- name: Lint code
19-
run: npm run lint
20-
21-
- name: Test code
22-
run: npm run test
18+
- name: Verify and test code
19+
uses: ./.github/actions/verify-test
2320

2421
- name: Build the app
2522
run: npm run build
23+
env:
24+
VITE_ENVIRONMENT: 'Development'
2625

2726
- name: Deploy to Netlify
2827
uses: nwtgck/[email protected]

.github/workflows/deploy-vercel.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ jobs:
1515
- name: Configure node
1616
uses: ./.github/actions/setup-project
1717

18-
- name: Lint code
19-
run: npm run lint
20-
21-
- name: Test code
22-
run: npm run test
18+
- name: Verify and test code
19+
uses: ./.github/actions/verify-test
2320

2421
- name: Build the app
2522
run: npm run build
23+
env:
24+
VITE_ENVIRONMENT: 'Staging'
2625

2726
- name: Deploy app to Vercel production env
2827
uses: ./.github/actions/deploy-vercel
@@ -32,3 +31,10 @@ jobs:
3231
env:
3332
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
3433
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
34+
test:
35+
timeout-minutes: 60
36+
runs-on: ubuntu-latest
37+
needs: deploy
38+
steps:
39+
- name: Run playwright test
40+
uses: ./.github/actions/playwright

.github/workflows/pull_request.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ jobs:
1717
- name: Configure node
1818
uses: ./.github/actions/setup-project
1919

20-
- name: Lint code
21-
run: npm run lint
22-
23-
- name: Test code
24-
run: npm run test
20+
- name: Verify and test code
21+
uses: ./.github/actions/verify-test
2522

2623
- name: Build the app
2724
run: npm run build
25+
env:
26+
VITE_ENVIRONMENT: 'Preview'
2827

2928
- name: Deploy app to Vercel preview env
3029
uses: ./.github/actions/deploy-vercel
@@ -34,3 +33,4 @@ jobs:
3433
env:
3534
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
3635
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
36+
VITE_ENVIRONMENT: 'Preview'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ node_modules
77

88

99
.env
10+
.env.*
1011

1112
/dist/

src/App.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import React from 'react';
22
import { Outlet } from 'react-router-dom';
3+
import { VersionApp } from './components/VersionApp';
34

45
const App = () => {
56
return (
6-
<div>
7+
<div className="relative">
78
<div className="bg-white rounded-lg shadow-sm p-4 mb-4">
89
<h1 className="text-xl font-bold text-center">Rick and Morty - Fan Service !!!</h1>
910
</div>
1011
<Outlet />
12+
<div className="absolute -bottom-20 right-10">
13+
<VersionApp />
14+
</div>
1115
</div>
1216
);
1317
};

src/components/VersionApp.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { useConfig } from '../context/ConfigContext';
3+
4+
export const VersionApp = () => {
5+
const { appVersion } = useConfig();
6+
const viteEnv = import.meta.env.VITE_ENVIRONMENT;
7+
8+
console.log(import.meta.env);
9+
10+
return (
11+
<div>
12+
ENV: {viteEnv} VER: {appVersion}
13+
</div>
14+
);
15+
};

src/types/vite-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="vite/client" />
22

33
interface ImportMetaEnv {
4-
readonly APP_VERSION: string;
4+
readonly VITE_ENVIRONMENT: string;
55
}
66

77
interface ImportMeta {

vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import packageJson from './package.json';
44

5-
const env = loadEnv('', process.cwd(), 'XYZ');
5+
const env = loadEnv('', process.cwd(), 'VITE_ENVIRONMENT');
66

77
console.log(env);
88

0 commit comments

Comments
 (0)