Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version name #19

Merged
merged 7 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/actions/playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Playwright Tests
description: Playwright Tests


runs:
using: 'composite'
steps:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
PLAYWRIGHT_TEST_BASE_URL: 'https://przeprogramowani-frontend-bootstrap.vercel.app/'
13 changes: 13 additions & 0 deletions .github/actions/verify-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Verify and test
description: Verify and test project

runs:
using: 'composite'
steps:
- name: Lint code
run: npm run lint
shell: bash

- name: Test code
run: npm run test
shell: bash
9 changes: 4 additions & 5 deletions .github/workflows/deploy-netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ jobs:
- name: Configure node
uses: ./.github/actions/setup-project

- name: Lint code
run: npm run lint

- name: Test code
run: npm run test
- name: Verify and test code
uses: ./.github/actions/verify-test

- name: Build the app
run: npm run build
env:
VITE_ENVIRONMENT: 'Development'

- name: Deploy to Netlify
uses: nwtgck/[email protected]
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/deploy-vercel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ jobs:
- name: Configure node
uses: ./.github/actions/setup-project

- name: Lint code
run: npm run lint

- name: Test code
run: npm run test
- name: Verify and test code
uses: ./.github/actions/verify-test

- name: Build the app
run: npm run build
env:
VITE_ENVIRONMENT: 'Staging'

- name: Deploy app to Vercel production env
uses: ./.github/actions/deploy-vercel
Expand All @@ -32,3 +31,10 @@ jobs:
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
test:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Run playwright test
uses: ./.github/actions/playwright
10 changes: 5 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ jobs:
- name: Configure node
uses: ./.github/actions/setup-project

- name: Lint code
run: npm run lint

- name: Test code
run: npm run test
- name: Verify and test code
uses: ./.github/actions/verify-test

- name: Build the app
run: npm run build
env:
VITE_ENVIRONMENT: 'Preview'

- name: Deploy app to Vercel preview env
uses: ./.github/actions/deploy-vercel
Expand All @@ -34,3 +33,4 @@ jobs:
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VITE_ENVIRONMENT: 'Preview'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ node_modules


.env
.env.*

/dist/
6 changes: 5 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react';
import { Outlet } from 'react-router-dom';
import { VersionApp } from './components/VersionApp';

const App = () => {
return (
<div>
<div className="relative">
<div className="bg-white rounded-lg shadow-sm p-4 mb-4">
<h1 className="text-xl font-bold text-center">Rick and Morty - Fan Service !!!</h1>
</div>
<Outlet />
<div className="absolute -bottom-20 right-10">
<VersionApp />
</div>
</div>
);
};
Expand Down
15 changes: 15 additions & 0 deletions src/components/VersionApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { useConfig } from '../context/ConfigContext';

export const VersionApp = () => {
const { appVersion } = useConfig();
const viteEnv = import.meta.env.VITE_ENVIRONMENT;

console.log(import.meta.env);

return (
<div>
ENV: {viteEnv} VER: {appVersion}
</div>
);
};
2 changes: 1 addition & 1 deletion src/types/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly APP_VERSION: string;
readonly VITE_ENVIRONMENT: string;
}

interface ImportMeta {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite';
import react from '@vitejs/plugin-react';
import packageJson from './package.json';

const env = loadEnv('', process.cwd(), 'XYZ');
const env = loadEnv('', process.cwd(), 'VITE_ENVIRONMENT');

console.log(env);

Expand Down