What it does
- Pull in CI: a GitHub Actions workflow runs
stoaken export --checkon pull requests, so a build fails when committed token files are behind the live release. - Push on publish: a Stoaken webhook sent as a GitHub repository dispatch starts the same workflow when a release is published. It runs
stoaken exportand opens a pull request on thestoaken/tokensbranch.
Before you start
- A Stoaken API key (Settings > API keys) and a
stoaken.config.jsonwith anexportslist (see /docs/cli). - Brand Admin on the Brand (webhooks are part of the Team plan).
- A fine-grained GitHub personal access token for this one repository with Contents: read and write. GitHub's dispatch endpoint needs that permission (docs).
- In the repository's Settings > Actions > General, allow GitHub Actions to create pull requests.
Setup
- Add the secret
STOAKEN_TOKEN(your API key) under Settings > Secrets and variables > Actions. - Commit
.github/workflows/stoaken-tokens.yml(the template below). - In Stoaken, go to Settings > Webhooks and choose Add a webhook:
- Send as: GitHub repository dispatch
- Address:
https://api.github.com/repos/OWNER/REPO/dispatches - Access token: the fine-grained token. It's stored encrypted and never shown again.
- Events: Release published only.
name: Stoaken tokens
on:
pull_request:
workflow_dispatch:
repository_dispatch:
types: [stoaken-release-published]
permissions:
contents: write
pull-requests: write
jobs:
check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npx --yes stoaken@latest export --check
env:
STOAKEN_TOKEN: ${{ secrets.STOAKEN_TOKEN }}
update:
if: github.event_name != 'pull_request'
# … export, commit to stoaken/tokens, `gh pr create` (full file: src/lib/integrations/pipelines.ts)For your own workflows, the composite action in integrations/github-action/ wraps the same command: uses: ./integrations/github-action with token: ${{ secrets.STOAKEN_TOKEN }} and, optionally, check: 'true'.
Configuration
- The dispatch's
event_typeisstoaken-release-published(andstoaken-pingfor Send test, which the workflow ignores). - The
client_payloadhastype,delivery_id,release_id,theme_id,brand_id,version,is_breaking,changesandtest. GitHub allows at most 10 top-level keys. Read them asgithub.event.client_payload.version. - Requests send
Authorization: Bearer <token>,Accept: application/vnd.github+jsonandX-GitHub-Api-Version: 2022-11-28. Stoaken only sends the token tohttps://api.github.com/repos/…/dispatches, and the database refuses any other address for this format.
Try it
- On the webhook, choose Send test. GitHub should answer 204, and no workflow runs, because
stoaken-pingisn't listed. - In the webhook lab, choose Send a sample with Release published. A workflow run appears under Actions and opens a pull request if the export changed anything.
- Open any pull request and look for the
checkjob.
Troubleshooting
- 401/403: the token has expired, doesn't cover this repository, or lacks Contents: write.
- 404: the owner or repository in the address is wrong, or the token can't see a private repository.
- 422: GitHub refused the body. Check the format is GitHub repository dispatch, not Stoaken event.
- The check doesn't run on the bot's pull request: GitHub doesn't start workflows from pushes made with
GITHUB_TOKEN. Re-run it by hand, or push with a separate token. stoaken exporterrors are explained in /docs/cli.
Limits
- No GitHub App or OAuth: you manage the token, and it can expire.
- One repository per webhook. A Brand has at most 10 webhooks.
- Failed deliveries retry for about a day (/docs/webhooks).