Skip to content

Gate pull requests

A pull request gate runs your tests against the branch under review and blocks the merge when a failure criterion is breached. Before you start, keep a test in git and set the MAXOPERF_API_KEY secret and MAXOPERF_ACCOUNT_ID variable from the overview.

  1. Add .github/workflows/perf.yml:

    name: perf
    on: pull_request
    permissions:
    contents: read
    pull-requests: write
    jobs:
    load-test:
    if: github.event.pull_request.head.repo.fork != true
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: MaxoPerf/github-action@v1
    with:
    api-key: ${{ secrets.MAXOPERF_API_KEY }}
    account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }}
    config-overrides: TARGET_URL=https://staging.example.com
    pr-comment: true
  2. In Settings → Branches, require the load-test check on your protected branch.

  3. Open a pull request. The job syncs the tests, runs them and waits for the verdict.

The config-overrides line points the run at your staging environment for this run only. To test a per-pull-request preview, see Run after a deploy.

Job summary. The action always writes a summary to the workflow run page: one row per test with its result, the number of breached criteria and a link to the report, followed by a table per test listing each criterion with its status, observed value and threshold.

Pull request comment. With pr-comment: true the action posts one comment and updates that same comment on every push, instead of adding a new one each time. It works on pull_request events and needs pull-requests: write. Without the permission the action logs a warning and the job continues.

Console. Each run shows a CI chip with the repository, PR #n, short commit hash and the source (Action, CLI or deploy hook). The chip links back to the workflow run. In Runs, filter by branch to see every run from one pull request branch.

The CI chip on a run links back to the workflow run and the commit.
The Branch filter on the runs list shows the runs from one branch.
SituationResult
Every criterion holdsThe step passes.
A criterion is breachedThe step fails with criteria not met.
Invalid test file, rejected syncThe step fails with the file name and message.
API or network error, blocked start, timeoutThe step fails.

Set fail-on: never to report the result without failing the check, for example during a trial period. Use timeout-minutes to cap how long the job waits.

GitHub does not give workflows secrets on pull requests from forks. The head.repo.fork != true guard skips the job there instead of failing on an empty key. Do not switch to pull_request_target to get the secret: the comment feature only works on pull_request, and running fork code with secrets is unsafe.