From faf7f2f30f86174a38dce925023b5b27d73940a7 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 30 Oct 2026 06:07:09 -0500 Subject: [PATCH] feat(pm-dispatch): add thin pm-dispatch-ci-fix wrapper action (#2672) --- .github/actions/pm-dispatch-ci-fix/action.yml | 86 +++++++++++++++++++ pm-stack/dispatch/README.md | 40 ++++++++- 2 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 .github/actions/pm-dispatch-ci-fix/action.yml diff --git a/.github/actions/pm-dispatch-ci-fix/action.yml b/.github/actions/pm-dispatch-ci-fix/action.yml new file mode 100644 index 0000000000..4575a28628 --- /dev/null +++ b/.github/actions/pm-dispatch-ci-fix/action.yml @@ -0,0 +1,86 @@ +name: pm-dispatch-ci-fix +description: >- + Thin wrapper over pm-dispatch-task with `task: ci-fix`: it contains no + logic of its own and has exactly one step, which calls pm-dispatch-task. + All dedupe and routing behavior lives in pm-dispatch-task's ci-fix mode + (the dedupe search on the conventional tracking-issue title, and the + default-branch to starter / other-branch to queuer routing). Intended + use is a `ci-fix` job inside a repo's main CI workflow: the job needs + the main jobs and runs only `if: failure()`, and the caller provides + GH_TOKEN in the job environment plus `permissions: id-token: write` and + `issues: read`. The ci-fix context inputs below default from the + caller's own run context, so in that intended use the call site needs + no `with:` block at all. +inputs: + repo: + description: "Target repo (owner/name). Any allowlisted repo may target any allowlisted repo." + required: false + default: ${{ github.repository }} + workflow: + description: "ci-fix context: name of the failed workflow. Defaults to the calling workflow name." + required: false + default: ${{ github.workflow }} + run-id: + description: "ci-fix context: id of the failed workflow run. Defaults to the calling run id." + required: false + default: ${{ github.run_id }} + run-url: + description: "ci-fix context: URL of the failed workflow run. Defaults to the calling run URL." + required: false + default: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + branch: + description: "ci-fix context: head branch of the failed run. Defaults to the calling run head ref (pull request events) or ref name." + required: false + default: ${{ github.head_ref || github.ref_name }} + sha: + description: "ci-fix context: head SHA of the failed run. Defaults to the calling run SHA." + required: false + default: ${{ github.sha }} + pr: + description: "ci-fix context: optional number of the pull request associated with the failed run. Defaults to the calling event pull request number (empty on non-PR events)." + required: false + default: ${{ github.event.pull_request.number }} + title: + description: "Optional session / tracking-issue title, passed through to pm-dispatch-task. No default beyond that of pm-dispatch-task (for ci-fix the title is always the conventional `ci-fix: failing on `, so pm-dispatch-task ignores this input)." + required: false + model: + description: 'Optional model hint, "provider/model", passed through to pm-dispatch-task (which passes it through to the starter/queuer when non-empty). No default beyond that of pm-dispatch-task.' + required: false + priority: + description: "Optional priority: 10-90 or critical|high|normal|low, passed through to pm-dispatch-task. No default beyond that of pm-dispatch-task (for ci-fix, when empty it defaults there to high on the target repo default branch, otherwise normal)." + required: false + default-branch: + description: "Default branch of the target repo, passed through to pm-dispatch-task. No default beyond that of pm-dispatch-task (there it defaults to the caller repository default branch; ci-fix failures on this branch dispatch at high priority via pm-dispatch-start, failures on any other branch are queued via pm-dispatch-queue)." + required: false +outputs: + task_id: + description: "pm-dispatch queue task id from the pm-dispatch-task step." + value: ${{ steps.dispatch.outputs.task_id }} + session_id: + description: "OpenCode session id (only set when pm-dispatch-start ran inside pm-dispatch-task: a fresh ci-fix failure on the default branch)." + value: ${{ steps.dispatch.outputs.session_id }} + issue_number: + description: "Tracking issue number (attached, or created by the dispatch step inside pm-dispatch-task)." + value: ${{ steps.dispatch.outputs.issue_number }} + issue_url: + description: "Tracking issue URL." + value: ${{ steps.dispatch.outputs.issue_url }} +runs: + using: composite + steps: + - name: Dispatch ci-fix via pm-dispatch-task + id: dispatch + uses: developing-today/code/.github/actions/pm-dispatch-task@main + with: + task: ci-fix + repo: ${{ inputs.repo }} + title: ${{ inputs.title }} + model: ${{ inputs.model }} + priority: ${{ inputs.priority }} + workflow: ${{ inputs.workflow }} + run-id: ${{ inputs['run-id'] }} + run-url: ${{ inputs['run-url'] }} + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + pr: ${{ inputs.pr }} + default-branch: ${{ inputs['default-branch'] }} diff --git a/pm-stack/dispatch/README.md b/pm-stack/dispatch/README.md index 2c52be323d..3c69146a30 100644 --- a/pm-stack/dispatch/README.md +++ b/pm-stack/dispatch/README.md @@ -130,10 +130,11 @@ actor, workflow_ref}`) is recorded in the task payload. ## GitHub Actions (reusable) -Three composite actions in this repo wrap dispatch so call sites do +Four composite actions in this repo wrap dispatch so call sites do not hand-roll the OIDC + curl plumbing. Two are low-level primitives that wrap the dispatch endpoints directly; the third is the -task-level entry point built on top of them: +task-level entry point built on top of them, and the fourth is a +thin in-CI wrapper over that entry point: - `.github/actions/pm-dispatch-start` ("the starter") — POSTs to `/v1/sessions`; outputs `task_id`, `session_id`, `issue_number` @@ -147,6 +148,13 @@ task-level entry point built on top of them: prompt library bundled with the action. It contains no OIDC or HTTP plumbing of its own. Outputs `task_id`, `session_id`, `issue_number` and `issue_url`, whichever apply to the path taken. +- `.github/actions/pm-dispatch-ci-fix` ("the ci-fix wrapper") — a + thin wrapper over the task action with `task: ci-fix` (one step, + no logic of its own). Its ci-fix context inputs default from the + caller's own run context, so a `ci-fix` job inside a repo's main + CI workflow needs no `with:` block. Outputs `task_id`, + `session_id`, `issue_number` and `issue_url`, mapped from the + task action step. Usage, pinned to `@main` so fleet call sites pick up central updates: @@ -329,6 +337,34 @@ target repo; the dedupe search fails loudly without it. The step summary records the task, the path taken, and the dispatched task / session / issue ids. +#### pm-dispatch-ci-fix — the in-CI wrapper + +For a repo's own CI, `.github/actions/pm-dispatch-ci-fix` wraps the +call above in a single step with `task: ci-fix`. All of its context +inputs (`repo`, `workflow`, `run-id`, `run-url`, `branch`, `sha`, +`pr`) default from the calling run's own context, and all dedupe / +routing behavior stays in the task action's ci-fix mode — the +wrapper adds none. The intended shape is a `ci-fix` job inside the +repo's main CI workflow, gated on the main jobs failing and kept +from failing the workflow itself: + +```yaml +jobs: + ci-fix: + needs: [] + if: failure() + continue-on-error: true + runs-on: ubuntu-latest + permissions: + id-token: write + issues: read + contents: read + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: developing-today/code/.github/actions/pm-dispatch-ci-fix@main +``` + #### Design note Every call carries `repo` and `task` explicitly, and the prompt