Run an automated code review on each ready-for-review pull request. GitHub Actions signs in to Teleport with OIDC, starts a beam as an ephemeral runtime, and copies in the checkout. OpenCodeReview runs in the beam and calls the LLM Gateway. The runner copies back the result and posts the review to GitHub. The GitHub token stays on the runner, and no inference provider key is copied into the beam.
This walkthrough adapts the reference repository. The review is advisory: it does not approve, merge, or deploy the pull request.
Install the client tools and sign in
Beams is a Teleport project and uses official Teleport client tools.
The client tools include tsh to sign in and run commands, and tctl to administer your cluster if you have permission.
Cluster: example.beams.run. Edit this example to use your cluster name.
Install version 18.11.10 of the client:
Download and open the macOS installer, then follow its instructions.
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkgFor Linux x86-64, download and install the client tools:
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/installFor Windows x86-64, run these commands in PowerShell. Add the extraction directory ($env:LOCALAPPDATA\Teleport) to your user PATH to use tsh in future terminals; the last command adds it to this terminal's PATH.
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"Follow the official client tools install guide for other versions and architectures.
Check that you’re running v18.11.10 of the client with tsh version.
tsh versionI sign in without a password (e.g. a passkey).
tsh login --proxy='example.beams.run' --auth=passwordlessI have a password & MFA set up for my account:
Replace you@example.com with your Teleport username.
tsh login --proxy='example.beams.run' --user=you@example.comI sign in with SSO (e.g. Okta, GitHub, SAML).
tsh login --proxy='example.beams.run'You need:
- A GitHub repository with Actions enabled and permission to configure environments and repository variables. Use a test repository first. This workflow is for branches pushed by trusted contributors in the same repository; it skips fork and draft pull requests.
- A Teleport cluster with Beams, permission to create bots and join tokens, and an Anthropic-compatible gateway accessible to
beam-user. Use built-in inference for evaluation and your own inference endpoint for regular CI traffic. Have your admin confirm that new beams route to the intended endpoint and that the model is available there. - A
tshandtbotbuild for the runner that supports your cluster’s Beams commands and direct-role bots. The reference repository targets a development cluster and works around atbotcompatibility issue with a custom build. Use a compatible official release when available, or an approved build from your Teleport administrator. Do not use the demo’s bundled binary as a general-purpose installer.
1. Create a bot and GitHub join token
Save this as teleport/bot.yaml. direct_unscoped_role_assignment: true puts beam-user on the bot’s own identity, so the bot can delegate that role to the beam. Set this at creation; it is not an option you can change later on an existing bot.
kind: bot
version: v1
metadata:
name: ocr-reviewer
spec:
direct_unscoped_role_assignment: true
roles: [beam-user]
traits:
- name: logins
values: [beams]Save this as teleport/token.yaml and replace my-org/my-repo with the repository that runs the workflow. Keep the workflow and environment names in sync with the YAML in step 3. The join token is a policy, not a shared password: Teleport checks claims in the OIDC token that GitHub issues for the job.
kind: token
version: v2
metadata:
name: ocr-reviewer
spec:
roles: [Bot]
bot_name: ocr-reviewer
join_method: github
github:
allow:
- repository: my-org/my-repo
workflow: Review pull requests in a beam
environment: beam-review
event_name: pull_requesttctl create teleport/bot.yaml
tctl create teleport/token.yamlIf the names are already in use, choose unique names and update the workflow’s TELEPORT_JOIN_TOKEN as needed. Do not overwrite an existing bot or token from another pipeline.
2. Configure GitHub Actions
In your GitHub repository, go to Settings → Environments, create beam-review, and configure required reviewers if your plan supports them. Use an isolated test repository with trusted contributors if you cannot enforce the necessary protection. The OIDC policy matches GitHub’s workflow name and environment claims; those names alone do not make a workflow trustworthy.
Under Settings → Secrets and variables → Actions → Variables, add:
| Repository variable | Value |
|---|---|
TELEPORT_PROXY_ADDR |
Your Teleport proxy address, such as example.beams.run:443. |
TELEPORT_TOOLS_VERSION |
The compatible official client release to install, without the v prefix. If using an approved custom build, replace the setup step with installation of trusted tsh and tbot binaries on the runner’s PATH before authentication. Never load those binaries from the pull request checkout. |
OCR_MODEL |
A model ID exposed by the beam’s Anthropic-compatible endpoint, such as claude-opus-5-5 if available. |
3. Add the workflow
Save this as .github/workflows/ocr-review.yml. The runner keeps the Git metadata so OCR can review the diff from the merge base to the pull request head. It does not run any scripts or tests from the pull request checkout on the runner. The comment helper comes from a pinned OpenCodeReview revision, not the pull request.
name: Review pull requests in a beam
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: beam-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions: {}
jobs:
review:
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
environment: beam-review
timeout-minutes: 40
permissions:
contents: read
id-token: write
pull-requests: write
env:
TELEPORT_PROXY_ADDR: ${{ vars.TELEPORT_PROXY_ADDR }}
TELEPORT_JOIN_TOKEN: ocr-reviewer
OCR_MODEL: ${{ vars.OCR_MODEL }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
path: src
- uses: actions/checkout@v4
with:
repository: alibaba/open-code-review
ref: f921d6a0de3b71befce15d8edf589cd3609968fa
sparse-checkout: scripts/github-actions
persist-credentials: false
path: ocr
- uses: teleport-actions/setup@v2
with:
version: ${{ vars.TELEPORT_TOOLS_VERSION }}
- uses: teleport-actions/auth@v2
with:
proxy: ${{ env.TELEPORT_PROXY_ADDR }}
token: ${{ env.TELEPORT_JOIN_TOKEN }}
certificate-ttl: 1h
allow-reissue: true
- name: Create beam
run: |
tsh beams add --no-console --roles=beam-user \
--no-share-connected-accounts --format=json > beam.json
beam=$(jq -er '.uuid // .id' beam.json)
printf 'BEAM=%s\n' "$beam" >> "$GITHUB_ENV"
jq '{id, uuid, roles, expires}' beam.json
- name: Copy checkout and install OCR
run: |
tar -C src --exclude=./bin/tbot.gz -czf src.tgz .
tsh beams scp src.tgz "$BEAM:/tmp/src.tgz"
tsh beams exec "$BEAM" -- 'mkdir -p ~/work && tar -C ~/work -xzf /tmp/src.tgz && rm /tmp/src.tgz'
tsh beams exec "$BEAM" -- 'curl -fsSL https://raw.githubusercontent.com/alibaba/open-code-review/f921d6a0de3b71befce15d8edf589cd3609968fa/install.sh -o /tmp/install-ocr.sh && OCR_VERSION=v1.13.12 OCR_INSTALL_DIR="$HOME/.local/bin" sh /tmp/install-ocr.sh'
- name: Review diff and collect result
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
merge_base=$(git -C src merge-base "$BASE_SHA" "$HEAD_SHA")
[[ "$merge_base" =~ ^[0-9a-f]{40}$ && "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]
[[ "$OCR_MODEL" =~ ^[a-zA-Z0-9][a-zA-Z0-9._:-]*$ ]]
status=0
tsh beams exec "$BEAM" -- "cd ~/work && test -n \"\${ANTHROPIC_BASE_URL:-}\" && ANTHROPIC_AUTH_TOKEN=unused ANTHROPIC_MODEL='$OCR_MODEL' \"\$HOME/.local/bin/ocr\" review --from '$merge_base' --to '$HEAD_SHA' --audience agent --format json > /tmp/ocr-result.json 2> /tmp/ocr-stderr.log" || status=$?
tsh beams scp "$BEAM:/tmp/ocr-result.json" /tmp/ocr-result.json
tsh beams scp "$BEAM:/tmp/ocr-stderr.log" /tmp/ocr-stderr.log
exit "$status"
- name: Delete beam
if: ${{ always() && env.BEAM != '' }}
run: tsh beams rm "$BEAM"
- name: Post review comments
uses: actions/github-script@v7
with:
script: |
const fs = require('node:fs');
const path = require('node:path');
const { runPostReviewComments } = require(path.join(
process.env.GITHUB_WORKSPACE, 'ocr/scripts/github-actions/post-review-comments.js'
));
await runPostReviewComments({
github, context, core, fs,
prNumber: context.issue.number,
resultPath: '/tmp/ocr-result.json',
stderrPath: '/tmp/ocr-stderr.log',
stickySummary: true,
incremental: false,
incrementalOverlapThreshold: 0.6,
reviewCommentBatchSize: 50,
routeSeverityBelow: '',
routeCategories: '',
checkpointEnabled: false,
resolveOutdated: 'false',
});ANTHROPIC_AUTH_TOKEN=unused is a placeholder for OCR, not a provider credential. OCR uses the beam’s ANTHROPIC_BASE_URL; the gateway supplies credentials upstream. The workflow does not upload session traces as artifacts. Review comments and diagnostics can still contain source excerpts; keep repository visibility and inference data handling in mind.
4. Run and verify the review
Commit the workflow to the default branch through your normal review process. From a new branch in the same repository, make a small, non-sensitive change and open a pull request that is ready for review. If you configured environment protection, have an authorized reviewer approve the job in GitHub Actions.
In Actions, open the run and check that:
- Teleport Auth joins as the CI bot; no Teleport secret stored in GitHub is needed.
- Create beam prints a beam ID, roles, and expiry. Review diff and collect result completes with the OCR result copied back to the runner.
- Delete beam succeeds. The pull request shows the review summary and inline comments if OCR found anything. No inline comments does not necessarily mean the review failed.
If authentication fails, check the join rule against the run’s repository, event, exact workflow name, and environment. If the failure mentions direct roles or reissuing certificates, check the runner’s tbot version, the bot’s direct_unscoped_role_assignment, and allow-reissue. For inference errors, check the model name and the beam’s gateway route and budget. If the final step cannot post, verify the job has pull-requests: write and that organization policy allows it.
5. Clean up
The delete step runs after earlier failures if the runner saved the beam ID. A hard cancellation or runner loss can prevent it. Check the beam ID and expiry in the job log; if it still exists, have an authorized administrator remove it rather than waiting for expiry. The runner’s tsh beams ls lists its own beams, not those of other identities.
To retire the integration, first disable the workflow and wait for active runs to finish. Then remove the dedicated join token and bot:
tctl rm token/ocr-reviewer
tctl rm bot/ocr-reviewer