diff --git a/pr-checks/sync_back.ts b/pr-checks/sync_back.ts new file mode 100755 index 000000000..e42934f7a --- /dev/null +++ b/pr-checks/sync_back.ts @@ -0,0 +1,48 @@ +#!/usr/bin/env npx tsx + +/* +Sync-back script to automatically update action versions in source templates +from the generated workflow files after Dependabot updates. + +This script scans the generated workflow files (.github/workflows/__*.yml) to find +all external action versions used, then updates: +1. Hardcoded action versions in pr-checks/sync.ts +2. Action version references in template files in pr-checks/checks/ + +The script automatically detects all actions used in generated workflows and +preserves version comments (e.g., # v1.2.3) when syncing versions. + +This ensures that when Dependabot updates action versions in generated workflows, +those changes are properly synced back to the source templates. Regular workflow +files are updated directly by Dependabot and don't need sync-back. +*/ + +import { parseArgs } from "node:util"; + +import * as path from "path"; + +const THIS_DIR = __dirname; +const CHECKS_DIR = path.join(THIS_DIR, "checks"); +const WORKFLOW_DIR = path.join(THIS_DIR, "..", ".github", "workflows"); +const SYNC_TS_PATH = path.join(THIS_DIR, "sync.ts"); + +function main(): number { + const { values } = parseArgs({ + options: { + verbose: { + type: "boolean", + short: "v", + default: false, + }, + }, + strict: true, + }); + + const verbose = values.verbose ?? false; + + console.log(verbose); + + return 0; +} + +process.exit(main());