Skip to content

Commit

Permalink
feat: gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfig committed Sep 3, 2024
1 parent 32246a7 commit 767f4aa
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 4 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy

on:
push:
branches: ["main"]

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install Yarn
run: npm i --g yarn

- name: Install dependencies
run: yarn install --immutable

- name: Build project
run: yarn build
env:
VITE_BASE_APP: '/my-dashboard/'

- name: Upload production-ready build files
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.env
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@types/node": "^22.5.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Router = () => {
}, [])

return (
<BrowserRouter>
<BrowserRouter basename={import.meta.env.VITE_BASE_APP ? import.meta.env.VITE_BASE_APP : '/'}>
<Routes key="routes-root">
{RoutesConfig.map(routeMaker)}
</Routes>
Expand Down
11 changes: 8 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tsconfigPaths()],
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())

return {
plugins: [react(), tsconfigPaths()],
base: env.VITE_BASE_APP ? env.VITE_BASE_APP : '/',
}
})
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,13 @@
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==

"@types/node@^22.5.2":
version "22.5.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.2.tgz#e42344429702e69e28c839a7e16a8262a8086793"
integrity sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==
dependencies:
undici-types "~6.19.2"

"@types/prop-types@*":
version "15.7.12"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
Expand Down Expand Up @@ -2211,6 +2218,11 @@ typescript@^5.5.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==

undici-types@~6.19.2:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

update-browserslist-db@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz#7ca61c0d8650766090728046e416a8cde682859e"
Expand Down

0 comments on commit 767f4aa

Please sign in to comment.