GitHub integration

Pipemesh connects to GitHub through the Pipemesh GitHub App. Install it and you're connected: no personal token, no webhooks to set up. Getting started shows how.

GitLab and self-hosted repositories are coming soon.

What the App can do

It reads a lot and writes very little:

Permission Access Used for
Metadata Read finding your repositories
Contents Read commits, files, diffs; never pushes
Commit statuses Read/write held for plain statuses; results report as check runs
Checks Read/write native check runs on pull requests
Pull requests Read/write pull request workflows; the pull request a merge commit links; one comment on each merged pull request
Actions Read/write starting and cancelling jobs that run on GitHub Actions (see The definition)
Members (organization) Read who belongs to an organization and who administers it, for its members and owners in Pipemesh, and each member's teams and the repositories those teams reach, so their lists show what GitHub lets them read
Administration (organization) Read the organization's base permission (none, read, write, admin): with read or more, every member lists all its repositories

The App can't push code or edit workflow files. Pipemesh reads with short-lived installation tokens, and only writes check runs, Actions dispatches, and its comment on merged pull requests.

What each permission exposes

The App's installation token holds every permission above, on every repository the App is installed on. Only Pipemesh's own servers hold it. This is what a holder of that token could reach, whatever Pipemesh uses:

  • Metadata: read: each installed repository's name, description, visibility, branches and collaborators.
  • Contents: read: each installed repository's code, history, branches, tags and releases, private ones included.
  • Commit statuses: read/write: post a status on any commit of any installed repository, including one a branch protection rule requires.
  • Checks: read/write: create or update a check run on any commit of any installed repository, under the App's name, the one your required checks name.
  • Pull requests: read/write: read every pull request, its reviews and comments; open, edit and close pull requests and comment on them. Merging needs Contents: write, which the App doesn't have.
  • Actions: read/write: read workflow runs, their logs and artifacts; start a workflow_dispatch workflow, re-run or cancel one, in any installed repository. Not the repositories' secrets.
  • Members (organization): read: the organization's members, private (concealed) memberships included, and its teams, secret ones included, with their members and repositories.
  • Administration (organization): read: the organization's settings that GitHub shows only to its owners: the base permission, member privileges, the two-factor requirement, and the organization's other administrative settings. Nothing in it can be changed with read.

What a job gets

A job never gets the App's token. Each repository a job clones, its own, a repo: or a repos: entry, comes with a token minted for that repository alone:

  • Contents: read on that one repository, and the Metadata: read GitHub adds to every token. No other permission, and no other repository: no statuses, checks, pull requests, Actions, members or organization settings.
  • It expires within the hour, and the job's log masks it.
  • Jobs of the same repository share it, so a busy repository costs GitHub one token every 50 minutes, not one per job.

The same holds on every runner: the hosted ones, CodeBuild, and your own runners, which get only the tokens of the repositories their jobs clone. A job on GitHub Actions gets GitHub's own GITHUB_TOKEN from its workflow, and none of Pipemesh's.

So a job that reads another repository declares it in repos:, even when its clone credential used to open it. A script that calls the GitHub API with the clone credential gets only what Contents: read on its own repository allows.

When the App asks for a new permission, each organization must approve it on GitHub (a review request on the installation). Until then, its jobs that run on GitHub Actions fail with a message saying so, and its merged pull requests get no comment: Pull request comments in the organization's General settings says NOT APPROVED. Without Administration (organization), Pipemesh can't see the base permission: a member's lists show the repositories their teams reach, and the others open from a link.

Webhooks

The App sends pushes, pull requests, check runs and workflow runs as they happen. A push starts its pipeline in seconds, and a job on GitHub Actions settles the moment its run finishes.

Deliveries are signed (X-Hub-Signature-256) and backed by polling, so a lost one costs a poll interval, never work. Polling is every 5 minutes unless an Owner picks another interval (30 s to 15 min, or off) under Polling in the organization's General settings.

