Skip to content
Merged
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
46 changes: 38 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,42 @@ jobs:
.catch(err => { console.error(err); process.exit(1); });
")
export SANITY_ORGANIZATION_ID="$ORG_ID"
if [ "${{ vars.SANITY_STUDIO_DATASET }}" = "dev" ]; then
APP_TITLE="CodingCat Ops & Revenue OS (Dev)"
else
APP_TITLE="CodingCat Ops & Revenue OS (Production)"
fi
export APP_TITLE
EXISTING_APP_ID=$(node -e "
fetch('https://api.sanity.io/v2024-08-01/user-applications?appType=coreApp&organizationId=' + process.env.SANITY_ORGANIZATION_ID, {
headers: { Authorization: 'Bearer ' + process.env.SANITY_AUTH_TOKEN }
})
.then(r => r.ok ? r.json() : [])
.then(apps => {
const list = Array.isArray(apps) ? apps : [];
const match = list.find(a => a.title === 'CodingCat Ops & Revenue OS');
const targetTitle = process.env.APP_TITLE;
const isDev = process.env.SANITY_APP_DATASET === 'dev';
const match = list.find(a =>
a.title === targetTitle ||
(isDev && (a.id === 'yiugiba2sjnhpehqmky6nulc' || a.title === 'CodingCat Ops & Revenue OS'))
);
if (match && match.id) console.log(match.id);
})
.catch(() => {});
")
if [ -n "$EXISTING_APP_ID" ]; then
echo "Found existing CodingCat Ops & Revenue OS app: $EXISTING_APP_ID"
echo "Found existing $APP_TITLE app: $EXISTING_APP_ID"
SANITY_OPS_APP_ID="$EXISTING_APP_ID" npx sanity deploy -y
else
echo "Creating and deploying new CodingCat Ops & Revenue OS app in organization $ORG_ID..."
npx sanity deploy -y --create --title "CodingCat Ops & Revenue OS"
echo "Creating and deploying new $APP_TITLE app in organization $ORG_ID..."
npx sanity deploy -y --create --title "$APP_TITLE"
fi
env:
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}
SANITY_APP_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
SANITY_APP_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}

- name: Promote Stack to Organization Scope
run: |
Expand Down Expand Up @@ -236,27 +251,42 @@ jobs:
.catch(err => { console.error(err); process.exit(1); });
")
export SANITY_ORGANIZATION_ID="$ORG_ID"
if [ "${{ vars.SANITY_STUDIO_DATASET }}" = "dev" ]; then
APP_TITLE="CodingCat Ops & Revenue OS (Dev)"
else
APP_TITLE="CodingCat Ops & Revenue OS (Production)"
fi
export APP_TITLE
EXISTING_APP_ID=$(node -e "
fetch('https://api.sanity.io/v2024-08-01/user-applications?appType=coreApp&organizationId=' + process.env.SANITY_ORGANIZATION_ID, {
headers: { Authorization: 'Bearer ' + process.env.SANITY_AUTH_TOKEN }
})
.then(r => r.ok ? r.json() : [])
.then(apps => {
const list = Array.isArray(apps) ? apps : [];
const match = list.find(a => a.title === 'CodingCat Ops & Revenue OS');
const targetTitle = process.env.APP_TITLE;
const isDev = process.env.SANITY_APP_DATASET === 'dev';
const match = list.find(a =>
a.title === targetTitle ||
(isDev && (a.id === 'yiugiba2sjnhpehqmky6nulc' || a.title === 'CodingCat Ops & Revenue OS'))
);
if (match && match.id) console.log(match.id);
})
.catch(() => {});
")
if [ -n "$EXISTING_APP_ID" ]; then
echo "Found existing CodingCat Ops & Revenue OS app: $EXISTING_APP_ID"
echo "Found existing $APP_TITLE app: $EXISTING_APP_ID"
SANITY_OPS_APP_ID="$EXISTING_APP_ID" npx sanity deploy -y
else
echo "Creating and deploying new CodingCat Ops & Revenue OS app in organization $ORG_ID..."
npx sanity deploy -y --create --title "CodingCat Ops & Revenue OS"
echo "Creating and deploying new $APP_TITLE app in organization $ORG_ID..."
npx sanity deploy -y --create --title "$APP_TITLE"
fi
env:
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}
SANITY_APP_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
SANITY_APP_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}

