

























@@ -264,74 +264,17 @@ export function parseWorkflowRunIdFromOutput(output: string): string | undefined
264264return /\/actions\/runs\/(\d+)/u.exec(output)?.[1];
265265}
266266267-type WorkflowRunListEntry = {
268-createdAt?: string;
269-created_at?: string;
270-databaseId?: number | string;
271-id?: number | string;
272-};
273-274-function normalizeRunId(value: unknown): string | undefined {
275-if (typeof value === "number" && Number.isFinite(value)) {
276-return String(value);
277-}
278-if (typeof value === "string" && value.trim()) {
279-return value.trim();
280-}
281-return undefined;
282-}
283-284-export function selectNewestDispatchedRunId(params: {
285-beforeIds: ReadonlySet<string>;
286-runs: readonly WorkflowRunListEntry[];
287-}): string | undefined {
288-return params.runs
289-.filter((entry) => {
290-const id = normalizeRunId(entry.databaseId ?? entry.id);
291-return id !== undefined && !params.beforeIds.has(id);
292-})
293-.toSorted((a, b) =>
294-(b.createdAt ?? b.created_at ?? "").localeCompare(a.createdAt ?? a.created_at ?? ""),
295-)
296-.map((entry) => normalizeRunId(entry.databaseId ?? entry.id))
297-.find((id): id is string => id !== undefined);
298-}
299-300-function listWorkflowDispatchRuns(repo: string, workflow: string): WorkflowRunListEntry[] {
301-const encodedWorkflow = encodeURIComponent(workflow);
302-const response = ghJson(
303-repo,
304-`actions/workflows/${encodedWorkflow}/runs?event=workflow_dispatch&per_page=50`,
305-) as { workflow_runs?: WorkflowRunListEntry[] };
306-return response.workflow_runs ?? [];
307-}
308-309-async function findDispatchedWorkflowRunId(params: {
310-beforeIds: ReadonlySet<string>;
311-repo: string;
312-workflow: string;
313-}): Promise<string> {
314-for (let attempt = 0; attempt < 60; attempt++) {
315-const runId = selectNewestDispatchedRunId({
316-beforeIds: params.beforeIds,
317-runs: listWorkflowDispatchRuns(params.repo, params.workflow),
318-});
319-if (runId) {
320-return runId;
321-}
322-await new Promise((resolve) => {
323-setTimeout(resolve, 5_000);
324-});
267+export function requireWorkflowRunIdFromOutput(output: string, workflow: string): string {
268+const runId = parseWorkflowRunIdFromOutput(output);
269+if (!runId) {
270+throw new Error(
271+`gh workflow run ${workflow} did not return an Actions run URL; refusing to guess from recent workflow_dispatch runs`,
272+);
325273}
326-throw new Error(`could not find dispatched run for ${params.workflow}`);
274+return runId;
327275}
328276329277async function dispatchTelegram(options: Options, packageSpec: string): Promise<string> {
330-const beforeIds = new Set(
331-listWorkflowDispatchRuns(options.repo, TELEGRAM_BETA_WORKFLOW_FILE)
332-.map((entry) => normalizeRunId(entry.databaseId ?? entry.id))
333-.filter((id): id is string => id !== undefined),
334-);
335278const output = run(
336279"gh",
337280[
@@ -351,15 +294,7 @@ async function dispatchTelegram(options: Options, packageSpec: string): Promise<
351294],
352295{ capture: true },
353296);
354-const runId = parseWorkflowRunIdFromOutput(output);
355-if (runId) {
356-return runId;
357-}
358-return await findDispatchedWorkflowRunId({
359- beforeIds,
360-repo: options.repo,
361-workflow: TELEGRAM_BETA_WORKFLOW_FILE,
362-});
297+return requireWorkflowRunIdFromOutput(output, TELEGRAM_BETA_WORKFLOW_FILE);
363298}
364299365300export async function pollRun(
@@ -508,7 +443,7 @@ async function main(): Promise<void> {
508443}
509444510445if (!options.skipParallels) {
511-runParallels(options.beta, options.model);
446+runParallels(version, options.model);
512447}
513448514449if (telegramRunId) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。