Merged pull requests get linked to the revision or workflow run at the merge's commit (merge, squash or last rebased commit), in the revision panel and a job's Revision and Run tabs. Only the webhook makes this link, so a lost delivery means none.

After the merge

Checks answer "can this be merged?". After the merge, the question is "where is my change now?", and a revision can bring in several merges at once, or a later run can cover a revision that never ran.

  • Every commit a run covers gets its status. A job's run at a revision posts its result on each commit that revision brought in, and on those of the revisions it skipped, described like succeeded in rev 483, together with #57. A run that succeeds also turns green the commits whose own run failed since the job's last success: succeeded in rev 483, after rev 480 failed. A revision where only a declared repository moved posts beside the commit's own result, as pipemesh/<job> · infra.
  • One comment on each merged pull request, written when the first revision that carries the merge exists and edited in place as the change moves: one block per pipeline that carries it, each job's result for that revision, ✓ in rev 485 when a later run covered it, and ✓ in rev 483 (rev 480 failed) when a job's own run failed and a later one succeeded; the picture says so too. A failed job keeps the comment open, since a later success may still change it. It is edited at most every 30 seconds, only when what it says changed, and left alone once every job has a final result (or after 7 days). Direct pushes get none. On a public repository the comment and its picture show only the public pipelines and workflows: a private one that carries the merge is left out, not counted, and a merge only private ones carry gets no comment. Each edit applies the rule again, so a pipeline made public or private shows or drops from the next one.
  • Track this change: the comment links a page with the same, following the change live: /{repository}/-/merges/{number}. It shows each reader the pipelines they may read. The revision panel lists the requests each revision merged in, with that link and Refresh note. The page opens as a #226 tab (!226 on GitLab), and a board's source card links it beside a commit that is a merge. It shows the request's last checks and merge queue runs, each pipeline's child pipelines (or not handed over when nothing the job watches changed), the workflow runs the merge started, and reused from #226's checks for a job that took the request's build; the comment says the same.
  • Switches: an Owner turns commit statuses and pull request comments off for their organization under General settings.

Checks on pull requests

  • One check per job and commit, named pipemesh/<job>. A child carries its path: pipemesh/build/commit_lint.
  • Each check links to its job: its details open that job's panel in Pipemesh, in the run the check belongs to.
  • Native check runs, with skipped among the conclusions, so branch protection can require a job that may skip.
  • Useful failures: the summary shows the failing task's log excerpt, and compiler output (javac, tsc) becomes file and line annotations on the diff.
  • Re-run works: GitHub's Re-run on a failed check retries the job, with the commits its run started with, so a flaky failure shows as one.
  • Re-run all checks starts a new run: the pull request's head again, with the other repositories it reads at their current heads, when one of them got the fix since. Every check goes back to queued at once and links to the new run. The run it replaces says so, can't be retried, and posts nothing more. A run that succeeded isn't run again. The run's page has the same as New run, and pipemesh rerun <workflow> --run=<n> --new.
  • A failed check says what it worked with: the commit of each other repository its job read, and which button keeps it.

Pull request workflows

Workflows with on: pull_request run once per pull request head, on the head commit: the branch as pushed, never a hypothetical merge. Results show up on the pull request within seconds.

  • Builds reuse the outputs of an earlier successful run with the same fingerprint: trusted runs first, then this pull request's own, never another's.
  • Tasks always run. Deploys belong to pipelines.

The checkout is one commit deep. A job that needs the merge base fetches the target's history itself. Without file contents (--filter=blob:none) that is a few MB even for a large repository:

t=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
git fetch --filter=blob:none --unshallow origin "+refs/heads/$t:refs/remotes/origin/$t"
git merge-base "origin/$t" HEAD

Monorepo checks rarely need it: run every task and let the tool's cache skip what's unchanged (Nx).

What a fork's pull request gets

