Skip to content

Commit c0ced11

Browse files
Merge pull request #66 from rahul-vyas-dev/feat/ci
fix: update deployment workflow and refine Vite configuration
2 parents 5cf488d + 9e4609f commit c0ced11

3 files changed

Lines changed: 38 additions & 66 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,60 @@
11
# Workflow for building and deploying to GitHub Pages
22

3-
name: Deploy site to Pages
3+
name: Deploy Vite App to GitHub Pages
44

55
on:
6-
# Runs on pushes targeting the default branch
76
push:
8-
branches: ["main"]
7+
branches:
8+
- main
99

10-
# Allows you to run this workflow manually from the Actions tab
1110
workflow_dispatch:
1211

13-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14-
permissions:
15-
contents: read
16-
pages: write
17-
id-token: write
18-
19-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2112
concurrency:
22-
group: "pages"
23-
cancel-in-progress: false
13+
group: github-pages
14+
cancel-in-progress: true
2415

2516
jobs:
26-
# Build job
2717
build:
2818
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
2922
steps:
30-
- name: Checkout
23+
- name: Checkout repository
3124
uses: actions/checkout@v4
32-
- name: Detect package manager
33-
id: detect-package-manager
34-
run: |
35-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
36-
echo "manager=yarn" >> $GITHUB_OUTPUT
37-
echo "command=install" >> $GITHUB_OUTPUT
38-
echo "runner=yarn" >> $GITHUB_OUTPUT
39-
exit 0
40-
elif [ -f "${{ github.workspace }}/package.json" ]; then
41-
echo "manager=npm" >> $GITHUB_OUTPUT
42-
echo "command=ci" >> $GITHUB_OUTPUT
43-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
44-
exit 0
45-
else
46-
echo "Unable to determine package manager"
47-
exit 1
48-
fi
49-
- name: Setup Node
25+
26+
- name: Setup Node.js
5027
uses: actions/setup-node@v4
5128
with:
52-
node-version: "20"
53-
cache: ${{ steps.detect-package-manager.outputs.manager }}
54-
- name: Setup Pages
29+
node-version: 22
30+
cache: npm
31+
32+
- name: Setup GitHub Pages
5533
uses: actions/configure-pages@v5
56-
with:
57-
# Automatically inject basePath in your Next.js configuration file and disable
58-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
59-
#
60-
# You may remove this line if you want to manage the configuration yourself.
61-
static_site_generator: next
62-
- name: Restore cache
63-
uses: actions/cache@v4
64-
with:
65-
path: |
66-
.next/cache
67-
# Generate a new cache whenever packages or source files change.
68-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
69-
# If source files changed but packages didn't, rebuild from a prior cache.
70-
restore-keys: |
71-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
34+
7235
- name: Install dependencies
73-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
74-
- name: Build
75-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
76-
- name: Upload artifact
36+
run: npm ci
37+
38+
- name: Build application
39+
run: npm run build
40+
41+
- name: Upload build artifact
7742
uses: actions/upload-pages-artifact@v3
7843
with:
79-
path: ./out
44+
path: ./dist
8045

81-
# Deployment job
8246
deploy:
47+
needs: build
48+
49+
runs-on: ubuntu-latest
50+
permissions:
51+
pages: write
52+
id-token: write
53+
8354
environment:
8455
name: github-pages
8556
url: ${{ steps.deployment.outputs.page_url }}
86-
runs-on: ubuntu-latest
87-
needs: build
57+
8858
steps:
8959
- name: Deploy to GitHub Pages
9060
id: deployment

src/main.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import './styles/global.css'
66

77
ReactDOM.createRoot(document.getElementById('root')).render(
88
<React.StrictMode>
9-
<BrowserRouter>
9+
<BrowserRouter basename={import.meta.env.PROD ? "/OrgExplorer" : "/"}>
1010
<App />
1111
</BrowserRouter>
1212
</React.StrictMode>

vite.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { defineConfig } from 'vite'
2-
import react from '@vitejs/plugin-react'
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
33

4-
export default defineConfig({
4+
export default defineConfig(({ mode }) => ({
55
plugins: [react()],
6-
})
6+
7+
base: mode === "production" ? "/OrgExplorer/" : "/",
8+
}));

0 commit comments

Comments
 (0)