Skip to content

Commit

Permalink
Merge pull request #196 from polywrap/release/dev
Browse files Browse the repository at this point in the history
Prod Release Feb 20th
  • Loading branch information
dOrgJelli committed Feb 20, 2024
2 parents ea01ba7 + 006bfaa commit 1b5a689
Show file tree
Hide file tree
Showing 145 changed files with 9,566 additions and 2,567 deletions.
4 changes: 3 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
WORKERS_URL=
RUNTIME=local
NEXT_PUBLIC_WORKERS_URL=
NEXTAUTH_URL=
NEXTAUTH_SECRET=
NEXT_PUBLIC_INFURA_PROJECT_ID=
Expand All @@ -7,3 +8,4 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
SUPABASE_JWT_SECRET=
OPENAI_API_KEY=
PINECONE_API_KEY=
47 changes: 40 additions & 7 deletions .github/workflows/cd.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: CD Dev

"""
NOTE: temporarily disabled, need to make new dev environment
on:
push:
branches:
- release/dev
"""

jobs:
Deploy-Dev:
Deploy-API:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand Down Expand Up @@ -60,21 +63,51 @@ jobs:
DEV_NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.DEV_NEXT_PUBLIC_SUPABASE_ANON_KEY }}
DEV_SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.DEV_SUPABASE_SERVICE_ROLE_KEY }}
DEV_OPENAI_API_KEY: ${{ secrets.DEV_OPENAI_API_KEY}}
DEV_PINECONE_API_KEY: ${{ secrets.DEV_PINECONE_API_KEY }}

Deploy-DB:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: cp ../yarn.lock ./ && (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline)
working-directory: ./web

- uses: supabase/setup-cli@v1
with:
version: latest
- run: supabase link --project-ref $SUPABASE_PROJECT_ID
- run: supabase link --project-ref $PROJECT_ID --password $DB_PASSWORD --debug
working-directory: ./web
env:
DB_PASSWORD: ${{ secrets.DEV_SUPABASE_DB_PASSWORD }}
PROJECT_ID: ${{ secrets.DEV_SUPABASE_PROJECT_ID }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.DEV_SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.DEV_SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.DEV_SUPABASE_PROJECT_ID }}

- run: supabase db push
- run: supabase db push --password $DB_PASSWORD
working-directory: ./web
env:
DB_PASSWORD: ${{ secrets.DEV_SUPABASE_DB_PASSWORD }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.DEV_SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.DEV_SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.DEV_SUPABASE_PROJECT_ID }}
- run: curl -X PUT https://api.dev.fundpublicgoods.ai/api/inngest
113 changes: 113 additions & 0 deletions .github/workflows/cd.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: CD Prod

on:
push:
branches:
- release/prod

jobs:
Deploy-API:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
working-directory: ./workers

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
working-directory: ./workers

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline)
working-directory: ./workers

# TODO: rename to all "dev" here to prod and update aws accordingly
- name: Deploy
run: yarn deploy:dev
working-directory: ./workers
env:
DEPLOYMENT_STAGE: dev
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
DEV_INNGEST_SIGNING_KEY: ${{ secrets.DEV_INNGEST_SIGNING_KEY }}
DEV_INNGEST_EVENT_KEY: ${{ secrets.DEV_INNGEST_EVENT_KEY }}
DEV_NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.PROD_NEXT_PUBLIC_SUPABASE_URL }}
DEV_NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PROD_NEXT_PUBLIC_SUPABASE_ANON_KEY }}
DEV_SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.PROD_SUPABASE_SERVICE_ROLE_KEY }}
DEV_OPENAI_API_KEY: ${{ secrets.DEV_OPENAI_API_KEY}}
DEV_PINECONE_API_KEY: ${{ secrets.DEV_PINECONE_API_KEY }}

Deploy-DB:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: cp ../yarn.lock ./ && (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline)
working-directory: ./web

- uses: supabase/setup-cli@v1
with:
version: latest
- run: supabase link --project-ref $PROJECT_ID --password $DB_PASSWORD --debug
working-directory: ./web
env:
DB_PASSWORD: ${{ secrets.PROD_SUPABASE_DB_PASSWORD }}
PROJECT_ID: ${{ secrets.PROD_SUPABASE_PROJECT_ID }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.DEV_SUPABASE_ACCESS_TOKEN }}

- run: supabase db push --password $DB_PASSWORD
working-directory: ./web
env:
DB_PASSWORD: ${{ secrets.PROD_SUPABASE_DB_PASSWORD }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.DEV_SUPABASE_ACCESS_TOKEN }}