A pull request from a fork runs code from a repository you don't control, and on a public repository its author can be anyone. So its run gets less than one of your branches, and so do its children. A pull request is a fork's when its head lives in another repository than its base; one whose head repository GitHub no longer names (a deleted fork) counts as a fork's too.

A pull request from a branch of the repository itself, whose author can push there, runs as a push does: it clones each repository with that repository's own token (What a job gets), and none of the rules below apply. So does a merge queue's run: the queue's branch is your repository's, and someone who may merge queued the pull request.

  • A stranger's waits for approval. A fork's pull request from someone who isn't an owner, member or collaborator of the repository (on GitLab: without the Developer role on the project) doesn't run until a maintainer approves its head. The workflow's page says N waiting for approval, with Approve and run for maintainers, and the pull request gets a pipemesh/<workflow>/approval check marked Action required. Each new push waits again.
  • No credential but its own repository's. On a private repository the run clones with that repository's token: it reads that one repository's contents and expires within the hour. On a public repository it clones with no credential at all.
  • Other repositories must be public. A repo: or repos: entry naming a private repository fails the job, saying so. Pull requests from your own branches still get it.
  • No github_actions: jobs. The workflow would run in your repository with its secrets, on the pull request's code. The job fails, saying why.
  • No CodeBuild projects. A job routed to one fails.
  • Nodes of their own, where the instance has them. On hosted runners, a fork's pods are apart from your organization's other jobs only on an instance with per-organization nodes. There a fork's dockerd: true job runs on nodes kept for the organization's forks, and so do its other jobs, unless the instance runs jobs without a Docker daemon as unprivileged pods on nodes every organization shares. An instance without per-organization nodes runs a fork's pods on the nodes every job uses, and refuses dockerd: true in forks' pull requests.
  • At most six hours. timeout_seconds: is capped there, and the job's token and identity tokens expire an hour later.
  • Secrets: as for every pull request, a secret reaches one only if its contexts include it.
  • Caches are read-only. A fork's jobs restore trusted caches and save none. A pull request from your own branches saves into a space that is used once it merges.

CI_MERGE_REQUEST_SOURCE_PROJECT_ID and CI_MERGE_REQUEST_PROJECT_ID name the head's repository and the base's, as the provider's ids.

GitHub merge queue

Mark Pipemesh checks as required and turn on the merge queue. That's all. Each group runs your on: pull_request workflows once on the queue's commit and reports the checks the queue waits for.

  • Which workflows: those whose targets: include the queue's base branch, or that have no targets:.
  • Build reuse: the queue's commit holds the pull requests ahead in the group too, so a build reuses only if what it checks out there matches an earlier successful run.
  • Secrets and caches: as for a pull request, since the commit isn't on the base branch yet.
  • Spotting a queue run: CI_MERGE_REQUEST_EVENT_TYPE=merge_train, a gh-readonly-queue/… ref, and a title starting with merge queue:.

Job identity

A job proves who it is with a short-lived OIDC token from Pipemesh's own issuer. Cloud accounts and other services trust it directly: no stored keys, nothing to rotate.

Request a token

On an instance with a public URL, like pipemesh.io, every job gets:

Variable What it is
PIPEMESH_JOB_TOKEN The job's own credential, masked in logs: it opens what the job calls in Pipemesh, and requests identity tokens. Only Pipemesh accepts it and no other party sees it, so one party's token can't be turned into another's.
PIPEMESH_ID_TOKEN_REQUEST_URL https://<instance>/api/runtime/token

A job gets tokens only for the audiences it declares, in its id_tokens: or through a component it uses. Which clouds a job can reach is then its configuration, reviewed in the pull request that adds it, and a job that declares nothing gets no identity at all. A declared audience can also be requested while the job runs, for a fresh token mid-run; any other audience is refused (403), naming what to add. Request one token per party, with that party's audience:

token=$(curl -fsS -X POST \
  -H "Authorization: Bearer $PIPEMESH_JOB_TOKEN" \
  --get --data-urlencode "audience=sts.amazonaws.com" \
  "$PIPEMESH_ID_TOKEN_REQUEST_URL")

