Webhook icon
If icon
Script icon
Search icon
OutputValues icon
Log icon
Comment icon

Check pull requests against your contribution rules automatically

Check every GitHub PR against contribution rules with Kestra. Validates flow files, counts open PRs per author, keeps one updated checklist comment.

Categories
CoreInfrastructure

Contribution programs bring many pull requests, and maintainers spend review time on rules a machine can check. This flow runs on every pull request. It checks each changed flow file against the catalog rules, counts the author's open pull requests against the per-person limit, and posts one checklist comment. The same comment is updated on every push, so the PR never fills with bot messages. Contributors see what to fix before a maintainer looks.

It starts in dry-run mode and only logs the report. Set dry_run to false once you trust it.

This blueprint was created by zkasuran.

How it works

  1. on_pull_request (io.kestra.plugin.core.trigger.Webhook) receives GitHub pull_request events. relevant_event (io.kestra.plugin.core.flow.If) handles opened, reopened, synchronize and ready_for_review, and ignores the rest. Manual runs use the pr_number input.
  2. inspect (io.kestra.plugin.scripts.python.Script) reads the pull request and its changed files from the GitHub API, then checks every changed flows/*.yaml at the PR head:
    • id matches the file name and namespace is set.
    • At least 3 runnable tasks, 1 flow task (If, Switch, Parallel, Loop...) and 1 trigger, counted through nested branches.
    • At least 1 non-core plugin.
    • extend has title, description, metaDescription, tags, ee and demo, the metaDescription is 160 characters or less, and there are 3 tags or fewer from the allowed list.
    • No value that looks like a hardcoded password, token or API key.
  3. author_open_prs (io.kestra.plugin.github.pulls.Search) counts the author's open pull requests across the organization or in this repository only.
  4. report (io.kestra.plugin.core.output.OutputValues) builds a Markdown table per file and a warning when the author is over max_open_prs.
  5. post (io.kestra.plugin.core.flow.If) skips dry runs and closed PRs. comment (io.kestra.plugin.github.issues.Comment) uses updateTag, so it edits its earlier comment instead of adding a new one.

Inputs

  • repository (STRING, default kestra-io/blueprints): the catalog repository.
  • pr_number (INT): the pull request for manual runs.
  • max_open_prs (INT, default 2): open pull requests allowed per author.
  • count_scope (SELECT ORGANIZATION or REPOSITORY, default ORGANIZATION): where open pull requests are counted. Use ORGANIZATION when the limit covers several repositories.
  • dry_run (BOOL, default true): log the report without commenting.

The allowed tags list is the allowed_tags variable. Edit the checks in the inspect script to match your own README.

Prerequisites

  • A Kestra worker that can run Docker containers. The script uses python:3.12-slim.
  • A GitHub webhook on the repository: payload URL https://<kestra>/api/v1/main/executions/webhook/company.team/github-pr-contribution-rules-check/<key>, content type application/json, event "Pull requests".

Secrets

  • GITHUB_TOKEN: a token with read access to pull requests. To post comments it also needs write access to issues and pull requests, for example a fine-grained token or a GitHub App installation token.

Quick start

  1. Add GITHUB_TOKEN and replace the webhook key with a long random value.
  2. Run the flow manually with a pr_number. The report appears in the logs and nothing is posted.
  3. Add the GitHub webhook. Every new or updated pull request gets a report in the logs.
  4. Set dry_run to false to post the checklist comment.

Expected outputs

  • outputs.inspect.vars.failed_checks: the number of failed file checks.
  • outputs.author_open_prs.size: the author's open pull requests in the chosen scope.
  • outputs.report.values.markdown: the checklist, also posted as the PR comment.

How to extend

  • Add a label such as needs-changes with an io.kestra.plugin.core.http.Request call when checks fail.
  • Validate each changed flow against your Kestra instance with POST /api/v1/main/flows/validate.
  • Add rules for apps/ and dashboards/ files.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.