Skip to content

chore: apply customization testimonials.testimonial1.author #27

chore: apply customization testimonials.testimonial1.author

chore: apply customization testimonials.testimonial1.author #27

Workflow file for this run

name: Deploy React App to GitHub Pages
on:
push:
branches: [ "main" ]
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-pm
run: |
if [ -f "bun.lockb" ]; then
echo "manager=bun" >> $GITHUB_OUTPUT
echo "lockfile=bun.lockb" >> $GITHUB_OUTPUT
elif [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
elif [ -f "pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT
else
echo "manager=npm" >> $GITHUB_OUTPUT
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: ${{ steps.detect-pm.outputs.manager == 'npm' && 'npm' || '' }}
cache-dependency-path: ${{ steps.detect-pm.outputs.lockfile }}
- name: Setup Bun
if: steps.detect-pm.outputs.manager == 'bun'
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Setup pnpm
if: steps.detect-pm.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install dependencies
run: |
if [ "${{ steps.detect-pm.outputs.manager }}" = "bun" ]; then
bun install
elif [ "${{ steps.detect-pm.outputs.manager }}" = "yarn" ]; then
yarn install --frozen-lockfile
elif [ "${{ steps.detect-pm.outputs.manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
- name: Verify Vite Configuration
run: |
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
echo "Repository name: $REPO_NAME"
echo "Expected base path: /$REPO_NAME/"
# Check if vite.config exists and show its content
if [ -f "vite.config.ts" ]; then
echo "=== vite.config.ts content ==="
cat vite.config.ts
elif [ -f "vite.config.js" ]; then
echo "=== vite.config.js content ==="
cat vite.config.js
else
echo "No vite.config found"
fi
# Check if React Router configuration exists
if [ -f "src/main.tsx" ]; then
echo "=== src/main.tsx content ==="
cat src/main.tsx
elif [ -f "src/main.jsx" ]; then
echo "=== src/main.jsx content ==="
cat src/main.jsx
fi
- name: Patch Vite base path for GitHub Pages
run: |
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
if [ -f "vite.config.ts" ]; then
echo "Patching vite.config.ts base to /$REPO_NAME/"
sed -i.bak -E "s|base: ?['\"][^'\"]*['\"]|base: '/$REPO_NAME/'|" vite.config.ts
cat vite.config.ts
elif [ -f "vite.config.js" ]; then
echo "Patching vite.config.js base to /$REPO_NAME/"
sed -i.bak -E "s|base: ?['\"][^'\"]*['\"]|base: '/$REPO_NAME/'|" vite.config.js
cat vite.config.js
else
echo "No vite.config found to patch base path."
fi
- name: Build
env:
NODE_ENV: production
VITE_BASE_PATH: "/harmony-wellness-spa-demo/"
run: |
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
export VITE_BASE_PATH="/$REPO_NAME/"
echo "Building for base path: $VITE_BASE_PATH"
if [ "${{ steps.detect-pm.outputs.manager }}" = "bun" ]; then
bun run build
elif [ "${{ steps.detect-pm.outputs.manager }}" = "yarn" ]; then
yarn build
elif [ "${{ steps.detect-pm.outputs.manager }}" = "pnpm" ]; then
pnpm run build
else
npm run build
fi
- name: Create 404.html for client-side routing
run: cp ./dist/index.html ./dist/404.html
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
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