Skip to content

Commit

Permalink
Merge pull request #1 from abikart/main
Browse files Browse the repository at this point in the history
feat(deploy): github pages
  • Loading branch information
abikart authored Dec 27, 2024
2 parents b6a6aa9 + 8de1c5a commit 8d4a7af
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
13 changes: 8 additions & 5 deletions apps/frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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
: "/",
});

0 comments on commit 8d4a7af

Please sign in to comment.