Skip to content

Commit a1412b4

Browse files
committed
chore(sanity,ci): retain legacy content fields as hidden/readOnly and add pre-deploy production dataset backup
1 parent 04a1fd6 commit a1412b4

4 files changed

Lines changed: 316 additions & 0 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ jobs:
2929
- name: Install dependencies
3030
run: pnpm install --frozen-lockfile
3131

32+
- name: Export Sanity production dataset backup before deploy
33+
run: |
34+
curl -f -sS "https://hfh83o0w.api.sanity.io/v2021-06-07/data/export/production" | gzip > /tmp/sanity-production-backup.ndjson.gz
35+
36+
- name: Upload Sanity production dataset backup artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: sanity-production-predeploy-backup-dev-${{ github.sha }}
40+
path: /tmp/sanity-production-backup.ndjson.gz
41+
retention-days: 30
42+
3243
- name: Deploy Sanity Studio
3344
run: npx sanity deploy -y
3445
working-directory: apps/sanity
@@ -90,6 +101,19 @@ jobs:
90101
- name: Install dependencies
91102
run: pnpm install --frozen-lockfile
92103

104+
- name: Export Sanity production dataset backup before deploy
105+
run: |
106+
curl -f -sS "https://hfh83o0w.api.sanity.io/v2021-06-07/data/export/production" | gzip > /tmp/sanity-production-backup.ndjson.gz
107+
env:
108+
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
109+
110+
- name: Upload Sanity production dataset backup artifact
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: sanity-production-predeploy-backup-${{ github.sha }}
114+
path: /tmp/sanity-production-backup.ndjson.gz
115+
retention-days: 30
116+
93117
- name: Deploy Sanity Studio
94118
run: npx sanity deploy -y
95119
working-directory: apps/sanity

‎.github/workflows/nightly-dataset-sync.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@ jobs:
4545
pnpm --filter @codingcatdev/sanity exec sanity dataset import /tmp/production.tar.gz dev --replace
4646
4747
echo "Dataset sync completed successfully!"
48+
49+
- name: Upload Sanity production dataset backup artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: sanity-production-backup-${{ github.run_id }}
53+
path: /tmp/production.tar.gz
54+
retention-days: 30