- name: Promote Stack to Organization Scope
run: |
Expand Down
15 changes: 13 additions & 2 deletions apps/ops/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { defineCliConfig } from "sanity/cli";

const dataset =
process.env.SANITY_APP_DATASET ||
process.env.SANITY_STUDIO_DATASET ||
"production";
const isDev = dataset === "dev";

export default defineCliConfig({
app: {
organizationId: process.env.SANITY_ORGANIZATION_ID || "ovF2qiKSO",
entry: "./src/index.tsx",
title: "CodingCat Ops & Revenue OS",
title: isDev
? "CodingCat Ops & Revenue OS (Dev)"
: "CodingCat Ops & Revenue OS (Production)",
},
deployment: {
appId: process.env.SANITY_OPS_APP_ID || "yiugiba2sjnhpehqmky6nulc",
appId:
process.env.SANITY_OPS_APP_ID ||
(isDev ? "yiugiba2sjnhpehqmky6nulc" : undefined),
},
});




15 changes: 12 additions & 3 deletions apps/ops/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ const ACTIVE_GMAIL_DEALS: SeededGmailDraft[] = [
];

export function App() {
const projectId = process.env.SANITY_APP_PROJECT_ID || "hfh83o0w";
const dataset = process.env.SANITY_APP_DATASET || "production";
const isDev = dataset === "dev";
const envLabel = isDev ? "Dev" : "Production";
const siteOrigin = isDev ? "https://dev.codingcat.dev" : "https://codingcat.dev";

const [activeTab, setActiveTab] = useState<WorkspaceTab>("crm");
const [discovering, setDiscovering] = useState(false);
const [discoveredProspects, setDiscoveredProspects] = useState<Array<any>>([]);
Expand All @@ -109,7 +115,7 @@ export function App() {
const handleDiscoverOutbound = async () => {
setDiscovering(true);
try {
const res = await fetch("https://codingcat.dev/api/sponsors/outbound");
const res = await fetch(`${siteOrigin}/api/sponsors/outbound`);
if (res.ok) {
const data = await res.json();
setDiscoveredProspects(data.prospects || []);
Expand All @@ -125,9 +131,12 @@ export function App() {
<div style={{ padding: 24, fontFamily: "system-ui, sans-serif", maxWidth: 1200, margin: "0 auto" }}>
<header style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 24 }}>
<div>
<h1 style={{ margin: 0, fontSize: 28 }}>CodingCat.dev Revenue &amp; Booking OS</h1>
<h1 style={{ margin: 0, fontSize: 28 }}>
CodingCat.dev Revenue &amp; Booking OS ({envLabel})
</h1>
<p style={{ margin: "4px 0 0", color: "#666", fontSize: 14 }}>
Unified Sanity App SDK Workspace &middot; Project <code>hfh83o0w</code> (Production)
Unified Sanity App SDK Workspace &middot; Project <code>{projectId}</code> &middot; Dataset{" "}
<code>{dataset}</code> ({envLabel})
</p>
</div>
<div style={{ display: "flex", gap: 8 }}>
Expand Down
17 changes: 14 additions & 3 deletions apps/ops/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@ import { studioTheme, ThemeProvider } from "@sanity/ui";
import { StrictMode } from "react";
import { App } from "./App";

const projectId = process.env.SANITY_APP_PROJECT_ID || "hfh83o0w";
const dataset = process.env.SANITY_APP_DATASET || "production";

const config: SanityConfig[] = [
{
projectId: "hfh83o0w",
dataset: "production",
projectId,
dataset,
},
];

export default function RootApp() {
return (
<StrictMode>
<ThemeProvider theme={studioTheme}>
<SanityApp config={config} fallback={<div>Loading CodingCat.dev Ops...</div>}>
<SanityApp
config={config}
fallback={
<div>
Loading CodingCat.dev Ops ({dataset === "dev" ? "Dev" : "Production"})...
</div>
}
>
<App />
</SanityApp>
</ThemeProvider>
</StrictMode>
);
}


Loading