Skip to content

feat(skill): add kbagent-promotion-pipeline skill for source->dest project promotion - #560

Draft
Matovidlo wants to merge 1 commit into
mainfrom
martinvasko-kbagent-promotion-pipeline
Draft

feat(skill): add kbagent-promotion-pipeline skill for source->dest project promotion#560
Matovidlo wants to merge 1 commit into
mainfrom
martinvasko-kbagent-promotion-pipeline

Conversation

@Matovidlo

Copy link
Copy Markdown
Contributor

Summary

  • Adds the kbagent-promotion-pipeline skill (plugins/kbagent/skills/kbagent-promotion-pipeline/): a from-scratch generator (scripts/generate_promotion_pipeline.py, stdlib-only) that scaffolds a GitHub Actions pipeline promoting Keboola configuration changes from a named source project (e.g. dev) to a named destination project (e.g. prod).
  • The generated pipeline is three workflows: kbagent-promote-pull.yml (pulls the source project into a shared directory and opens/updates one PR against main), kbagent-promote-validate.yml (runs sync push --dry-run against the destination project on that PR -- the cross-project diff), and kbagent-promote-push.yml (pushes to the destination project once merged, gated by the prod GitHub Environment).
  • Supports multiple independent pipelines in one repo via a JSON config (one {name, directory, source_stack_url, dest_stack_url} entry per pair) -- the "one GitHub repo covers the whole org" pattern.
  • Every step uses kbagent's KBAGENT_PROJECT_FROM_ENV=1 + --project __env__ env-injection model, so no token ever touches disk.

Why

Follow-up to #402 (kbc->kbagent CI/CD migration). That PR ports an existing kbc-managed repo; this one covers the separate, from-scratch use case of standing up a new dev->prod (or any source->destination) promotion pipeline that didn't exist before, modeled after the pattern in keboola/cli-based-sync-generator but adapted to kbagent's project-alias-per-invocation model rather than that tool's git-branch-bound-to-a-GitHub-Environment mechanic. Kept as a separate PR (rather than folding into #402) since it's a genuinely new capability, not a bugfix, and #402 was deliberately squeezed down in scope during its own review pass.

Change type

Feature — new skill. No source/CLI-command changes, no version bump.

Impact analysis

  • New files only: one skill tree under plugins/kbagent/skills/kbagent-promotion-pipeline/.
  • No changes to src/, no new CLI commands, no public API or behavior change.
  • Fully backwards-compatible.

Test plan

  • Generator smoke-tested against a throwaway git repo in both single-pipeline (CLI flags) and multi-pipeline (--config JSON) modes; verified the rendered --project __env__, KBAGENT_PROJECT_FROM_ENV, per-pipeline secret names, --json placement, and environment: prod gating are all correct against the current CLI's actual flags.
  • Inline sanity assertions (Pipeline.label/secret-name derivation, URL normalization, presence of expected strings in each generated workflow) run cleanly.
  • Local gates pass: ruff check/format, ty check (no new diagnostics), make skill-check (main SKILL.md unchanged), make command-sync-check, make changelog-check, make loc-check (pre-existing warnings only, unrelated to this change).

Deployment

Merge & automatic deploy. No migration.

Rollback plan

Revert of this PR.

…oject promotion

Adds a from-scratch generator (plugins/kbagent/skills/kbagent-promotion-pipeline/)
for a GitHub Actions pipeline that promotes Keboola configs between two
distinct projects (e.g. dev -> prod), for the "one repo covers the whole org"
pattern.

Mechanic (kbagent-native, no git-branching or GH-Environment-per-branch
magic needed): a pull workflow fetches the SOURCE project into a shared
directory and opens one PR against main; a validate workflow runs `sync
push --dry-run` against the DESTINATION project on that PR, showing exactly
what would change there; a push workflow (environment-gated) ships it once
the PR merges. Every step uses KBAGENT_PROJECT_FROM_ENV=1 + --project
__env__, so no token ever touches disk. A single repo can host several
independent pipelines via a JSON config (one entry per source/dest pair).

Generator is stdlib-only, mirrors the kbagent-cicd-migration skill's
structure; verified by generating both single- and multi-pipeline configs
and inline sanity assertions on the rendered YAML.
@Matovidlo

Copy link
Copy Markdown
Contributor Author

@claude review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new kbagent-promotion-pipeline skill under plugins/kbagent/skills/ that guides users through (and programmatically generates) a GitHub Actions–based source → destination promotion flow using kbagent sync with the KBAGENT_PROJECT_FROM_ENV=1 / --project __env__ CI authentication model.

Changes:

  • Introduces a new skill runbook (SKILL.md) describing the pull → validate → push promotion mechanic and required GitHub setup.
  • Adds a stdlib-only generator script that scaffolds three GitHub Actions workflows (pull, validate, push) for one or multiple pipelines.
  • Adds reference docs for env-injection rationale and GitHub secrets/environment setup.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
plugins/kbagent/skills/kbagent-promotion-pipeline/SKILL.md Skill runbook for the promotion pipeline pattern, steps, and guardrails.
plugins/kbagent/skills/kbagent-promotion-pipeline/scripts/generate_promotion_pipeline.py Workflow generator producing pull/validate/push GitHub Actions YAML and a secrets checklist.
plugins/kbagent/skills/kbagent-promotion-pipeline/references/secrets-setup.md Documentation for required secrets and prod environment gating.
plugins/kbagent/skills/kbagent-promotion-pipeline/references/env-injection.md Background on KBAGENT_PROJECT_FROM_ENV / __env__ and why it’s used in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +42
2. **Validate** (`kbagent-promote-validate.yml`, on the PR) runs
`sync push --dry-run --project __env__ --directory <dir>` against the
**destination** project's token, for every pipeline touched by the PR --
this is the cross-project diff: *if this PR merges, here is exactly what
changes in the destination project.* Read this before approving.
Comment on lines +159 to +168
prefix = "kbagent --json " if json_output else "kbagent "
return (
f" - name: {step_name} ({p.name})\n"
" env:\n"
' KBAGENT_PROJECT_FROM_ENV: "1"\n'
f" KBC_TOKEN: ${{{{ secrets.{token_secret} }}}}\n"
f" KBC_STORAGE_API_URL: {stack_url}\n"
" run: |\n"
f" {prefix}sync {command} --project __env__ --directory '{p.directory}'\n"
)
print(f"error: {repo} is not a directory", file=sys.stderr)
return 2

pipelines = _load_pipelines(args)
Comment on lines +85 to +95
if args.config:
data = json.loads(Path(args.config).read_text(encoding="utf-8"))
return [
Pipeline(
name=str(p["name"]),
directory=str(p["directory"]),
source_stack_url=_normalize_url(str(p["source_stack_url"])),
dest_stack_url=_normalize_url(str(p["dest_stack_url"])),
)
for p in data
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants