Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/db-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Auto-Update Database

on:
schedule:
- cron: "0 0 * * 0" # weekly on Sunday midnight
workflow_dispatch: # manual trigger

jobs:
sync:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: visor
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

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

- name: Clone problem data repository
run: |
rm -rf leetcode-companywise-interview-questions
git clone --depth 1 https://github.com/snehasishroy/leetcode-companywise-interview-questions.git leetcode-companywise-interview-questions

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25"

- name: Run data merger
working-directory: merger
run: go run . --ci
env:
LOCAL_DATABASE_URL: postgres://postgres:postgres@localhost:5432/visor?sslmode=disable
SUPABASE_DATABASE_URL: ${{ secrets.SUPABASE_DATABASE_URL }}
ROOT_DIR: ../leetcode-companywise-interview-questions

- name: Update last_db_update timestamp
run: |
psql "${{ secrets.SUPABASE_DATABASE_URL }}" \
-c "INSERT INTO app_metadata (id, last_db_update) VALUES (1, now()) ON CONFLICT (id) DO UPDATE SET last_db_update = now();"
10 changes: 8 additions & 2 deletions merger/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package main

import "os"

func main() {
// scrapeGithubMain()
// scrapeTagsMain()
if len(os.Args) > 1 && os.Args[1] == "--ci" {
scrapeGithubMain()
scrapeTagsMain()
supabaseSyncMain()
return
}
supabaseSyncMain() // go run main.go supabase_sync.go
}