The response is the token, valid for the job's timeout plus an hour, as long as the job token itself. A token for pipemesh:runtime is never minted: no identity token opens anything in Pipemesh.

Claim Value
iss https://<instance>/api/oidc (discovery and keys under it)
sub the job's subject (copy it)
aud the audience the job requested
context what started the run: pipeline, push, schedule, manual, tag or pull_request
pipeline, pipeline_id a pipeline's job: the pipeline's alias and id
workflow, workflow_id a workflow's job: the workflow's alias and id (instead of pipeline and pipeline_id)
mesh_id the id of the job's mesh (its repository in Pipemesh): one policy can name every job of a mesh, pipelines and workflows alike
job, ref, sha, org the job, ref, commit and organization
repository_id, repository_owner_id, job_id The ids of the repository and its owner, and the job's own id (renaming the job with was: keeps it). GitHub's ids are bare (4243). A GitLab's follow its id, as in the subject (gitlab:4243)
project_path, namespace_path Only for a GitLab project: GitLab's names for its path without the host (acme/platform/app) and its parent (acme/platform)
ref_type branch, or tag for a tag's run
ref_protected "true" (a string, as GitLab writes it) when your Git host protects the run's branch or tag, as the host's own CI token would say: on GitHub, a branch protection rule or an active ruleset applies to it; on GitLab, it is a protected branch or tag. "false" for pull requests, for refs the host doesn't protect, and when the host can't be asked. Pipemesh asks when it mints the job's token, and keeps an answer for a minute
pipeline_source GitLab's word for what started the run: push (a pipeline, push or tag run), merge_request_event, schedule or web (manual)
runner_id, runner_environment the machine: on your own runner, its numeric id and self-hosted; on a hosted runner, pipemesh-hosted and no runner_id

The GitLab claims mean what they mean in a GitLab job's token, so a Vault role or cloud trust written for GitLab CI moves by changing the issuer and the audience. Never write a trust on the repository and ref alone, since a pull request's token carries its source branch as ref: bind sub, or add ref_protected: "true" or context: pipeline. GitLab's issuer is the GitLab itself. Pipemesh's issuer signs for every Git host the instance knows, so a GitHub repository never carries project_path: github.com's acme/app can't meet a trust in gitlab.com's. An instance that knows more than one GitLab has the same paths on each, so there bind repository_id or sub, which name the GitLab. ref_protected is in GitHub Actions' tokens too, with the same meaning. A trust for release tags binds ref_type: tag and ref_protected: "true", or the tag subject (…:ref:refs/tags/v*).

Who may release is your Git host's call. A tag's run is code from the repository's branch or a branch its trigger lists, but anyone who may push a tag can tag an old commit of those branches, and anyone who may push to them can add one. Protect the listed branches, and protect release tags (GitHub tag rulesets with Restrict creations, GitLab protected tags) to choose who may create them. Then a trust that binds ref_protected: "true" accepts only those tags; without the protection, it accepts none. A trust that means the branch's runs only binds ref_type: branch too.

Declared tokens

A job can declare its tokens instead of requesting them, as GitLab CI does with id_tokens:. Each name is a variable the job gets, holding a token for its audience:

