Skip to content
trawler
Use Trawler

GitHub Actions

On GitHub Actions trawler-ci reads the pull request from the event, comments the result on it and writes it to the job summary. This page sets that up from nothing: a token, a project’s id, and a workflow for each of the two ways to run.

  1. An API token. Under API tokens & MCP in Settings create one named GitHub Actions and, under Acts for, choose Only the project. Copy it when the page shows it.
  2. Store it as a secret of the repository: TRAWLER_API_TOKEN.
  3. The project’s id. Open the project in the app; the UUID at the end of the address, app.usetrawler.com/projects/<id>, is it. Store it as a repository variable, TRAWLER_PROJECT; it is not a secret.
  4. A plan that can run. The plan of the project is what the people and goals are taken from. A person who has to sign in needs a test account on the plan or from the job.
  5. Optionally, a description of the setup, .github/trawler/environment.md, saying what the app in the job does not have. See Describing the CI setup.

This workflow builds the app, starts it on localhost:3000, checks Trawler out beside it and tests the pull request’s own build. The example app is started with npm start; use whatever starts yours.

name: Trawler
on:
pull_request:
permissions:
contents: read
pull-requests: write
concurrency:
group: trawler-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
trawler:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm ci
- run: npm run build
- name: Start the app
run: |
npm start &
npx wait-on http://localhost:3000
- name: Start a mail catcher
run: docker run -d -p 1025:1025 -p 8025:8025 axllent/mailpit
- uses: actions/checkout@v4
with:
repository: usetrawler/trawler
ref: stable
path: trawler
- name: Install Trawler
working-directory: trawler
run: |
npm ci
npx playwright install --with-deps chromium
- name: Run Trawler
run: node trawler/apps/ci/src/main.ts run --project "$TRAWLER_PROJECT" --url http://localhost:3000 --allow-origin http://localhost:8025 --runner own
env:
TRAWLER_API: https://app.usetrawler.com
TRAWLER_API_TOKEN: ${{ secrets.TRAWLER_API_TOKEN }}
TRAWLER_PROJECT: ${{ vars.TRAWLER_PROJECT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

What each part is for:

  • permissions. The job reads the repository and writes the comment. Without pull-requests: write the comment is refused with a warning and the run still happens.
  • concurrency. One group for each pull request, so the jobs of different pull requests do not wait for each other, and cancel-in-progress: true, so a newer push cancels the older job of the same pull request. trawler-ci stops that job’s run when it receives the signal; the cancelled run keeps what it found. Without the block, Trawler stops the older run itself when the newer push starts its own: see Newer pushes and other pull requests.
  • if. GitHub gives a workflow that a fork’s pull request starts no secrets, see Pull requests from forks.
  • The app. It starts in the background and wait-on returns once http://localhost:3000 answers. It is started in a step that holds no Trawler secret.
  • The mail catcher. An example for an app that sends mail: Mailpit takes mail on port 1025, which the app is set up to send to, and shows its inbox on http://localhost:8025. --allow-origin lets the people open that inbox; without it the browser blocks it. Drop the step and the option when your app sends no mail, or use the catcher yours uses.
  • Trawler. The second checkout is the public repository, in trawler. npm ci installs it, and npx playwright install --with-deps chromium installs the browser the runner uses and the libraries it needs. ref: stable checks out the branch app.usetrawler.com is deployed from, so the runner speaks the same protocol as the app; a runner of another protocol version is turned away. The checkout has to be the version the app runs: a runner of another version is turned away, see What the job needs.
  • The run. --runner own makes the job carry the run out; --url is where the people start. GITHUB_TOKEN is what lets the command comment and read the pull request’s changed files. The step runs from the root of your repository, not from trawler, because trawler-ci looks for .github/trawler/environment.md in the directory it runs in; see Describing the CI setup.
  • timeout-minutes. The command waits for 45 minutes by default (--timeout-minutes) and then stops the run, so give the job more. A run takes minutes, depending on the people and goals, but it can take up to 3 hours; raise --timeout-minutes as well to wait for a long one.

The command prints its progress to the job’s log and the result to the job summary. See The trawler-ci command.

For a staging site that Trawler’s runners can reach, drop the app, the browser and --url. A hosted run tests the address saved in the project, so it tests the pull request only if that address serves the pull request’s build. This job checks out Trawler alone, so a description of the CI setup in your repository is not found; check your repository out too and pass its path with --environment.

name: Trawler
on:
pull_request:
permissions:
contents: read
pull-requests: write
concurrency:
group: trawler-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
trawler:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/setup-node@v4
with:
node-version: 24
- uses: actions/checkout@v4
with:
repository: usetrawler/trawler
ref: stable
- run: npm ci
- run: node apps/ci/src/main.ts run --project "$TRAWLER_PROJECT"
env:
TRAWLER_API: https://app.usetrawler.com
TRAWLER_API_TOKEN: ${{ secrets.TRAWLER_API_TOKEN }}
TRAWLER_PROJECT: ${{ vars.TRAWLER_PROJECT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Add --fail-on never while you see what Trawler finds: the comment is posted and the check passes whatever the run confirms. Add --cap 1 to keep a run small, or --no-comment to keep the pull request quiet and read the job summary. See Options.

GitHub does not hand secrets to a workflow started by a pull request from a fork, and gives it a read-only GITHUB_TOKEN. In such a job TRAWLER_API_TOKEN is empty, and trawler-ci stops with exit code 2 and TRAWLER_API_TOKEN is not set, before it starts a run. The if in the examples above skips the job for forks instead of failing it.

Without GITHUB_TOKEN, or when the event is not a pull request, no comment is posted: the command prints No pull request comment posted (needs GITHUB_TOKEN and a pull request); see the job summary. The result is in the job summary and in the log. Without the token the command cannot read the pull request’s changed files either, so a plan for the pull request is made from the title and description alone.