Skip to content

OSAC-3734: add label-gate workflow for merge queue - #204

Merged
omer-vishlitzky merged 2 commits into
osac-project:mainfrom
omer-vishlitzky:feat/OSAC-3734-label-gate
Aug 7, 2026
Merged

OSAC-3734: add label-gate workflow for merge queue#204
omer-vishlitzky merged 2 commits into
osac-project:mainfrom
omer-vishlitzky:feat/OSAC-3734-label-gate

Conversation

@omer-vishlitzky

@omer-vishlitzky omer-vishlitzky commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds two GitHub Actions workflows for the merge queue migration:

1. label-gate.yml — bridge Prow labels to status checks

Merge queue can only gate on status checks, not labels. Prow plugins set labels (lgtm, approved, jira/valid-reference) via OWNERS files. This workflow reads those labels and reports a pass/fail status check that the merge queue can gate on.

  • Triggers on pull_request label events (labeled, unlabeled, synchronize)
  • Checks if all 3 required labels are present
  • Auto-passes on merge_group events (labels were validated on the PR)
  • On rebase/force-push: Prow removes lgtm → label-gate re-triggers → fails until reviewer re-/lgtms

2. auto-queue.yml — automatic queue entry (same UX as Tide)

Automatically enables auto-merge on every non-draft PR from org members. When all required checks pass (E2E + label-gate), the PR enters the merge queue without any manual click.

  • Uses pull_request_target so GITHUB_TOKEN has write permissions for fork PRs (all OSAC PRs come from forks)
  • Safe: never checks out fork code, just calls gh pr merge --auto
  • External contributors excluded (author_association check) — they use manual "Add to merge queue" after ok-to-test

Companion PRs — merge in this order

  1. This PR — must merge first so the status check exists
  2. OSAC-3734: enable merge queue for osac monorepo github-config#180 — enables merge queue, adds label-gate / check-labels to required status checks
  3. OSAC-3734: osac-project: remove Tide merge queries, keep Prow plugins openshift/release#83121 — removes Tide merge queries (keeps all Prow plugins)

Test plan

  • label-gate passes when all 3 labels present, fails when any missing
  • label-gate auto-passes on merge_group events
  • Adding a missing label re-triggers label-gate
  • auto-queue enables auto-merge on new non-draft PRs from org members
  • auto-queue skips draft PRs and external contributors
  • On force-push: Prow removes lgtm, label-gate fails, reviewer must re-/lgtm

🤖 Generated with Claude Code

Reads Prow-set labels (lgtm, approved, jira/valid-reference) and
converts their presence to a status check the merge queue can gate on.

Merge queue can only gate on status checks, not labels. Prow plugins
set labels via OWNERS files — this workflow bridges the gap.

Auto-passes on merge_group events since labels were already validated
on the PR.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: omer-vishlitzky <omer.vishlitzky@gmail.com>
@openshift-ci-robot

openshift-ci-robot commented Aug 7, 2026

Copy link
Copy Markdown

@omer-vishlitzky: This pull request references OSAC-3734 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Adds a label-gate.yml GitHub Actions workflow that bridges Prow labels → merge queue status checks.

Why

GitHub merge queue can only gate on status checks, not labels. Prow plugins set labels (lgtm, approved, jira/valid-reference) via OWNERS files. This workflow reads those labels and reports a pass/fail status check that the merge queue can gate on.

How it works

  1. Prow plugins set labels (unchanged — /lgtm, /approve, jira validation via OWNERS)
  2. This workflow triggers on pull_request label events
  3. Checks if lgtm, approved, and jira/valid-reference are all present
  4. Sets label-gate / check-labels status check to pass or fail
  5. Merge queue gates on this status check (configured in github-config)

On merge_group events, the workflow auto-passes (labels were already validated on the PR).

Companion PRs — merge in this order

  1. This PR — must merge first so the status check exists
  2. OSAC-3734: enable merge queue for osac monorepo github-config#180 — enables merge queue, adds label-gate / check-labels to required status checks
  3. OSAC-3734: osac-project: remove Tide merge queries, keep Prow plugins openshift/release#83121 — removes Tide merge queries (keeps all Prow plugins)

Test plan

  • Workflow runs on PR with all 3 labels present → check passes
  • Workflow fails when any label is missing
  • Workflow auto-passes on merge_group events
  • Adding a missing label (e.g., /lgtm) re-triggers the workflow

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: omer-vishlitzky

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The new label-gate workflow runs for relevant pull request and merge queue events. It validates lgtm, approved, and jira/valid-reference labels. It reports missing labels and fails the check when validation fails.

Changes

Pull request label gate

Layer / File(s) Summary
Workflow triggers and label validation
.github/workflows/label-gate.yml
The workflow runs on pull request and merge-group events with read-only contents access. Merge-group runs pass automatically. Pull requests fail when required labels are missing and report guidance for adding them.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: lgtm

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a label-gate workflow for merge queue integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed The PR adds only label-gate.yml; its literals contain no API keys, tokens, passwords, private keys, credentialed URLs, or long base64/hex strings.
No-Weak-Crypto ✅ Passed The label-gate workflow contains only label validation and echo commands; it has no weak algorithm, custom crypto, or secret/token comparison usage.
No-Injection-Vectors ✅ Passed The workflow uses quoted event data as jq input; its jq filter variable comes only from fixed label literals, with no eval, shell=True, unsafe YAML load, or other listed injection vector.
Container-Privileges ✅ Passed The PR adds only a GitHub Actions workflow; it declares no container or Kubernetes privilege settings, host namespaces, SYS_ADMIN, or root execution.
No-Sensitive-Data-In-Logs ✅ Passed The workflow logs only fixed status text and required label names; it does not print LABELS, credentials, tokens, PII, hostnames, or customer data.
Ai-Attribution ✅ Passed The PR mentions Claude Code and its commit includes an Assisted-by: Claude Code trailer; no Co-Authored-By trailer is present.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/label-gate.yml (2)

