Skip to content

Commit ab8cc23

Browse files
committed
feat(sanity): dedicated studio dataset workspaces and deploy workflow environment passing
1 parent 011d01f commit ab8cc23

5 files changed

Lines changed: 54 additions & 31 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Deploy Sanity Studio
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [dev, main]
67
paths:
@@ -10,7 +11,7 @@ on:
1011

1112
jobs:
1213
deploy-dev:
13-
if: github.ref == 'refs/heads/dev'
14+
if: github.ref == 'refs/heads/dev' || github.event_name == 'workflow_dispatch'
1415
runs-on: ubuntu-latest
1516
environment: dev
1617

@@ -33,6 +34,8 @@ jobs:
3334
env:
3435
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
3536
SANITY_STUDIO_HOSTNAME: ${{ vars.SANITY_STUDIO_HOSTNAME }}
37+
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
38+
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}
3639

3740
deploy-production:
3841
if: github.ref == 'refs/heads/main'
@@ -58,3 +61,5 @@ jobs:
5861
env:
5962
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
6063
SANITY_STUDIO_HOSTNAME: ${{ vars.SANITY_STUDIO_HOSTNAME }}
64+
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
65+
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}

‎apps/sanity/sanity.config.ts‎

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -279,29 +279,38 @@ function buildPlugins(previewUrl: string): PluginOptions[] {
279279
}
280280

281281
// ── Workspace definitions ────────────────────────────────────────────
282-
export default defineConfig([
283-
{
284-
name: "production",
285-
title: "CodingCat.dev (Production)",
286-
projectId,
287-
dataset: "production",
288-
basePath: "/production",
289-
schema: { types: schemaTypes },
290-
document: { actions: documentActions },
291-
plugins: buildPlugins(
292-
isLocal ? localPreviewOrigin : "https://codingcat.dev",
293-
),
294-
},
295-
{
296-
name: "dev",
297-
title: "CodingCat.dev (Dev)",
298-
projectId,
299-
dataset: "dev",
300-
basePath: "/dev",
301-
schema: { types: schemaTypes },
302-
document: { actions: documentActions },
303-
plugins: buildPlugins(
304-
isLocal ? localPreviewOrigin : "https://dev.codingcat.dev",
305-
),
306-
},
307-
]);
282+
const targetDataset = process.env.SANITY_STUDIO_DATASET;
283+
284+
const devWorkspace = {
285+
name: "dev",
286+
title: "CodingCat.dev (Dev)",
287+
projectId,
288+
dataset: "dev",
289+
basePath: targetDataset === "dev" ? "/" : "/dev",
290+
schema: { types: schemaTypes },
291+
document: { actions: documentActions },
292+
plugins: buildPlugins(
293+
isLocal ? localPreviewOrigin : "https://dev.codingcat.dev",
294+
),
295+
};
296+
297+
const prodWorkspace = {
298+
name: "production",
299+
title: "CodingCat.dev (Production)",
300+
projectId,
301+
dataset: "production",
302+
basePath: targetDataset === "production" ? "/" : "/production",
303+
schema: { types: schemaTypes },
304+
document: { actions: documentActions },
305+
plugins: buildPlugins(
306+
isLocal ? localPreviewOrigin : "https://codingcat.dev",
307+
),
308+
};
309+
310+
export default defineConfig(
311+
targetDataset === "dev"
312+
? [devWorkspace]
313+
: targetDataset === "production"
314+
? [prodWorkspace]
315+
: [prodWorkspace, devWorkspace],
316+
);

‎apps/site/tests/font-bold-mock.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import { fileURLToPath } from "node:url";
44

55
const __dirname = path.dirname(fileURLToPath(import.meta.url));
66
const fontPath = path.resolve(__dirname, "../src/assets/fonts/Inter-Bold.ttf");
7-
const buf = fs.existsSync(fontPath) ? fs.readFileSync(fontPath) : Buffer.from([]);
7+
const buf = fs.existsSync(fontPath)
8+
? fs.readFileSync(fontPath)
9+
: Buffer.from([]);
810
export default new Uint8Array(buf);

‎apps/site/tests/font-reg-mock.mjs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import path from "node:path";
33
import { fileURLToPath } from "node:url";
44

55
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6-
const fontPath = path.resolve(__dirname, "../src/assets/fonts/Inter-Regular.ttf");
7-
const buf = fs.existsSync(fontPath) ? fs.readFileSync(fontPath) : Buffer.from([]);
6+
const fontPath = path.resolve(
7+
__dirname,
8+
"../src/assets/fonts/Inter-Regular.ttf",
9+
);
10+
const buf = fs.existsSync(fontPath)
11+
? fs.readFileSync(fontPath)
12+
: Buffer.from([]);
813
export default new Uint8Array(buf);

‎apps/site/tests/run-e2e.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ async function main() {
149149
for (const f of failureDetails) {
150150
console.error(`\n- Test: ${f.name}`);
151151
if (f.details?.error) {
152-
console.error(f.details.error.stack || f.details.error.message || f.details.error);
152+
console.error(
153+
f.details.error.stack || f.details.error.message || f.details.error,
154+
);
153155
}
154156
}
155157
process.exit(1);

0 commit comments

Comments
 (0)