Skip to content

GitHub Action

apps/github-action is a composite action (requirement DEPLOYOPS-004). It never checks out or executes a pull request’s code in a context that holds secrets. Example workflow: examples/workflows/yomorai.yml.

Status: the scripts are tested (verification/acceptance/github-action.test.ts) and were run locally in both modes with node src/run.ts. The composite action.yml has not yet run on a GitHub-hosted runner.

Use it as shashikanth-a/yomorai@<tag or commit>: the action.yml at the repository root runs the scripts in apps/github-action. Tag v0.0.1 also has it at shashikanth-a/yomorai/apps/[email protected].

Sends POST /api/repos/:owner/:repo/reviews with { "prNumber": n } and Authorization: Bearer <token> to your deployment. The deployment reads the pull request from GitHub itself, creates the review in pending_approval, and publishes a check run asking a maintainer to approve the exact head commit. The request authorizes nothing: no review runs before that approval.

The token is a deployment API token with the review scope, created by a maintainer (POST /api/repos/:owner/:repo/tokens) and stored as a repository secret.

Forward mode needs no install: node src/run.ts imports only Node’s built-in modules. Inputs other than url, token and pr-number are ignored with a warning, because the deployment takes deployments, routes and categories from the repository configuration on the default branch.

Note that a GitHub App deployment already creates reviews from pull_request webhooks. Forward mode is useful when webhook triggers are restricted (triggers in the configuration) or to start a review from a workflow.

Runs yomorai review --production <url> --preview <url> --json on the runner against two URLs that are already deployed. It:

  1. checks out only the base repository’s default branch, sparsely, to read the configuration file (persist-credentials: false);
  2. installs the dependencies of the pinned Yomorai copy the runner downloaded for the action (pnpm install --frozen-lockfile --ignore-scripts) and Chromium;
  3. runs the CLI from that copy in an empty directory under RUNNER_TEMP;
  4. maps the CLI’s exit code to the step result (fail-on).

It never builds or runs the pull request’s code; the review only opens the deployed URLs in a browser, with production read-only. If github-token is available and the event is a pull request, the CLI also reads the pull request’s title, description and diff through the API — as data.

Input Default Mode Meaning
mode forward both forward or local
url forward Base URL of your deployment
token forward Deployment API token from a secret
pr-number from the event both Pull request number
production-url, preview-url local The two deployed URLs (https; http only on localhost)
categories, routes, viewports all local Comma-separated subsets, as for the CLI
config-path first of the four standard names local Configuration file path on the default branch
models false local Use the models in the configuration (keys from the step’s env)
fail-on findings both findings: fail on a regression at or above report.failOn; incomplete: also when the review did not finish; never: report only
github-token github.token local Read access, for the configuration and the pull request
Output Values
review-id The review’s identifier, empty when none was created
conclusion forward: the review state (normally pending_approval), skipped or error; local: success, neutral, failure, incomplete or error

Step result in local mode: CLI exit 0 → success; 1 → failure unless fail-on: never; 3 (incomplete) → success with a warning unless fail-on: incomplete; 2 or anything else → failure.

Why it is safe on pull requests from forks

Section titled “Why it is safe on pull requests from forks”
  • Trigger on pull_request, never on pull_request_target. On pull_request GitHub gives workflows from forks no secrets and a read-only token. pull_request_target gives secrets and a write token while the pull request’s author controls the code. The action’s first step fails on pull_request_target, and src/run.ts refuses it again.
  • Fork pull requests in forward mode have an empty token. The action then sends nothing, makes no network call, writes a notice that a maintainer can comment /yomorai review on the pull request, and ends with exit 0 and conclusion=skipped. There is no fallback to anything else.
  • Local mode never checks out the pull request’s head; it uses only the default branch’s configuration file and deployed URLs.
  • Inputs reach the scripts as environment variables, not interpolated into shell code; the token is masked and never written to an output.
  • Pin the action to a full commit SHA, as the example does.

apps/github-action/src/lint-workflow.ts reports three unsafe patterns:

Terminal window
node_modules/.bin/tsx apps/github-action/src/lint-workflow.ts .github/workflows/*.yml
Rule Pattern
pull-request-target-head-checkout a pull_request_target job that checks out the pull request’s head (head.sha, head.ref, github.head_ref, refs/pull/…, gh pr checkout) and references secrets or keeps the privileged token
head-code-executed-with-secrets a job that checks out the head and then installs, builds or runs code while it references secrets
yomorai-action-in-pull-request-target this action used with secrets in a pull_request_target workflow

Exit 0 when nothing is found, 1 for a violation, 2 when a file cannot be read. It is a narrow check for these patterns, not a workflow security audit.