Skip to content

Commit

Permalink
added student table, cicd to supabase, example to query from supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
colinpeng-datascience committed Dec 16, 2024
1 parent cda6699 commit 8e8000a
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/supabase-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy to Supabase on merge

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Supabase CLI
run: npm install -g supabase

- name: Authenticate Supabase CLI
run: supabase login --token "${{ secrets.SUPABASE_ACCESS_TOKEN }}"

- name: Link Supabase Project
run: supabase link --project-ref "${{ secrets.SUPABASE_PROJECT_REF }}" --password "${{ secrets.SUPABASE_DB_PWD }}"
- name: Deploy migrations
run: supabase db push

- name: Deploy Edge Functions
run: |
if [ -d "supabase/functions" ] && [ "$(ls -A supabase/functions)" ]; then
supabase functions deploy
else
echo "No functions to deploy."
fi
36 changes: 36 additions & 0 deletions .github/workflows/supabase-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to Supabase on PR

on: pull_request
name: Deploy to Supabase on merge

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Supabase CLI
run: npm install -g supabase

- name: Authenticate Supabase CLI
run: supabase login --token "${{ secrets.SUPABASE_ACCESS_TOKEN }}"

- name: Link Supabase Project
run: supabase link --project-ref "${{ secrets.SUPABASE_PROJECT_REF }}" --password "${{ secrets.SUPABASE_DB_PWD }}"
- name: Deploy migrations
run: supabase db push

- name: Deploy Edge Functions
run: |
if [ -d "supabase/functions" ] && [ "$(ls -A supabase/functions)" ]; then
supabase functions deploy
else
echo "No functions to deploy."
fi
49 changes: 41 additions & 8 deletions src/pages/students/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,50 @@
// project import
import { Typography } from '@mui/material';
import MainCard from '../../components/MainCard';
import { useState, useEffect } from 'react';
import { supabaseClient } from '../../services/supabaseClient';

// ================================|| 404 ||================================ //
interface Student {
id: number; // Adjust based on your database schema
first_name: string; // Example field, replace with your schema fields
last_name: string;
age: number;
country: string;
}

const StudentsPage: React.FC = () => {
return (
<MainCard title="Students Page">
<Typography>List/Table of students enrolled in the program.</Typography>
<Typography>Should include method to upload a spreadsheet</Typography>
<Typography>Investigate integration with Google Docs to obtain data</Typography>
</MainCard>
)
const [students, setStudents] = useState<Student[]>([]);

useEffect(() => {
const getTodos = async () => {
try {
const { data: students, error } = await supabaseClient.from('student_tbl').select();

if (error) {
console.error('Error fetching students:', error.message);
} else if (students) {
setStudents(students);
}
} catch (err) {
console.error('Unexpected error:', err);
}
};

getTodos();
}, []);

return (
<MainCard title="Students Page">
<Typography>List/Table of students enrolled in the program.</Typography>
<Typography>Should include method to upload a spreadsheet</Typography>
<Typography>Investigate integration with Google Docs to obtain data</Typography>
<div>
{students.map((student) => (
<li key={student.id}>{student.first_name}</li>
))}
</div>
</MainCard>
);
};

export default StudentsPage;
Loading

0 comments on commit 8e8000a

Please sign in to comment.