# TODO: update to api.fundpublicgoods.ai once updated in AWS
- run: curl -X PUT https://api.dev.fundpublicgoods.ai/api/inngest
11 changes: 7 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- dev
- release/dev
- release/prod
pull_request:

jobs:
Expand Down Expand Up @@ -34,15 +36,16 @@ jobs:
- name: Install dependencies
run: yarn

# TODO: change "PROD_" back to "DEV_" once that exists again
- name: Build
run: yarn build
env:
CICD: true
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.DEV_NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.DEV_NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.DEV_SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.PROD_NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PROD_NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.PROD_SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_INFURA_PROJECT_ID: ${{ secrets.DEV_NEXT_PUBLIC_INFURA_PROJECT_ID}}
WORKERS_URL: ${{ secrets.DEV_WORKERS_URL }}
NEXT_PUBLIC_WORKERS_URL: ${{ secrets.DEV_WORKERS_URL }}

- name: Test
run: yarn test
1 change: 1 addition & 0 deletions ops/scripts/generate_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def run():
create_table_statements = [stmt.replace('"public".', '') for stmt in create_table_statements]
# Remove some unsupported SQL features that break omymodels
create_table_statements = [stmt.replace('DEFAULT "gen_random_uuid"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('DEFAULT "auth"."uid"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('with time zone DEFAULT "now"() NOT NULL', '') for stmt in create_table_statements]
create_table_statements = [stmt.replace('with time zone', '') for stmt in create_table_statements]
create_table_statements = [re.sub(r'(?m)CONSTRAINT.*\n?', '', stmt) for stmt in create_table_statements]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"concurrently": "8.2.2",
"inngest-cli": "^0.23.1"
}
}
}
86 changes: 86 additions & 0 deletions web/app/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"use client";

import { Logo } from "@/components/Logo";
import truncateEthAddress from "@/utils/ethereum/truncateAddress";
import { CaretDown, Link } from "@phosphor-icons/react";
import { useConnectWallet } from "@web3-onboard/react";
import Image from "next/image";
import { useEffect, useRef, useState } from "react";

function Header() {
const [{ wallet }, _, disconnect] = useConnectWallet();
const [showDropdownMenu, setShowDropdownMenu] = useState<boolean>(false);
const dropdownRef = useRef<HTMLDivElement | null>(null);

useEffect(() => {
function handleClickOutside(event: MouseEvent) {
const current = dropdownRef.current;
if (current && !current.contains(event.target as Node)) {
setShowDropdownMenu(false);
}
}

// Bind the event listener
if (showDropdownMenu) {
document.addEventListener("mousedown", handleClickOutside);
}

// Unbind the event listener on clean up
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, [showDropdownMenu]);

return (
<div className='flex w-full justify-between text-sm px-6 py-4 bg-indigo-300/80 border-b-2 border-indigo-400/20'>
<a href='/' className='flex'>
<Logo size={160} />
</a>
{wallet && (
<div className='relative' ref={dropdownRef}>
<div
onClick={() => setShowDropdownMenu((current) => !current)}
className='text-indigo-600 hover:text-indigo-800 font-bold text-sm cursor-pointer flex space-x-1 items-center p-1 rounded-md hover:bg-indigo-500/20'>
<div>
{wallet.accounts[0]?.ens?.name ? (
<div className='flex items-center space-x-2'>
{wallet.accounts[0]?.ens?.avatar && (
<Image
className='min-w-[20px] h-5 rounded-full object-fit bg-white'
src={wallet.accounts[0]?.ens?.avatar.toString()}
alt={wallet.accounts[0]?.ens?.name}
width={20}
height={20}
/>
)}
<div>{wallet.accounts[0]?.ens?.name}</div>
</div>
) : (
<div>{truncateEthAddress(wallet.accounts[0].address)}</div>
)}
</div>
<CaretDown weight='bold' />
</div>
{showDropdownMenu ? <div className='absolute top-[calc(100%+8px)] right-0 z-10' >
<div className='bg-indigo-50 rounded-2xl border-2 border-indigo-300 space-y-2 p-3 shadow-xl shadow-primary-shadow/20'>
<div
className="p-2 flex items-center space-x-2 hover:bg-white cursor-pointer w-full rounded-xl"
onClick={() => {
disconnect(wallet);
setShowDropdownMenu(!showDropdownMenu)
}}
>
<Link size={16} weight='bold' className='min-w-[16px]' />
<div className='whitespace-nowrap'>
Disconnect Wallet
</div>
</div>
</div>
</div> : null}
</div>
)}
</div>
);
}

export default Header;
Loading

0 comments on commit 1b5a689

Please sign in to comment.