microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
eng/common/scripts/dispatch-area-triggers.ts
33lines · modecode
| 1 | import { parseArgs } from "util"; |
| 2 | import { setOutputVariable } from "./utils/ado.js"; |
| 3 | import { repoRoot } from "./utils/common.js"; |
| 4 | import { findAreasChanged } from "./utils/find-area-changed.js"; |
| 5 | import { listChangedFilesSince } from "./utils/git.js"; |
| 6 | |
| 7 | const args = parseArgs({ |
| 8 | args: process.argv.slice(2), |
| 9 | options: { |
| 10 | "target-branch": { type: "string" }, |
| 11 | }, |
| 12 | }); |
| 13 | |
| 14 | const targetBranch = args.values["target-branch"]; |
| 15 | if (!targetBranch) { |
| 16 | console.error("--target-branch is required"); |
| 17 | process.exit(1); |
| 18 | } |
| 19 | |
| 20 | console.log("Checking for changes in current branch compared to $TargetBranch"); |
| 21 | |
| 22 | const files = await listChangedFilesSince(`origin/${targetBranch}`, { repositoryPath: repoRoot }); |
| 23 | |
| 24 | console.log("##[group]Files changed in this pr"); |
| 25 | console.log(files.map((x) => ` - ${x}`).join("\n")); |
| 26 | console.log("##[endgroup]"); |
| 27 | |
| 28 | const areaChanged = findAreasChanged(files); |
| 29 | |
| 30 | for (const area of areaChanged) { |
| 31 | console.log(`Setting output variable Run${area} to true`); |
| 32 | setOutputVariable(`Run${area}`, "true"); |
| 33 | } |