From e2e29a19fc80305c758d3f6fc79ab68bee27f48e Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 7 May 2026 18:04:07 +0000 Subject: [PATCH] accept pullfrog.yaml as well as pullfrog.yml (#596) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * accept pullfrog.yaml as well as pullfrog.yml centralize the accepted workflow filenames in `utils/github/pullfrogWorkflow.ts` (`PULLFROG_WORKFLOW_FILES = ["pullfrog.yml", "pullfrog.yaml"]`) and use the new `findExistingWorkflowFile` helper at every read path: `getWorkflow` (cached), the verify-workflow API route, and the audit/sync/download/update scripts. `.yml` is always tried first so the common case still costs exactly one API call. webhook handlers (push cache-bust, `workflow_run_*`) now use the shared `isPullfrogWorkflowPath` matcher. action runtime (`reviewCleanup.ts`) derives the running workflow's filename from `process.env.GITHUB_WORKFLOW_REF` instead of hardcoding `.yml`, so the safety-net follow-up dispatch targets whichever file the user actually has — strictly more correct than today. write paths (`createWorkflowForRepo`, `createWorkflowPR`) intentionally still create `.yml`; existing 422 collision handling covers the rare double-install case. UI/wiki/onboarding copy keeps saying `pullfrog.yml`; one callout in `docs/getting-started.mdx` mentions `.yaml` works too. also drops dead code (`utils/github/findWorkflow.ts`, parallel single-file implementation with no importers) and the now-unused `WORKFLOW_FILENAME` export. * rename pullfrogWorkflow.ts -> findPullfrogWorkflow.ts (verb form) * add pre-flight check to workflow create paths `createWorkflowForRepo` and `createWorkflowPR` now check for any existing pullfrog workflow file (`.yml` or `.yaml`) before doing work, preventing the degenerate state where a repo with `pullfrog.yaml` ends up with both files dispatching on every event. costs one `getContent` call per first-time install. existing 422 branch in `createWorkflowForRepo` is retained as a race-condition safety net; the 409 branch now also handles the case where `createWorkflowPR` discovers an existing file in flight. `createWorkflowPR` return shape becomes a discriminated union; the standalone `/api/create-workflow-pr` route returns `{ alreadyInstalled: true }` instead of creating a redundant PR. * promote repo to active when /api/create-workflow-pr finds existing workflow extracts `promoteRepoToActive` from `createWorkflowForRepo`'s closure to a shared module-level function, and wires it into the standalone PR route's `alreadyInstalled` branch so a `needs_setup` repo with an existing `.yaml` file doesn't go stale (was only handled by the dashboard's own create path). addresses pullfrog review on #596. --- utils/reviewCleanup.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/reviewCleanup.ts b/utils/reviewCleanup.ts index 2aa6339..4f33dca 100644 --- a/utils/reviewCleanup.ts +++ b/utils/reviewCleanup.ts @@ -88,8 +88,19 @@ async function dispatchFollowUpReReview(ctx: ToolContext, reviewedSha: string): await ctx.octokit.rest.actions.createWorkflowDispatch({ owner: ctx.repo.owner, repo: ctx.repo.name, - workflow_id: "pullfrog.yml", + workflow_id: getCurrentWorkflowFilename(), ref: pr.data.base.repo.default_branch, inputs: { prompt: JSON.stringify(payload) }, }); } + +/** + * derive the running workflow's filename from `GITHUB_WORKFLOW_REF`, which has the form + * `//.github/workflows/@` (e.g. `.../pullfrog.yaml@refs/heads/main`). + * falls back to `pullfrog.yml` if the env var is missing or malformed (shouldn't happen in CI). + */ +function getCurrentWorkflowFilename(): string { + const ref = process.env.GITHUB_WORKFLOW_REF ?? ""; + const match = ref.match(/\/([^/]+)@/); + return match?.[1] ?? "pullfrog.yml"; +}