Automate approving Konflux bot PRs for the given repository by adding /lgtm and /approve
Automates approval of Konflux bot PRs by adding /lgtm and /approve comments when all CI checks pass.
/plugin marketplace add openshift-eng/ai-helpers/plugin install utils@ai-helpers<target-repository>utils:auto-approve-konflux-prs
/utils:auto-approve-konflux-prs <target-repository>
The command automates the approval of open PRs created by the red-hat-konflux[bot] for the given repository.
It filters all open PRs from the given repository, checks whether the PR already has /lgtm and /approve comments, verifies that all required checks (CI jobs or other mandatory checks) have passed, and if any labels/comments are missing and all checks succeed, posts /lgtm and /approve comments to trigger approval.
This ensures that PRs are only auto-approved if all required checks succeed and the author is red-hat-konflux[bot], reducing the risk of approving failing or unauthorized changes.
OWNER/REPO format.
The command executes the following workflow:
The command only processes PRs authored by red-hat-konflux[bot]. If a PR from any other author is encountered, it reports an error such as below:
⚠️ Only PRs from red-hat-konflux[bot] can be automatically processed
and exits.
Fetch all open PRs authored by red-hat-konflux[bot] for the specified repository:
gh pr list --repo <target-repository> --author app/red-hat-konflux --state open --json number,title,baseRefName,labels
gh pr view <PR_NUMBER> --repo <target-repository> --json statusCheckRollup,labels
⚠️ Skipping PR #<PR_NUMBER>: CI checks not all passed
Inspect labels:
Add missing labels via comments:
Log each action:
✅ Added /lgtm and/or /approve to PR #<PR_NUMBER>: <PR_TITLE> (merge into <MERGE_BRANCH>)
red-hat-konflux[bot] in a repository:/utils:auto-approve-konflux-prs openshift/multiarch-tuning-operator
Output:
Processing 3 open Konflux PRs...
[1/3] PR #84 - chore(deps): update konflux references (merge into main)
✅ Added /lgtm and /approve (all CI passed)
[2/3] PR #83 - chore(deps): update konflux references (merge into v1.x)
⚠️ Skipping: CI checks not all passed
[3/3] PR #82 - chore(deps): update konflux references (merge into fbc)
✅ Added /lgtm (already had /approve, all CI passed)
Summary:
✅ Processed 2 PRs successfully, 1 skipped due to CI failures
GitHub CLI (gh): Must be installed and authenticated
brew install gh (macOS) or see GitHub CLI docsgh auth logingh auth statusAccess to GitHub Repositories: Must have read access to repos where PRs are located
red-hat-konflux[bot]: Reports error and exits.gh auth login.app/red-hat-konflux.