11-12: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Restrict merge_group to checks_requested.

merge_group: currently accepts all activity types. GitHub documents checks_requested as the supported activity and recommends an explicit types filter. If another activity is added later, the auto-pass step can report success without checking labels. (docs.github.com)

Proposed trigger change
   merge_group:
+    types: [checks_requested]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/label-gate.yml around lines 11 - 12, Update the
merge_group workflow trigger to explicitly restrict its activity types to
checks_requested, preserving the existing workflow behavior while preventing
unsupported or future activities from invoking the auto-pass path.

20-24: 🔒 Security & Privacy | 🔵 Trivial

Verify SAST and SCA coverage in the required PR pipeline.

This workflow only checks labels. It contains no SAST or SCA step. Confirm that another required workflow provides both checks for main. If no such workflow exists, the PR pipeline lacks code and dependency security scanning.

As per path instructions, include SAST/SCA steps in the pipeline.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/label-gate.yml around lines 20 - 24, Update the required
PR workflow containing the “Check required Prow labels” step to include both
SAST and SCA scanning steps, ensuring they run for pull requests targeting main.
Reuse the repository’s established security scanning actions or commands, and
preserve the existing label validation behavior.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/label-gate.yml:
- Around line 13-15: Add a pull-request-scoped concurrency block to the
check-labels job in label-gate.yml, using the pull request identifier as the
group and enabling cancel-in-progress. Update label evaluation to query the
current pull request labels rather than relying on
github.event.pull_request.labels, so out-of-order events use current state.
- Around line 4-5: Update the permissions configuration in the label-gate
workflow by removing the unused contents: read permission; either set contents
to none or omit the explicit permissions block, while preserving the workflow’s
existing event-data processing.

---

Nitpick comments:
In @.github/workflows/label-gate.yml:
- Around line 11-12: Update the merge_group workflow trigger to explicitly
restrict its activity types to checks_requested, preserving the existing
workflow behavior while preventing unsupported or future activities from
invoking the auto-pass path.
- Around line 20-24: Update the required PR workflow containing the “Check
required Prow labels” step to include both SAST and SCA scanning steps, ensuring
they run for pull requests targeting main. Reuse the repository’s established
security scanning actions or commands, and preserve the existing label
validation behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ab356bf3-6b34-4257-9e2f-37b4689bd0ac

📥 Commits

Reviewing files that changed from the base of the PR and between ac89552 and bd5ba2c.

📒 Files selected for processing (1)
  • .github/workflows/label-gate.yml

Comment on lines +4 to +5
permissions:
contents: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Workflow file:"
cat -n .github/workflows/label-gate.yml

echo
echo "Search for GitHub API usage / contents references in workflow:"
rg -n "contents|pulls/|issues/|repos/|api\.github\.com|curl|gh |jq|github\.event|uses:" .github/workflows/label-gate.yml || true

Repository: osac-project/osac

Length of output: 2067


Remove the unused contents: read permission.

This workflow only reads GitHub event data with github.event and jq; it does not checkout the repository or call the GitHub API. Set contents: none or omit the explicit permission block to keep GITHUB_TOKEN permissions minimal.

Proposed permission change
 permissions:
-  contents: read
+  contents: none
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
contents: read
permissions:
contents: none
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/label-gate.yml around lines 4 - 5, Update the permissions
configuration in the label-gate workflow by removing the unused contents: read
permission; either set contents to none or omit the explicit permissions block,
while preserving the workflow’s existing event-data processing.

Source: Path instructions

Comment on lines +13 to +15
jobs:
check-labels:
runs-on: ubuntu-latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repository files matching label-gate:"
fd -a 'label-gate\.yml$|label-gate\.yaml$' .github/workflows || true

if [ -f .github/workflows/label-gate.yml ]; then
  echo
  echo "File outline/stat:"
  wc -l .github/workflows/label-gate.yml
  echo
  echo "Workflow contents:"
  cat -n .github/workflows/label-gate.yml
fi

echo
echo "All workflow labels and concurrency settings nearby:"
rg -n "label-gate|pull_request|pull_request_target|concurrency|labels|GITHUB_TOKEN|permissions:" .github/workflows || true

Repository: osac-project/osac

Length of output: 28462


Serialize label-gate runs per pull request.

.github/workflows/label-gate.yml triggers on multiple pull_request events and uses github.event.pull_request.labels without a concurrency group. Add a pull-request-scoped concurrency block with cancel-in-progress: true, and compare labels from a current PR query if label delivery can be out of order.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/label-gate.yml around lines 13 - 15, Add a
pull-request-scoped concurrency block to the check-labels job in label-gate.yml,
using the pull request identifier as the group and enabling cancel-in-progress.
Update label evaluation to query the current pull request labels rather than
relying on github.event.pull_request.labels, so out-of-order events use current
state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants