mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
ci: add GitHub Pages deployment workflow for web app
Adds automated deployment to GitHub Pages with custom domain app.hapi.run, and updates vite.config.ts to support dynamic base URL via VITE_BASE_URL environment variable
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
name: Deploy Web App to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'web/**'
|
||||
- '.github/workflows/webapp.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
- run: bun install
|
||||
- name: Build web app
|
||||
run: bun run --cwd web build
|
||||
- name: Add CNAME for custom domain
|
||||
run: echo "app.hapi.run" > web/dist/CNAME
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: web/dist
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
+5
-3
@@ -3,6 +3,8 @@ import react from '@vitejs/plugin-react'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
const base = process.env.VITE_BASE_URL || '/'
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
host: true,
|
||||
@@ -31,8 +33,8 @@ export default defineConfig({
|
||||
background_color: '#ffffff',
|
||||
display: 'standalone',
|
||||
orientation: 'portrait',
|
||||
scope: '/',
|
||||
start_url: '/',
|
||||
scope: base,
|
||||
start_url: base,
|
||||
icons: [
|
||||
{
|
||||
src: 'pwa-64x64.png',
|
||||
@@ -126,7 +128,7 @@ export default defineConfig({
|
||||
}
|
||||
})
|
||||
],
|
||||
base: '/',
|
||||
base,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
|
||||
Reference in New Issue
Block a user