Shared GitHub configuration and reusable workflows for the Kyverno organization.
Reusable workflows live in .github/workflows/ and are called from consumer repositories via uses: kyverno/.github/.github/workflows/<name>.yml@main.
Finds open, non-draft pull requests whose branches have fallen behind their base branch and triggers GitHub's built-in branch-update mechanism for each one.
How it works
- Fetches all open non-draft PRs via the REST API.
- Re-fetches each PR individually to get a reliable
mergeable_state(the bulk endpoint returns"unknown"for most PRs). - Calls
PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branchfor every PR withmergeable_state == "behind". - Per-PR failures are non-fatal — the job logs and continues. The job exits non-zero only if unexpected errors occur.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
base_branch |
No | repo default branch | Only update PRs targeting this branch. |
Secrets
| Secret | Required | Description |
|---|---|---|
GH_TOKEN |
No | Token with contents:write and pull-requests:write. Falls back to the built-in github.token. |
Usage — minimal caller workflow
name: PR Branch Auto-Updater
on:
schedule:
- cron: "39 */1 * * *"
workflow_dispatch:
permissions: {}
concurrency:
group: pr-branch-updater
cancel-in-progress: false
jobs:
update:
uses: kyverno/.github/.github/workflows/pr-branch-updater.yml@main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}To restrict updates to a specific base branch, pass the optional input:
with:
base_branch: mainThe shell script logic is extracted from the workflow into scripts/ and covered by bats unit tests in tests/. A fake gh CLI stub is injected via PATH so tests run with no GitHub credentials and no network access.
Run locally:
# Install bats (once)
brew install bats-core # macOS
sudo apt-get install bats # Ubuntu/Debian
# Run all tests from the repo root
bats tests/update-pr-branches.batsCI runs shellcheck (linting) and bats (unit tests) automatically on every push or PR that touches scripts/ or tests/ — see .github/workflows/test.yml.
- Add the workflow file to
.github/workflows/usingon: workflow_call. - Document it in this README under Reusable Workflows.
- Add a thin caller wrapper to each consumer repository.
.github/
workflows/
pr-branch-updater.yml # Reusable: update behind PR branches
test.yml # CI: shellcheck + bats on every scripts/ / tests/ change
scripts/
update-pr-branches.sh # Standalone bash implementation (called by the workflow)
tests/
update-pr-branches.bats # Bats unit tests with a fake gh stub
profile/
README.md # GitHub org profile page (kyverno.io)