‎apps/sanity/extract.json‎

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,6 +3531,85 @@
35313531
"name": "statistics"
35323532
},
35333533
"optional": true
3534+
},
3535+
"tags": {
3536+
"type": "objectAttribute",
3537+
"value": {
3538+
"type": "array",
3539+
"of": {
3540+
"type": "object",
3541+
"attributes": {
3542+
"label": {
3543+
"type": "objectAttribute",
3544+
"value": {
3545+
"type": "string"
3546+
},
3547+
"optional": true
3548+
},
3549+
"value": {
3550+
"type": "objectAttribute",
3551+
"value": {
3552+
"type": "string"
3553+
},
3554+
"optional": true
3555+
},
3556+
"_type": {
3557+
"type": "objectAttribute",
3558+
"value": {
3559+
"type": "string",
3560+
"value": "tag"
3561+
}
3562+
}
3563+
},
3564+
"rest": {
3565+
"type": "object",
3566+
"attributes": {
3567+
"_key": {
3568+
"type": "objectAttribute",
3569+
"value": {
3570+
"type": "string"
3571+
}
3572+
}
3573+
}
3574+
}
3575+
}
3576+
},
3577+
"optional": true
3578+
},
3579+
"views": {
3580+
"type": "objectAttribute",
3581+
"value": {
3582+
"type": "number"
3583+
},
3584+
"optional": true
3585+
},
3586+
"ogTitle": {
3587+
"type": "objectAttribute",
3588+
"value": {
3589+
"type": "string"
3590+
},
3591+
"optional": true
3592+
},
3593+
"ogDescription": {
3594+
"type": "objectAttribute",
3595+
"value": {
3596+
"type": "string"
3597+
},
3598+
"optional": true
3599+
},
3600+
"twitterCardType": {
3601+
"type": "objectAttribute",
3602+
"value": {
3603+
"type": "string"
3604+
},
3605+
"optional": true
3606+
},
3607+
"noIndex": {
3608+
"type": "objectAttribute",
3609+
"value": {
3610+
"type": "boolean"
3611+
},
3612+
"optional": true
35343613
}
35353614
}
35363615
},
@@ -4556,6 +4635,85 @@
45564635
},
45574636
"optional": true
45584637
},
4638+
"tags": {
4639+
"type": "objectAttribute",
4640+
"value": {
4641+
"type": "array",
4642+
"of": {
4643+
"type": "object",
4644+
"attributes": {
4645+
"label": {
4646+
"type": "objectAttribute",
4647+
"value": {
4648+
"type": "string"
4649+
},
4650+
"optional": true
4651+
},
4652+
"value": {
4653+
"type": "objectAttribute",
4654+
"value": {
4655+
"type": "string"
4656+
},
4657+
"optional": true
4658+
},
4659+
"_type": {
4660+
"type": "objectAttribute",
4661+
"value": {
4662+
"type": "string",
4663+
"value": "tag"
4664+
}
4665+
}
4666+
},
4667+
"rest": {
4668+
"type": "object",
4669+
"attributes": {
4670+
"_key": {
4671+
"type": "objectAttribute",
4672+
"value": {
4673+
"type": "string"
4674+
}
4675+
}
4676+
}
4677+
}
4678+
}
4679+
},
4680+
"optional": true
4681+
},
4682+
"views": {
4683+
"type": "objectAttribute",
4684+
"value": {
4685+
"type": "number"
4686+
},
4687+
"optional": true
4688+
},
4689+
"ogTitle": {
4690+
"type": "objectAttribute",
4691+
"value": {
4692+
"type": "string"
4693+
},
4694+
"optional": true
4695+
},
4696+
"ogDescription": {
4697+
"type": "objectAttribute",
4698+
"value": {
4699+
"type": "string"
4700+
},
4701+
"optional": true
4702+
},
4703+
"twitterCardType": {
4704+
"type": "objectAttribute",
4705+
"value": {
4706+
"type": "string"
4707+
},
4708+
"optional": true
4709+
},
4710+
"noIndex": {
4711+
"type": "objectAttribute",
4712+
"value": {
4713+
"type": "boolean"
4714+
},
4715+
"optional": true
4716+
},
45594717
"podcastType": {
45604718
"type": "objectAttribute",
45614719
"value": {
@@ -7567,6 +7725,85 @@
75677725
"name": "statistics"
75687726
},
75697727
"optional": true
7728+
},
7729+
"tags": {
7730+
"type": "objectAttribute",
7731+
"value": {
7732+
"type": "array",
7733+
"of": {
7734+
"type": "object",
7735+
"attributes": {
7736+
"label": {
7737+
"type": "objectAttribute",
7738+
"value": {
7739+
"type": "string"
7740+
},
7741+
"optional": true
7742+
},
7743+
"value": {
7744+
"type": "objectAttribute",
7745+
"value": {
7746+
"type": "string"
7747+
},
7748+
"optional": true
7749+
},
7750+
"_type": {
7751+
"type": "objectAttribute",
7752+
"value": {
7753+
"type": "string",
7754+
"value": "tag"
7755+
}
7756+
}
7757+
},
7758+
"rest": {
7759+
"type": "object",
7760+
"attributes": {
7761+
"_key": {
7762+
"type": "objectAttribute",
7763+
"value": {
7764+
"type": "string"
7765+
}
7766+
}
7767+
}
7768+
}
7769+
}
7770+
},
7771+
"optional": true
7772+
},
7773+
"views": {
7774+
"type": "objectAttribute",
7775+
"value": {
7776+
"type": "number"
7777+
},
7778+
"optional": true
7779+
},
7780+
"ogTitle": {
7781+
"type": "objectAttribute",
7782+
"value": {
7783+
"type": "string"
7784+
},
7785+
"optional": true
7786+
},
7787+
"ogDescription": {
7788+
"type": "objectAttribute",
7789+
"value": {
7790+
"type": "string"
7791+
},
7792+
"optional": true
7793+
},
7794+
"twitterCardType": {
7795+
"type": "objectAttribute",
7796+
"value": {
7797+
"type": "string"
7798+
},
7799+
"optional": true
7800+
},
7801+
"noIndex": {
7802+
"type": "objectAttribute",
7803+
"value": {
7804+
"type": "boolean"
7805+
},
7806+
"optional": true
75707807
}
75717808
}
75727809
},

‎apps/sanity/schemas/partials/content.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,54 @@ const content = defineType({
119119
}),
120120
],
121121
}),
122+
// Legacy fields retained as hidden/readOnly so existing production documents
123+
// do not trigger "Unknown fields found" warnings in Sanity Studio.
124+
defineField({
125+
name: "tags",
126+
type: "array",
127+
of: [
128+
{
129+
type: "object",
130+
name: "tag",
131+
fields: [
132+
defineField({ name: "label", type: "string" }),
133+
defineField({ name: "value", type: "string" }),
134+
],
135+
},
136+
],
137+
hidden: true,
138+
readOnly: true,
139+
}),
140+
defineField({
141+
name: "views",
142+
type: "number",
143+
hidden: true,
144+
readOnly: true,
145+
}),
146+
defineField({
147+
name: "ogTitle",
148+
type: "string",
149+
hidden: true,
150+
readOnly: true,
151+
}),
152+
defineField({
153+
name: "ogDescription",
154+
type: "text",
155+
hidden: true,
156+
readOnly: true,
157+
}),
158+
defineField({
159+
name: "twitterCardType",
160+
type: "string",
161+
hidden: true,
162+
readOnly: true,
163+
}),
164+
defineField({
165+
name: "noIndex",
166+
type: "boolean",
167+
hidden: true,
168+
readOnly: true,
169+
}),
122170
],
123171
});
124172

0 commit comments

Comments
 (0)