Publish snapshots with GitHub Actions
Publish an installable Kubb Studio snapshot from GitHub Actions so reviewers can compare generated files against the base branch and previous runs. Store KUBB_TOKEN as an Actions repository secret.
Prerequisites
- A repository with a working
kubb.config.tson Kubb 5.6.2 or later. Follow Installation if you have not set up Kubb. - A Kubb Studio organization and an organization CI API key, stored as
KUBB_TOKENin a secret only trusted pipelines can read. Snapshot installation uses a separate registry key. Create both in Studio under Settings > Developer > Tokens, with type CI forKUBB_TOKENand type Registry for installs.
Configure the workflow
Add this workflow:
name: Kubb snapshot
on:
pull_request:
# `closed` deletes the pull request's Studio agent. GitHub leaves it out by default.
types: [opened, synchronize, reopened, closed]
# A snapshot of main is what pull requests compare with.
push:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: kubb-labs/action@v0
with:
token: ${{ secrets.KUBB_TOKEN }}pull-requests: write allows snapshot comments. contents: write lets the action open an initialization pull request when the repository has no Kubb config. For that pull request, turn on Allow GitHub Actions to create and approve pull requests under Settings > Actions > General.
Review the pull request comment for generated changes against the base branch and the previous run.
To pass the tarball URL to another step, give the action an id: snapshot, then read ${{ steps.snapshot.outputs.tarball-url }}. See the action reference for all inputs, outputs, and runtime behavior.
Review and install the result
Open the snapshot in Studio to review generated changes. To consume the generated package, follow Install the snapshot.