Skip to content

Commit 6a6bd77

Browse files
committed
Add initial sync_back.ts script
1 parent f0f92a1 commit 6a6bd77

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

pr-checks/sync_back.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env npx tsx
2+
3+
/*
4+
Sync-back script to automatically update action versions in source templates
5+
from the generated workflow files after Dependabot updates.
6+
7+
This script scans the generated workflow files (.github/workflows/__*.yml) to find
8+
all external action versions used, then updates:
9+
1. Hardcoded action versions in pr-checks/sync.ts
10+
2. Action version references in template files in pr-checks/checks/
11+
12+
The script automatically detects all actions used in generated workflows and
13+
preserves version comments (e.g., # v1.2.3) when syncing versions.
14+
15+
This ensures that when Dependabot updates action versions in generated workflows,
16+
those changes are properly synced back to the source templates. Regular workflow
17+
files are updated directly by Dependabot and don't need sync-back.
18+
*/
19+
20+
import { parseArgs } from "node:util";
21+
22+
import * as path from "path";
23+
24+
const THIS_DIR = __dirname;
25+
const CHECKS_DIR = path.join(THIS_DIR, "checks");
26+
const WORKFLOW_DIR = path.join(THIS_DIR, "..", ".github", "workflows");
27+
const SYNC_TS_PATH = path.join(THIS_DIR, "sync.ts");
28+
29+
function main(): number {
30+
const { values } = parseArgs({
31+
options: {
32+
verbose: {
33+
type: "boolean",
34+
short: "v",
35+
default: false,
36+
},
37+
},
38+
strict: true,
39+
});
40+
41+
const verbose = values.verbose ?? false;
42+
43+
console.log(verbose);
44+
45+
return 0;
46+
}
47+
48+
process.exit(main());

0 commit comments

Comments
 (0)