Skip to content

Commit 530515a

Browse files
committed
ci: add GitHub Actions workflow to deploy frontend to GitHub Pages
1 parent fe8aa74 commit 530515a

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy Frontend to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Only trigger if frontend files change, or manually
8+
paths:
9+
- 'frontend/**'
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
working-directory: ./frontend
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: 'npm'
38+
cache-dependency-path: ./frontend/package-lock.json
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Build
44+
run: npm run build
45+
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: ./frontend/dist
50+
51+
deploy:
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
runs-on: ubuntu-latest
56+
needs: build
57+
steps:
58+
- name: Deploy to GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v4

frontend/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'
33

44
export default defineConfig({
55
plugins: [react()],
6+
base: '/SQL-Query-Generator/',
67
server: {
78
proxy: {
89
'/api': 'http://localhost:8000'

0 commit comments

Comments
 (0)