Deploy from GitHub Actions
ob runs wherever its keys are: a laptop, a dev box, an agent, or a GitHub
Actions runner. The commands are the same in every case. A workflow lets the
people with access start a deploy with gh workflow run or the Actions tab,
on a machine that holds the keys, while a human still approves it.
Choose the runner by where the keys live
Section titled “Choose the runner by where the keys live”ob needs an SSH identity for the server, the server’s key in
~/.ssh/known_hosts (it never skips host verification), and whatever decrypts
the project’s secrets, such as a SOPS age key.
| Runner | Keys | Use it when |
|---|---|---|
| Self-hosted, on a machine that already deploys | stay on that machine; nothing is stored in GitHub | the keys must never leave your machines |
| GitHub-hosted | stored as environment secrets and written to the runner for the job | you accept GitHub holding a deploy key |
On a self-hosted runner the job uses the runner user’s ~/.ssh and agent, so
ob deploy behaves as it does in that user’s shell. The runner also needs
git, gh and jq, which a self-hosted machine does not always have;
GitHub-hosted runners include them.
Who can deploy
Section titled “Who can deploy”A workflow started with workflow_dispatch runs the workflow file from the
branch the caller picks. Anyone who can push a branch can therefore run their
own deploy.yml on a runner that accepts the repository’s jobs. That run need
not contain an approval step at all.
On a self-hosted runner that holds the keys, everyone with write access to the repository can reach those keys. An approval gate cannot change that. It stops mistakes, not people with push access. Limit it with one of these:
- Give deploys their own runner. Never put the keys on a runner that also
builds, tests or releases: every job it runs can read them. A label such as
deployonly says where a job asks to run; it does not stop another workflow asking for it. - Restrict the runner. Put the deploy runner in a runner group that only
this workflow may use, at a protected branch such as
main, and protect that branch. Where your plan offers no such restriction, treat repository write access as deploy access. - Keep the keys in GitHub. Use a GitHub-hosted runner and store the keys as
environment secrets, with the environment’s deployment branches limited to
main. A run from any other branch cannot read them.
Never attach a key-holding self-hosted runner to a public repository: a pull request from a fork can run code on it.
Choose the approval gate
Section titled “Choose the approval gate”A workflow deploy needs a human gate as much as a terminal deploy does. Pick one of two; without either, anyone who can start the workflow deploys.
| Gate | Requires | Onebox policy |
|---|---|---|
| Onebox approval, typed at a terminal | nothing beyond Onebox | requireApproval: true (the default) |
| GitHub required reviewers | a public repository with GitHub-hosted runners, or GitHub Enterprise for a private one | requireApproval: false |
GitHub offers required reviewers on private repositories only with GitHub Enterprise. On Free, Pro and Team, a private repository uses Onebox approval.
Inputs reach the scripts through env, never pasted into them with ${{ }},
so an input cannot run as shell. Both workflows below install ob with
labstack/setup-onebox, which
downloads the release for the runner’s OS and architecture, checks it against
the release’s checksums, and puts ob on PATH. Pin it by commit, with the
release as a comment, and pin the Onebox version a deploy uses:
- uses: labstack/setup-onebox@70b22ea24ef456027bb46854737bc2d1ac375e88 # v2026.11.0-alpha with: version: 2026.11.5-alphaOnebox approval: any repository
Section titled “Onebox approval: any repository”ob approve records a human confirmation typed at a terminal, and has no flag
to skip it. It reads only the plan file, contacts nothing and needs no keys,
so the plan is made on the runner and approved on your laptop:
- A run with no
plan_runinput makes the plan and uploads it. The plan’s Compose is redacted, so the artifact carries no secret values. - You download it, review it, and approve it with
ob approve. - A second run receives the plan run’s ID and the confirmation, and applies exactly that plan. A plan expires 15 minutes after it is made, and a host that drifted in between is refused, as for any saved plan.
name: Deployon: workflow_dispatch: inputs: environment: description: Onebox environment default: production plan_run: description: Run ID of the plan to apply; empty makes a new plan default: "" approval: description: Contents of ob-approval.json from ob approve default: ""
permissions: contents: read actions: read # download the plan from the plan run deployments: write # lets ob report the deploy with the job's own token
concurrency: group: deploy-${{ inputs.environment }} cancel-in-progress: false
jobs: plan: if: inputs.plan_run == '' runs-on: [self-hosted, deploy] steps: - uses: actions/checkout@v4 # Install ob (above) - env: ENVIRONMENT: ${{ inputs.environment }} run: ob plan --env "$ENVIRONMENT" --out ob-plan.json - uses: actions/upload-artifact@v4 with: name: ob-plan path: ob-plan.json retention-days: 1
apply: if: inputs.plan_run != '' runs-on: [self-hosted, deploy] steps: # Apply only a plan this workflow made from main, and check out the # commit it was made from, because the plan binds that configuration. - id: planned env: GH_TOKEN: ${{ github.token }} PLAN_RUN: ${{ inputs.plan_run }} run: | case "$PLAN_RUN" in ''|*[!0-9]*) echo "::error::plan_run must be a run ID"; exit 1 ;; esac run=$(gh run view "$PLAN_RUN" -R "$GITHUB_REPOSITORY" \ --json workflowName,event,headBranch,conclusion,headSha) ok=$(jq -r --arg w "$GITHUB_WORKFLOW" '.workflowName == $w and .event == "workflow_dispatch" and .headBranch == "main" and .conclusion == "success"' <<<"$run") if [ "$ok" != true ]; then echo "::error::run $PLAN_RUN is not a successful plan run of this workflow on main"; exit 1 fi echo "sha=$(jq -r .headSha <<<"$run")" >> "$GITHUB_OUTPUT" - uses: actions/checkout@v4 with: ref: ${{ steps.planned.outputs.sha }} # Install ob (above) - env: GH_TOKEN: ${{ github.token }} ENVIRONMENT: ${{ inputs.environment }} PLAN_RUN: ${{ inputs.plan_run }} APPROVAL: ${{ inputs.approval }} run: | gh run download "$PLAN_RUN" -n ob-plan printf '%s' "$APPROVAL" > ob-approval.json ob deploy --env "$ENVIRONMENT" \ --plan ob-plan.json --approval ob-approval.jsonFrom a terminal with ob installed, no keys needed:
gh workflow run deploy.yml -f environment=productionrun=$(gh run list -w deploy.yml -L 1 --json databaseId -q '.[0].databaseId')gh run watch "$run"gh run download "$run" -n ob-planob approve --plan ob-plan.json # shows the plan; you confirm itgh workflow run deploy.yml -f environment=production \ -f plan_run="$run" -f approval="$(cat ob-approval.json)"The confirmation is tamper-evident and bound to that one plan, but it is not a
signed identity, and who can deploy still decides who could
approve. The apply job checks that the plan came from a successful run of this
workflow on main, so a run ID from another workflow or a branch is refused.
GitHub reviewers
Section titled “GitHub reviewers”With required reviewers on the GitHub environment, the job waits until one
approves, and ob deploy --yes applies the plan the job computes. Set
policy.requireApproval: false on the Onebox environment so --yes is
accepted. Onebox does not read GitHub’s approvals, so a terminal deploy to
that environment is not gated by GitHub either: give it to GitHub only if every
deploy to it goes through the workflow.
jobs: deploy: runs-on: [self-hosted, deploy] environment: name: ${{ inputs.environment }} # The reviewers still gate the job. ob creates the deployment records, # at the commits it actually ships, so Actions must not add its own. deployment: false steps: - uses: actions/checkout@v4 # Install ob (above) - env: GH_TOKEN: ${{ github.token }} ENVIRONMENT: ${{ inputs.environment }} run: ob deploy --env "$ENVIRONMENT" --yesdeployment: false keeps the reviewers working and stops Actions creating its
own deployment record at the workflow’s commit. GitHub refuses to start a job
that combines it with custom deployment protection rules.
A project whose workloads are built in CI passes the images it resolved, as
--image web=ghcr.io/acme/shop-web:2026.11.3, to ob plan or ob deploy
exactly as it does locally.
What the run records
Section titled “What the run records”- Operator. In GitHub Actions the journal, the lock and the reports name the
account that started the run, such as
vishr@runner-1 (github actions run 42), not the runner’s local user. SetONEBOX_OPERATORto name it yourself, for an agent or a pipeline. - GitHub deployments. With a
githubblock,obreports the deploy withGH_TOKEN. A deployment created with the job’sGITHUB_TOKENdoes not start other workflows, but webhooks and GitHub Apps still receive itsdeployment_statusevents. To start a workflow on those events, giveoba token of its own throughgithub.tokenEnv. - Notifications fire as they do for any deploy.
An interrupted job leaves the deploy where it stopped. Run ob resume or
ob abort from the same runner or any machine with the keys, and the GitHub
deployment is concluded with the outcome.