Skip to content

Commit

Permalink
fix: github workflow, types package.json, env examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Aug 28, 2024
1 parent 3b25774 commit 16786d7
Show file tree
Hide file tree
Showing 8 changed files with 696 additions and 86 deletions.
4 changes: 3 additions & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=""
SUPABASE_KEY=""
OPENAI_API_KEY=""
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=
SUPABASE_KEY=
OPENAI_API_KEY=
67 changes: 67 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Database

on:
push:
branches:
- main

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

jobs:
run-migration:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Link Supabase project
run: supabase link --project-ref $SUPABASE_PROJECT_ID

- name: Run migrations
run: supabase db push

generate_types:
runs-on: ubuntu-latest
needs:
- run-migration
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"
- name: Commit and Push generated types
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add src/types/database.ts
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated Supabase types" || echo "Lint-staged check failed"
git push origin main
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79 changes: 0 additions & 79 deletions database.types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default tsEslint.config({
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts"],
ignores: [".github/knip.ts", "src/types/database.ts"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"knip-ci": "",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 5000"
"worker": "wrangler dev --env dev --port 4000",
"supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts",
"supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\""
},
"keywords": [
"typescript",
Expand Down
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Env, PluginInputs } from "./types";
import { Context } from "./types";
import { isIssueCommentEvent } from "./types/typeguards";
import { LogLevel, Logs } from "@ubiquity-dao/ubiquibot-logger";
import { Database } from "./../database.types";
import { Database } from "./types/database";
import { createAdapters } from "./adapters";
import { createClient } from "@supabase/supabase-js";
import { addComments } from "./handlers/add-comments";
Expand All @@ -24,9 +24,9 @@ export async function runPlugin(context: Context) {
return await deleteComment(context);
case "issue_comment.edited":
return await updateComment(context);
default:
logger.error(`Unsupported event: ${eventName}`);
}
} else {
logger.error(`Unsupported event: ${eventName}`);
}
logger.ok(`Exiting plugin`);
}
Expand Down
Loading

0 comments on commit 16786d7

Please sign in to comment.