Skip to content

Commit 752851b

Browse files
committed
feat: add live update toggle (default off), change default env to production
1 parent 1e8c733 commit 752851b

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/fetch-models.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ on:
99
description: 'Target environment'
1010
type: choice
1111
options:
12-
- test
1312
- production
14-
default: 'test'
13+
- test
14+
default: 'production'
1515
dry_run:
1616
description: 'Dry run (show changes without pushing to Webflow)'
1717
type: boolean
1818
default: false
19+
live_update:
20+
description: 'Publish changes immediately (skip draft/staging)'
21+
type: boolean
22+
default: false
1923

2024
jobs:
2125
sync:
@@ -36,3 +40,4 @@ jobs:
3640
WEBFLOW_API_TOKEN: ${{ inputs.environment == 'test' && secrets.TEST_WEBFLOW_API_TOKEN || secrets.PROD_WEBFLOW_API_TOKEN }}
3741
WEBFLOW_SITE_ID: ${{ inputs.environment == 'test' && vars.TEST_WEBFLOW_SITE_ID || vars.PROD_WEBFLOW_SITE_ID }}
3842
DRY_RUN: ${{ inputs.dry_run || 'false' }}
43+
LIVE_UPDATE: ${{ inputs.live_update || 'false' }}

scripts/fetch-models.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const isMain = process.argv[1] === __filename;
77
// -- Configuration --
88

99
const { MODULAR_CLOUD_API_TOKEN, MODULAR_CLOUD_ORG, MODULAR_CLOUD_BASE_URL } = process.env;
10-
const { WEBFLOW_API_TOKEN, WEBFLOW_SITE_ID, DRY_RUN } = process.env;
10+
const { WEBFLOW_API_TOKEN, WEBFLOW_SITE_ID, DRY_RUN, LIVE_UPDATE } = process.env;
1111
const dryRun = DRY_RUN === 'true';
12+
const liveUpdate = LIVE_UPDATE === 'true';
1213

1314
let wf;
1415
if (isMain) {
@@ -22,7 +23,7 @@ if (isMain) {
2223
console.error('Missing required env vars: WEBFLOW_API_TOKEN, WEBFLOW_SITE_ID');
2324
process.exit(1);
2425
}
25-
wf = createClient(WEBFLOW_API_TOKEN);
26+
wf = createClient(WEBFLOW_API_TOKEN, { liveUpdate });
2627
}
2728

2829
const modularHeaders = {

scripts/webflow-api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function chunk(array, size) {
88
return chunks;
99
}
1010

11-
function createClient(apiToken) {
11+
function createClient(apiToken, { liveUpdate = false } = {}) {
1212
async function webflowFetch(path, options = {}) {
1313
const url = `https://api.webflow.com/v2${path}`;
1414
const method = options.method || 'GET';
@@ -42,6 +42,7 @@ function createClient(apiToken) {
4242
const liveSupported = new Map();
4343

4444
async function supportsLive(collectionId) {
45+
if (!liveUpdate) return false;
4546
if (liveSupported.has(collectionId)) return liveSupported.get(collectionId);
4647

4748
try {

0 commit comments

Comments
 (0)