From 7e470080b6e602c1a12a6322c4aea29d6b5b5120 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 23 Mar 2026 10:37:57 +0100 Subject: [PATCH] Update script timestamp handling and dev promotion Compute today's date once and use a consolidated patchBody for PATCH requests (including last_update_commit from PR_URL/COMMIT_URL). Add logic to promote dev scripts on merge: if record.is_dev === true, set is_dev to false and script_created to today, and log the promotion. Replace the previous duplicated date construction with the new patchBody. --- .../update-script-timestamp-on-sh-change.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-script-timestamp-on-sh-change.yml b/.github/workflows/update-script-timestamp-on-sh-change.yml index a7d10d6d6..916df6a58 100644 --- a/.github/workflows/update-script-timestamp-on-sh-change.yml +++ b/.github/workflows/update-script-timestamp-on-sh-change.yml @@ -155,13 +155,21 @@ jobs: console.log('Slug not in DB, skipping: ' + slug); continue; } + const today = new Date().toISOString().split('T')[0]; + const patchBody = { + script_updated: today, + last_update_commit: process.env.PR_URL || process.env.COMMIT_URL || '' + }; + // When a dev script is merged into main, promote it to production + if (record.is_dev === true) { + patchBody.is_dev = false; + patchBody.script_created = today; + console.log('Promoting dev script to production: ' + slug); + } const patchRes = await request(recordsUrl + '/' + record.id, { method: 'PATCH', headers: { 'Authorization': token, 'Content-Type': 'application/json' }, - body: JSON.stringify({ - script_updated: new Date().toISOString().split('T')[0], - last_update_commit: process.env.PR_URL || process.env.COMMIT_URL || '' - }) + body: JSON.stringify(patchBody) }); if (!patchRes.ok) { console.warn('PATCH failed for slug ' + slug + ': ' + patchRes.body);