deploy:
  runner: deploy-production
  id_tokens:
    VAULT_ID_TOKEN:
      aud: https://vault.example.com
    CLOUD_TOKEN:
      aud: [sts.amazonaws.com, https://other.example]   # aud is a list in the token
  script: vault write auth/jwt/login role=deploy jwt="$VAULT_ID_TOKEN"
  • The tokens are minted when the job starts, with the same claims and lifetime as a requested one, and masked in its log. Scripts and runner hooks (pre_build_script) that read a variable keep working.
  • A run without identity fails the job before its script, saying why: a run on a commit an API call made up, or an instance without a public URL.
  • Names follow the variable rules: [A-Z][A-Z0-9_]*, never CI_ or PIPEMESH_, and not a name the job's variables:, secrets: or consumes: also sets. At most ten per job.
  • An audience is 1 to 256 printable characters, no spaces.

CI_JOB_TOKEN

A job's CI_JOB_TOKEN is Pipemesh's job token, not GitLab's: it authenticates the runner protocol and the job's calls to Pipemesh, and it dies with the run. Nothing outside Pipemesh can check it, so a service that took a GitLab job token as proof of identity takes an identity token instead.

It also answers GET /api/v4/job (header JOB-TOKEN, or job_token), the read most integrations make, in GitLab's shape:

curl -fsS -H "JOB-TOKEN: $CI_JOB_TOKEN" "https://<instance>/api/v4/job"

The answer has the job's id, name, stage, status, ref, tag, created_at and started_at; its pipeline (id is the revision, or the workflow's run number, with project_id, ref, sha and status); and project (id and path_with_namespace), which GitLab doesn't send. The project is a GitLab project's only: a GitHub repository's job has project and pipeline.project_id null, so it never answers a GitLab project's id or path. Once the run is over, the token is 401 Unauthorized. Other GitLab API calls aren't answered.

Trust it on the other side

The party you connect to (a cloud account, a cache, a registry) needs:

  • Issuer and subject: copy them from the repository's Settings → Job identity, or print them with npx pipemesh identity. Never write a subject by hand.
  • Audience: what your job requests. Use the party's own, such as sts.amazonaws.com for AWS.

Each job has its own subject: trust only the jobs that need access. Where patterns work (AWS StringLike), Settings also gives one for every job of the repository.

Never trust the pull_request context for anything that can write: anyone who can open a pull request runs code in it. The subjects in Settings are for the repository's branch, so a pull request's jobs never match them.

Components that do it for you

A component declares the tokens it needs with id_tokens: in its job:, and they join the job's (Typed components).

  • aws/role@1 (a setup: step) declares an sts.amazonaws.com token (AWS_ROLE_ID_TOKEN) and exports the AWS SDK's web-identity environment, so every AWS call after it assumes the role.
  • vercel/turborepo-token@1 declares a https://vercel.com/<team> token (VERCEL_ID_TOKEN) and exchanges it at Vercel for a Turborepo token. See Turborepo monorepo.

Renames and transfers

Pipemesh follows a repository by the id GitHub keeps through renames and transfers. There's nothing to do.

  • Renamed repository or organization: pipelines, aliases and settings follow within seconds. Old URLs and aliases work while GitHub redirects.
  • Transferred to a connected organization (with the repository in its installation): the pipeline moves with its history and the repository's own variables and secrets. The old organization keeps its own settings and past usage.
  • Transferred where Pipemesh can't read it: the pipeline stops polling and its page says where it went, until you connect that organization with the repository.
  • Caches and job images start cold, as they're keyed by the repository's path.
  • Job identity subjects use ids, so renaming the repository, its organization or a job (with was:) doesn't change them. Trusts follow a transferred repository to its new owner; remove any that shouldn't.

A missed webhook only delays a rename: Pipemesh also checks on its own, at least hourly.

Deleting an organization

An Owner deletes the organization in its General settings: Delete group on GitLab, Delete organization on GitHub, typed to confirm.

  • At once, Pipemesh stops: its meshes stop running and its jobs are canceled, and its connection, the group token, the webhook token, its secrets and variables and its runners' tokens are deleted. It no longer shows up for anyone in it.
  • For 30 days its history is kept: meshes, runs, logs, artifacts and members. Connect the same group (or GitHub account) again within those days and it comes back as it was, with its meshes off until you turn each one on. Secrets, variables and runners are not restored.
  • To finish on the provider, delete the group access token and the Pipemesh webhook in the group's settings, or uninstall the Pipemesh GitHub App; the dialog links both pages.