Skip to content

Commit

Permalink
change activity workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartaithan committed Nov 28, 2024
1 parent 3234386 commit 2641e9d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Supabase Activity
on:
schedule:
- cron: "0 0 * * 0,3"
- cron: "0 9 * * 1,4"
workflow_dispatch:

jobs:
send-http-request:
runs-on: ubuntu-latest
steps:
- name: Send HTTP Request
run: curl https://trophy-hunt.vercel.app/api/supabase-activity
run: curl https://trophy-hunt.vercel.app/api/activity
24 changes: 24 additions & 0 deletions app/api/activity/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createClient } from "@/utils/supabase/server";
import { cookies } from "next/headers";

interface Data {
id: number;
value: string;
}

const table = "keep-alive";

export const GET = async (): Promise<Response> => {
try {
const sb = createClient(cookies());
const { data, error } = await sb.from(table).select("id").single<Data>();
if (error !== null) throw new Error(error.message);
const payload = { value: new Date().toISOString() };
const remove = await sb.from(table).update(payload).eq("id", data.id);
if (remove.error !== null) throw new Error(remove.error.message);
return Response.json(`Success! ${payload.value}`);
} catch (error) {
const message = (error as Error).message ?? "An error occurred.";
return Response.json(message, { status: 400 });
}
};
17 changes: 0 additions & 17 deletions app/api/supabase-activity/route.ts

This file was deleted.

0 comments on commit 2641e9d

Please sign in to comment.