Skip to content

Commit

Permalink
github pages deploy added
Browse files Browse the repository at this point in the history
  • Loading branch information
olesni committed Jan 8, 2024
1 parent 01648b1 commit 8db85f8
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 15 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/jobs/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
workflow_call:

jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
retention-days: 1
- name: Fix permissions
run: |
chmod -c -R +rX "dist/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: dist/

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
test:
needs: build
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
Expand All @@ -14,17 +15,15 @@ jobs:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run Unit Tests
run: npm run test:unit:coverage
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Build
run: npm run build
- uses: actions/upload-artifact@v3
- name: Download the build artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
retention-days: 1
- name: Run Unit Tests
run: npm run test:unit:coverage
- name: Run E2e Tests
run: npm run test:e2e
- uses: actions/upload-artifact@v3
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
name: Main Branch
run-name: ${{ github.actor }} is running main branch tests 🚀
run-name: ${{ github.actor }} is running main branch checks and deploy 🚀

on:
push:
branches: [main]
branches: [main, EO-28/deploy-to-github-pages]

env:
CI: true

concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/jobs/build.yml

test:
uses: ./.github/workflows/test-workflow.yml
uses: ./.github/workflows/jobs/test.yml

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
with:
timeout: 300000
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Pull Request
run-name: ${{ github.actor }} is running pull request checks 🚀
name: Pull Request Title
run-name: ${{ github.actor }} is checking the pull request title 🚀

on:
pull_request:
Expand All @@ -14,7 +14,7 @@ jobs:
steps:
- name: Check PR title
run: |
if [[ "${{ github.event.pull_request.title }}" =~ ^\[EO+-[0-9]+\] ]]; then
if [[ "${{ github.event.pull_request.title }}" =~ ^\[EO-[0-9]+\] ]]; then
echo "Pr title is correct"
else
echo "Incorrect PR title: should starts with [EO-XXXX] where XXXX is a task number"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ env:
CI: true

jobs:
build:
uses: ./.github/workflows/jobs/build.yml

test:
uses: ./.github/workflows/test-workflow.yml
uses: ./.github/workflows/jobs/test.yml

lint:
timeout-minutes: 10
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenAPI editor</title>
</head>
Expand Down
5 changes: 4 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import './index.css';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import routes from './routes';

const router = createBrowserRouter(routes);
const router = createBrowserRouter(routes, {
basename: import.meta.env.BASE_URL,
});
console.log(router);

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
Expand Down
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import 'dotenv/config';

export default defineConfig({
base: process.env.BASE_URL || '/',
plugins: [react()],
server: {
port: 3000,
Expand Down

0 comments on commit 8db85f8

Please sign in to comment.