From 8de1c5a0a34489a18fd646e714908f6c7e8f2a6a Mon Sep 17 00:00:00 2001 From: abikart Date: Thu, 26 Dec 2024 21:07:51 -0500 Subject: [PATCH] feat(deploy): github pages --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++++++++++ apps/frontend/package.json | 3 +- apps/frontend/vite.config.ts | 13 +++++--- 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..33d2a0a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main # or your default branch name + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build-and-deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.18.0' + + - name: Setup PNPM + uses: pnpm/action-setup@v3 + with: + version: '9.12.1' + + - name: Install Dependencies + run: pnpm install + + - name: Build Common Package + run: pnpm common build + + - name: Build Frontend + run: pnpm frontend build + env: + GITHUB_PAGES: true + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'apps/frontend/dist' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 3eff41b..1242378 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", - "preview": "vite preview" + "preview": "vite preview", + "deploy": "GITHUB_PAGES=true vite build" }, "dependencies": { "common": "workspace:*", diff --git a/apps/frontend/vite.config.ts b/apps/frontend/vite.config.ts index 2328e17..aea60a4 100644 --- a/apps/frontend/vite.config.ts +++ b/apps/frontend/vite.config.ts @@ -1,7 +1,10 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react-swc"; -// https://vite.dev/config/ +// https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], -}) + plugins: [react()], + base: process.env.GITHUB_PAGES // Set base URL for GitHub Pages + ? "/starter/" // Replace with your actual repository name + : "/", +});