# Fix a Failing check-dist Job in a TypeScript GitHub Action

Yes. An agent reads the failed check-dist run, rebuilds dist/ with the repository's own bundle script, finds why it drifted and pushes the regenerated bundle.

[Run this on Rush](https://cloud.getrush.ai/run/fix-failing-ci/github-actions/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

A JavaScript action runs from a committed bundle, so its CI has a job whose only purpose is to catch a bundle that no longer matches the source. In an action built from actions/typescript-action, `action.yml` declares `runs.using: node24` and `main: dist/index.js`, and `.github/workflows/check-dist.yml` runs on every pull request and push to `main`: it checks out, sets up Node from `.node-version` (24.4.0) with the npm cache, removes `dist/` with `rimraf`, runs `npm ci` and `npm run bundle`, then fails if `git diff --ignore-space-at-eol --text dist/ | wc -l` is above zero, printing the diff and uploading the expected `dist/` as an artifact named `dist`. The agent reads the failed run with `gh run view <id> --log-failed`, downloads that artifact, and reads the diff the job printed, because the shape of the diff is the diagnosis.

Then it reads how the bundle is made. `package.json` is an ES module with `engines.node >=24`, one runtime dependency, `@actions/core` ^3.0.0, and a `bundle` script that runs `format:write` and then `package`, which is `rimraf ./dist` followed by `rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript`. `rollup.config.ts` takes `src/index.ts`, emits `dist/index.js` in `es` format with `sourcemap: true`, and resolves node modules and CommonJS. `src/index.ts` imports `run` from `main.js`, `main.ts` reads the `milliseconds` input, calls `wait` and sets the `time` output, and `wait.ts` throws on a non-number. `dist/` holds `index.js` and `index.js.map`, and `.github/copilot-instructions.md` says plainly that `dist` is generated, should closely mirror `src`, and is not to be reviewed by hand. `dependabot.yml` updates npm dependencies weekly in two groups, and the `linter.yml` super-linter excludes `dist/**`.

The diff tells the agent which of three things happened. If the diff touches the functions that correspond to `src/main.ts` or `src/wait.ts`, someone changed source without running `npm run bundle`, and the fix is to run it and commit the result on the same branch. If the diff is spread through vendored code, a dependency changed: a Dependabot bump of `@actions/core`, which is bundled into `dist/index.js`, or of `rollup`, `@rollup/plugin-typescript` or `typescript`, which change how the bundle is emitted; the fix is the same regeneration, but the pull request says which package moved the output, and the agent reads the package's release notes to be sure the behaviour change is wanted. If the diff is only in `index.js.map` or in a banner line, the cause is a toolchain difference: a developer bundling on a Node other than `.node-version`, or a `format:write` step that reformatted a file the developer did not commit; the fix is to regenerate on the pinned Node and, where `prettier` changed source files, commit those too so `format:check` in `ci.yml` passes.

Before pushing, the agent runs what `ci.yml` runs: `npm run format:check`, `npm run lint` and `npm run ci-test`, which runs Jest with `--experimental-vm-modules` against `__tests__/main.test.ts` and `wait.test.ts` and their fixtures under `__fixtures__/`. It also runs `npm run bundle` a second time and confirms `git status` is clean, which is the same assertion `check-dist.yml` makes. It commits `dist/index.js`, `dist/index.js.map` and any file `format:write` changed with a message that names the cause, and pushes to the pull request's branch when the pull request is from the repository itself; for a run on `main` it opens a new pull request instead.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "The Check Transpiled JavaScript workflow failed on this repository; the failed workflow run follows this prompt. Read .github/workflows/check-dist.yml, .github/workflows/ci.yml, package.json, rollup.config.ts, action.yml, .node-version and .github/copilot-instructions.md first. Read the failed run with gh run view <run id> --log-failed and download its dist artifact. Classify the diff the job printed: source changed without rebundling, a dependency bump that changed the bundled output, or a toolchain difference such as a different Node version or a prettier reformat that was not committed. Check out the branch the run was for, use the Node version from .node-version, run npm ci and npm run bundle, and confirm the regenerated dist matches the artifact. If a dependency moved the output, name the package and read its release notes before accepting the change. Run npm run format:check, npm run lint and npm run ci-test, then run npm run bundle again and confirm git status is clean. Commit dist/index.js, dist/index.js.map and any source file that format:write changed, with a message naming the cause. Push to the pull request's branch if it belongs to this repository; otherwise open a new pull request against main. In the pull request or commit description quote the failing diff summary, state the cause in one paragraph and paste the commands you ran with their output. Do not edit any workflow file.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a commit on the failing pull request's branch, or a new pull request when the run was on `main`, that regenerates `dist/index.js` and `dist/index.js.map` and, when `format:write` changed anything, the source files it touched. The description names the cause in one paragraph: a source change that was never bundled, a named dependency whose bump moved the output, or a toolchain mismatch, and quotes the `npm run bundle`, `format:check`, `lint` and `ci-test` commands with their output.

`check-dist.yml` reruns on the push and compares `dist/` again; `ci.yml` runs the TypeScript tests and the `test-action` job that invokes the action from `./` with `milliseconds: 2000` and prints its `time` output, which is the end-to-end proof the bundle runs on the `node24` runtime. CodeQL and the linter run as before, the linter still excluding `dist/**`.

A reviewer does not read the bundle, as `copilot-instructions.md` says, but reads the cause: for a dependency bump, that the named package's change is one the action should take; for a stale bundle, that the source change it now reflects is the one the pull request intended. When the agent could not make the regenerated bundle match the artifact, it says so with the remaining diff rather than committing it.

## Run it on every failed check-dist run

Add an automation to the Project that holds the action with this prompt and a `github` trigger on `workflow_run.failure`. The trigger appends the run event after the prompt, so the agent reads the run id and the branch from it; a run from a fork never fires. Dependabot's weekly groups in `dependabot.yml` bump the packages that shape the bundle, but Dependabot is a bot sender and bot senders never fire a trigger, so a failed `check-dist` on its pull requests needs Run now or the server handler below. The automation's `max_runs_per_hour` caps how many failures it picks up when several land at once.

From your own server, a handler for GitHub's `workflow_run` webhook with `conclusion: failure` and the workflow name sends `POST /o/{org}/sessions` with this prompt and the run id in `input`, the repository in `resources`, and a `request_id` that is a UUID v5 of the run id. A `webhook_url` on the key receives `run.completed` with `data.session_url` to read the result from.

## Why run it on Rush?

A `check-dist` failure is cheap to fix and tedious to diagnose: the diff is hundreds of lines of bundled JavaScript, and the question is whether it is your change, a dependency's, or your laptop's Node. In a Rush sandbox the agent bundles on exactly the Node `.node-version` pins, with a fresh `npm ci`, and the transcript shows the regenerated bundle matching the artifact the job uploaded, so the commit is a fact and not a hope.

An action with Dependabot groups gets these failures weekly. One automation turns each into a commit with its cause named, and the reviewer reads one paragraph and one `test-action` job result instead of a bundle diff.

## Frequently asked questions

### Why not add dist/ to .gitignore and build it in the workflow?

Because `action.yml` runs `dist/index.js` straight from the repository at the ref a workflow pins, with no build step; that is how JavaScript actions work. `check-dist.yml` exists to keep that committed bundle honest, and the fix is to regenerate it, not to stop committing it.

### Will it push to a Dependabot pull request?

The branch belongs to the repository, so the agent can push the regenerated bundle to it, and says in the commit which bumped package changed the output. Dependabot treats a branch with extra commits as yours from then on, so the pull request's description notes that too.

### What if the diff is only the source map?

That points at the toolchain rather than the code: a different Node or rollup version emits different mapping. The agent regenerates on the Node from `.node-version` with the locked `package-lock.json` and checks whether the map now matches the artifact before committing anything.

### Does it change the workflows to make the check pass?

No. The prompt forbids editing workflow files, and `check-dist.yml` is doing its job. A failing check is information about the bundle, and the fix lands in `dist/` and, when needed, in the source files that `format:write` touched.

## More GitHub Actions jobs

- [Fix "Node.js 20 actions are deprecated" Annotations in GitHub Actions Workflows](https://getrush.ai/run/fix-node-js-20-actions-are-deprecated/github-actions/)
- [Fix "The set-output command is deprecated" in GitHub Actions Workflows](https://getrush.ai/run/fix-set-output-deprecation/github-actions/)
- [Fix "deprecated version of actions/upload-artifact: v3" Workflow Failures](https://getrush.ai/run/fix-upload-artifact-v3-deprecation/github-actions/)

## The same job on other stacks

- [Fix Failing GitHub Actions Checks in a Go Service](https://getrush.ai/run/fix-failing-ci/go/)
- [Fix Failing GitHub Actions Checks in a Koa API](https://getrush.ai/run/fix-failing-ci/koa/)
- [Fix Failing GitHub Actions Checks in a Laravel App](https://getrush.ai/run/fix-failing-ci/laravel/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
