Shared GitHub Actions CI for the plugin repos of one maintainer. Instead of copying the same workflows into every plugin repo, each repo keeps three small caller files that point here:
check.yml: the repo's own checks, Claude Code plugin validation at a pinned CLI version, test counts and README badges.release.yml: tags a release and publishes a GitHub Release with git-cliff notes, from a pushed release commit, a manual run or a hand-pushed tag, then starts the marketplace repo's update workflow.notify-marketplace.yml: starts the marketplace repo's update workflow again by hand.
There are no releases here: callers use @main, so main must always work. The action pins
(actions/checkout, actions/setup-node, actions/upload-artifact,
actions/download-artifact, actions/create-github-app-token, orhun/git-cliff-action,
softprops/action-gh-release), the Claude Code CLI version, badge-maker (an exact version in
scripts/badges/package.json, with every dependency locked by integrity hash in
scripts/badges/package-lock.json) and the Node version live in this repo and nowhere else. The
scripts have no plugin-specific logic.
Copy these into a plugin repo as .github/workflows/<name>.yml.
check.yml:
name: check
on: [push, pull_request, workflow_dispatch] # workflow_dispatch: release.yml starts it after a manual release
permissions:
contents: read
jobs:
check:
permissions:
contents: write # for the nested badges job; the nested check job lowers it to read
uses: rjstone/plugin-ci/.github/workflows/check.yml@mainEvery caller of check.yml must grant contents: write to the call. GitHub rejects a call
whose nested jobs ask for more than the caller grants, even when the job that asks
(push-badges) is skipped on that run. Every other nested job lowers its own token to
contents: read, and only push-badges uses the write grant.
release.yml:
name: release
on:
push:
branches: [main]
tags: ['v[0-9]+.[0-9]+.[0-9]+']
workflow_dispatch:
inputs:
bump:
description: Which part of the version to raise
type: choice
options: [patch, minor, major]
default: patch
version:
description: Or the exact version to release (X.Y.Z); wins over bump
required: false
type: string
permissions: {}
jobs:
release:
# On a push to main, only a release commit starts a release; other pushes show as skipped.
if: "${{ github.event_name != 'push' || github.ref_type == 'tag' || startsWith(github.event.head_commit.message, 'chore(release): v') }}"
permissions:
contents: write # the release commit, the tag and the GitHub Release
actions: write # to start check.yml on the release commit of a manual run
uses: rjstone/plugin-ci/.github/workflows/release.yml@main
with:
bump: ${{ inputs.bump }}
version: ${{ inputs.version }}
client-id: ${{ vars.MARKETPLACE_APP_CLIENT_ID }} # leave both out if no marketplace lists the plugin
secrets:
private-key: ${{ secrets.MARKETPLACE_APP_PRIVATE_KEY }}notify-marketplace.yml (optional: reports a tag to the marketplace again, by hand):
name: notify-marketplace
on:
workflow_dispatch:
inputs:
tag:
description: Release tag to report (empty = the latest vX.Y.Z tag)
required: false
type: string
permissions:
contents: read
jobs:
notify:
uses: rjstone/plugin-ci/.github/workflows/notify-marketplace.yml@main
with:
tag: ${{ inputs.tag }}
client-id: ${{ vars.MARKETPLACE_APP_CLIENT_ID }}
secrets:
private-key: ${{ secrets.MARKETPLACE_APP_PRIVATE_KEY }}It has no tag trigger: release.yml notifies the marketplace itself, and a second start for the
same tag would only repeat the work.
| Input | Type | Default | Meaning |
|---|---|---|---|
plugin-path |
string | . |
Folder that holds .claude-plugin/plugin.json. |
validate-directory |
boolean | true |
Also validate with the plugin-directory profile. |
plugin-tests |
boolean | false |
Also run claude plugin test on the plugin folder. |
fetch-depth |
number | 1 |
Checkout depth (0 = full history). |
badges |
boolean | true |
Render and push badges on pushes to the default branch (and on a manual run there). |
template-repo |
string | empty | owner/repo of the template the repo was made from; empty = no drift report (see "Template drift"). |
repository |
string | empty | Repository to check out (empty = the caller's). Only this repo's self-test sets it. |
ref |
string | empty | Ref to check out (empty = the caller's). Only this repo's self-test sets it. |
With badges on, a push to the default branch then calls badges.yml (below) with the badge
lines for the run: check (with the GitHub Actions logo), tests, version and license from
the plugin manifest, then the lines scripts/ci.sh appended to $CI_BADGES.
With template-repo set, the check job runs scripts/run-template-drift.sh after validation.
It fetches the maintenance branch of that repository and runs its scripts/template-drift.sh
from the repo root; that script compares the repo's shared files with the template's default
branch and prints one warning per differing file. The template owns the script and the list of
shared files, so plugin repos carry no copy of either.
- In a plugin repo the step never fails the run: a branch that can't be fetched, a missing script and a script that exits non-zero are all warnings.
- In the template itself (the calling repository is
template-repo) the script's exit code is passed on, so the template's own check fails when its list names a path it no longer has. - The step runs code from the template's
maintenancebranch with thecheckjob's read-only token. Only name a template you control.
Renders badge lines and publishes them on the calling repo's orphan branch badges. check.yml
calls it; a repo that runs its own test workflow can call it directly:
badges:
needs: test
if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: write
uses: rjstone/plugin-ci/.github/workflows/badges.yml@main
with:
spec: ${{ needs.test.outputs.badge-spec }}
keep-others: true| Input | Type | Default | Meaning |
|---|---|---|---|
spec |
string (required) | none | Badge lines, one per line: name|label|message|color, with an optional fifth field naming a logo in scripts/badges/logos/. Each becomes <name>.svg. |
keep-others |
boolean | false |
Keep the badges already on the branch that this call does not render. Set it in every caller when several workflows of one repo publish badges. |
The caller decides when to publish: only for pushes or scheduled runs on the default branch, never for pull requests (a fork's pull request must not publish its numbers).
render-badges(tokencontents: read) renders the lines with badge-maker, installed bynpm ci --ignore-scriptsfrom the lockfile inscripts/badges, and uploads the SVG files as the artifactplugin-ci-badges(kept for 1 day).push-badges(tokencontents: write) checks out nothing, fetches no plugin-ci scripts and runs no npm, npx or node: it downloads the artifact, refuses it unless it holds at least one file and every file is a<name>.svg(lowercase letters, digits and hyphens) that starts with<svg, and pushes the files as the single commit of the branch. Withkeep-othersit first carries over the badges already there, and pushes only if the branch has not moved since it read them (three tries).
So third-party npm code never runs in the job that holds the write token.
| Input | Type | Default | Meaning |
|---|---|---|---|
plugin-path |
string | . |
Folder that holds .claude-plugin/plugin.json. |
cliff-config |
string | cliff.toml |
git-cliff configuration file. |
bump |
string | empty | Manual run: patch, minor or major (empty = patch). |
version |
string | empty | Manual run: the exact version (X.Y.Z); wins over bump. |
client-id |
string | empty | Client ID of the GitHub App on the marketplace repo; empty = don't notify. |
marketplace-owner, marketplace-repo |
string | rjstone, plugin-marketplace |
The marketplace repo. |
Secret private-key (needed with client-id): a private key (.pem) generated for the App.
One caller covers three ways to release vX.Y.Z:
| What starts it | What the workflow does |
|---|---|
A commit whose first line is chore(release): vX.Y.Z, pushed to the default branch as the newest commit of the push |
checks it, tags it, publishes |
A manual run (Actions > release > Run workflow) with bump or version |
runs the repo's scripts/release.sh X.Y.Z, pushes the result as the release commit, tags it, publishes, starts check.yml on it |
A vX.Y.Z tag pushed by hand |
checks that it matches the manifest, publishes |
"Publishes" is a GitHub Release with git-cliff's notes for the tag, then a start of the
marketplace's update workflow when client-id is set.
- Release commit checks: the version in the message equals
versionin the manifest, it is above the newest release tag, andCHANGELOG.mdhas a## [X.Y.Z]section. A commit that is already tagged does nothing; a tag of that name on another commit fails the run. - Manual run:
bumpcounts from the newest release tag, or from the manifest's version when that is ahead of the tags. The push of the release commit fails if the branch moved after the run started: run it again. scripts/release.sh X.Y.Z(the manual run needs it; people use it too): the repo's own script that turns the working tree into that release. It sets the version, rebuilds generated files and regenerates the changelog (npx -y git-cliff@<pinned> --tag vX.Y.Z -o CHANGELOG.md). It commits nothing, needs no secrets and must not change files under.github/. By hand:bash scripts/release.sh X.Y.Z, commit everything aschore(release): vX.Y.Z, push; the workflow does the rest.- Tokens: the script and npm tools run in the
planjob under a read-only token, which hands the changes topushas a patch.pushholds the write token and runs only git. - A tag or commit pushed with
GITHUB_TOKENstarts no workflows. That is why this workflow publishes and notifies itself instead of relying on a tag trigger, and why it startscheck.yml(which needs aworkflow_dispatchtrigger) after a manual run. - The caller's job must grant
contents: writeandactions: write. GitHub rejects a call whose nested jobs ask for more than the caller grants.
| Input | Type | Default | Meaning |
|---|---|---|---|
tag |
string | empty | Release tag to report (empty = the latest vX.Y.Z tag). |
client-id |
string (required) | none | Client ID of the GitHub App installed on the marketplace repo. |
marketplace-owner |
string | rjstone |
Owner of the marketplace repo. |
marketplace-repo |
string | plugin-marketplace |
Name of the marketplace repo. |
Secret private-key (required): a private key (.pem) generated for the App. The App needs only
"Actions: Read and write". The workflow checks out nothing and runs no repo code.
check.yml runs bash scripts/ci.sh from the repo root if the file exists. The script:
- holds every check that is the repo's own: tests, generated-file freshness, type check, icon copies, skill version bumps, pins;
- does not run
claude plugin validate: the shared workflow does, at its pinned version; - needs no secrets and gets none (a read-only token);
- works with
CI_BASE_SHAandCI_BADGESunset, so it also runs by hand.
Environment it gets:
CI_BASE_SHA: the pull request base commit, else the commit before the push. It is all zeros on the first push of a branch or tag, and with the defaultfetch-depth: 1the commit it names is usually not in the clone. A script that compares against it must treat a missing or all-zero base as "nothing to compare"; a caller that needs history setsfetch-depth: 0.CI_BADGES: a file the script may append extra badge lines to, onename|label|message|colorper line.
Test counts come from the combined log of scripts/ci.sh and the validation step. Three summary
forms are recognised, every summary in the log is added up, and skipped tests count as neither
passed nor failed:
- node:test (TAP, as printed when output is piped):
# pass Nand# fail N. - unittest:
Ran N tests, thenOKorFAILED (failures=F, errors=E, skipped=S). claude plugin test:N passandN fail.
A called workflow fetches this repo's scripts from its own repository and commit
(job.workflow_repository and job.workflow_sha), so the workflow and its scripts always come
from the same commit. To try a branch of plugin-ci from a plugin repo, change only the ref:
uses: rjstone/plugin-ci/.github/workflows/check.yml@my-branchThis repo's own self-test.yml calls ./.github/workflows/check.yml, so every push here tests
the workflow and the scripts of that commit together. Those two context properties exist on
GitHub.com, not on GitHub Enterprise Server.
bash tests/run.sh
shellcheck scripts/*.sh actions/validate/*.sh tests/*.sh
actionlintThe tests are bash, need no network and use fixture logs and a fixture plugin under
tests/fixtures/.
actions/validate is a composite action for workflows that are not the shared ones and need the
same pinned claude plugin validate: uses: rjstone/plugin-ci/actions/validate@main.
| Input | Default | What it does |
|---|---|---|
plugin-path |
. |
Folder of the plugin, relative to the working directory. |
validate-directory |
true |
Also validate with the plugin-directory profile. |
plugin-tests |
false |
Also run the plugin's unit tests. |
working-directory |
. |
Folder to run in (the repository root, normally). |
The caller must have Node available (run actions/setup-node first), because the script uses npx.