Skip to content

OSAC-3734: add auto-queue workflow for merge queue - #216

Merged
omer-vishlitzky merged 1 commit into
osac-project:mainfrom
omer-vishlitzky:feat/OSAC-3734-auto-queue-v2
Aug 9, 2026
Merged

OSAC-3734: add auto-queue workflow for merge queue#216
omer-vishlitzky merged 1 commit into
osac-project:mainfrom
omer-vishlitzky:feat/OSAC-3734-auto-queue-v2

Conversation

@omer-vishlitzky

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

Copy link
Copy Markdown
Contributor

Summary

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 — same UX as Tide.

How it works

  1. PR opened (or marked ready for review) → workflow runs
  2. Checks: not draft, author is org member/collaborator/owner
  3. Runs gh pr merge --auto --rebase → enables auto-merge on the PR
  4. Later, when E2E + label-gate all pass → PR auto-enters merge queue
  5. Queue tests against latest main → merges

Token

Uses MERGE_QUEUE_TOKEN repo secret (fine-grained PAT or GitHub App token) with pull-requests:write + contents:write permissions scoped to osac-project/osac. GITHUB_TOKEN may not have permission to enable auto-merge when merge queue is required.

Security

  • Uses pull_request_target so the token works for fork PRs (all OSAC PRs come from forks)
  • Safe: workflow never checks out or executes fork code — just calls gh pr merge --auto
  • External contributors excluded via author_association check

Prerequisites

  • Create MERGE_QUEUE_TOKEN repo secret with a PAT (scoped to osac-project/osac, permissions: pull-requests:write + contents:write)

Part of OSAC-3734 (merge queue migration)

Test plan

  • Non-draft PR from org member → auto-merge enabled
  • Draft PR → skipped
  • External contributor PR → skipped
  • PR with auto-merge + all checks passing → enters merge queue automatically

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated automated merge queue authentication and permission handling.

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 for fork PR compatibility (all OSAC PRs come
from forks). Safe because the workflow never checks out fork code.

Uses MERGE_QUEUE_TOKEN secret (PAT or GitHub App token) since
GITHUB_TOKEN may not have permission to enable auto-merge with merge
queue enabled.

External contributors (non-org members) are excluded — they use
manual "Add to merge queue" after ok-to-test authorization.

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

openshift-ci-robot commented Aug 9, 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

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 — same UX as Tide.

How it works

  1. PR opened (or marked ready for review) → workflow runs
  2. Checks: not draft, author is org member/collaborator/owner
  3. Runs gh pr merge --auto --rebase → enables auto-merge on the PR
  4. Later, when E2E + label-gate all pass → PR auto-enters merge queue
  5. Queue tests against latest main → merges

Token

Uses MERGE_QUEUE_TOKEN repo secret (fine-grained PAT or GitHub App token) with pull-requests:write + contents:write permissions scoped to osac-project/osac. GITHUB_TOKEN may not have permission to enable auto-merge when merge queue is required.

Security

  • Uses pull_request_target so the token works for fork PRs (all OSAC PRs come from forks)
  • Safe: workflow never checks out or executes fork code — just calls gh pr merge --auto
  • External contributors excluded via author_association check

Prerequisites

  • Create MERGE_QUEUE_TOKEN repo secret with a PAT (scoped to osac-project/osac, permissions: pull-requests:write + contents:write)

Part of OSAC-3734 (merge queue migration)

Test plan

  • Non-draft PR from org member → auto-merge enabled
  • Draft PR → skipped
  • External contributor PR → skipped
  • PR with auto-merge + all checks passing → enters merge queue automatically

🤖 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 requested review from trewest and tzvatot August 9, 2026 11:40
@openshift-ci

openshift-ci Bot commented Aug 9, 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 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The auto-queue workflow now authenticates pull request merges with MERGE_QUEUE_TOKEN and removes explicit write permission declarations.

Changes

Merge queue authentication

Layer / File(s) Summary
Dedicated merge queue token
.github/workflows/auto-queue.yml
The gh pr merge command uses secrets.MERGE_QUEUE_TOKEN instead of github.token. The workflow no longer declares explicit contents and pull-requests write permissions.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested labels: approved, jira/valid-reference

🚥 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 identifies the addition of an auto-queue workflow for the merge queue, which matches the pull request objectives.
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 only credential reference is GH_TOKEN: ${{ secrets.MERGE_QUEUE_TOKEN }}; the diff contains no literal token, password, key, credential, embedded-auth URL, or private-key material.
No-Weak-Crypto ✅ Passed The patch only replaces GITHUB_TOKEN with secrets.MERGE_QUEUE_TOKEN and removes permissions; it contains no weak algorithm, custom crypto, or secret comparison.
No-Injection-Vectors ✅ Passed The only changed file alters permissions and GH_TOKEN. Its existing command interpolates a numeric PR number and trusted repository name; no flagged injection construct uses untrusted input.
Container-Privileges ✅ Passed The changed workflow uses ubuntu-latest and runs gh pr merge; it declares no container or Kubernetes privilege settings, host namespaces, SYS_ADMIN, root user, or allowPrivilegeEscalation: true.
No-Sensitive-Data-In-Logs ✅ Passed The diff only assigns MERGE_QUEUE_TOKEN to GH_TOKEN and runs gh pr merge; it has no echo, printf, tracing, or other logging of secret or sensitive values.
Ai-Attribution ✅ Passed The PR mentions Claude Code, and its only PR commit includes the valid Assisted-by: Claude Code <noreply@anthropic.com> trailer with no AI Co-Authored-By trailer.
✨ 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.

@omer-vishlitzky
omer-vishlitzky merged commit bd04c8c into osac-project:main Aug 9, 2026
19 of 23 checks passed

@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: 1

🤖 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/auto-queue.yml:
- Around line 18-19: Update the top-level workflow configuration in
auto-queue.yml by adding an explicit permissions: {} block. Keep the existing
MERGE_QUEUE_TOKEN usage in the gh pr merge step unchanged, ensuring the
pull_request_target workflow does not inherit repository or organization default
GITHUB_TOKEN permissions.
🪄 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: 115fbebb-4e86-4de7-82d3-f678b260d78d

📥 Commits

Reviewing files that changed from the base of the PR and between 09c0432 and e0aa82c.

📒 Files selected for processing (1)
  • .github/workflows/auto-queue.yml

Comment on lines +18 to 19
GH_TOKEN: ${{ secrets.MERGE_QUEUE_TOKEN }}
run: gh pr merge ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --auto --rebase

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:

#!/usr/bin/env bash
set -euo pipefail

workflow=".github/workflows/auto-queue.yml"

if ! rg -q '^permissions:\s*\{\}\s*$' "$workflow"; then
  echo "Missing explicit permissions: {} in $workflow" >&2
  exit 1
fi

rg -n 'permissions:|GH_TOKEN:|github\.token|MERGE_QUEUE_TOKEN' "$workflow"

Repository: osac-project/osac

Length of output: 224


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
workflow=".github/workflows/auto-queue.yml"
printf '--- file lines ---\n'
cat -n "$workflow" | sed -n '1,220p'
printf '\n--- relevant permissions/env/token searches ---\n'
rg -n '^\s*permissions:|GH_TOKEN:|GITHUB_TOKEN|github\.token|MERGE_QUEUE_TOKEN|gh pr merge' "$workflow" || true
printf '\n--- referenced PR workflow snippets: lines 1-80 ---\n'
sed -n '1,80p' "$workflow"

Repository: osac-project/osac

Length of output: 246


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
workflow=".github/workflows/auto-queue.yml"
printf '%s\n' '--- file lines ---'
cat -n "$workflow" | sed -n '1,220p'
printf '%s\n' ''
printf '%s\n' '--- relevant permissions/env/token searches ---'
rg -n 'permissions:|GH_TOKEN:|GITHUB_TOKEN|github\.token|MERGE_QUEUE_TOKEN|gh pr merge' "$workflow" || true
printf '%s\n' ''
printf '%s\n' '--- referenced PR workflow snippets: lines 1-80 ---'
sed -n '1,80p' "$workflow"

Repository: osac-project/osac

Length of output: 1689


🌐 Web query:

GitHub Actions workflows top-level GITHUB_TOKEN permissions default write contents pull_request_target

💡 Result:

In GitHub Actions, the GITHUB_TOKEN is a short-lived authentication token generated for each workflow job [1][2]. Its default permissions are governed by repository or organization settings [3][1]. Default Permissions By default, GitHub repositories may be configured to grant the GITHUB_TOKEN read and write access for all scopes, or a more restricted "read contents" default [3][1]. Because these defaults can be permissive, GitHub security documentation strongly recommends adopting the principle of least privilege by explicitly configuring permissions within the workflow file [4][5]. The pull_request_target Event The pull_request_target trigger is inherently different from the standard pull_request event [6][7]. While the standard pull_request event runs using the code from the pull request's merge commit and is restricted to a read-only GITHUB_TOKEN (without secret access) to prevent abuse [6][8], the pull_request_target event runs in the context of the base repository's default branch [6][7]. Because the pull_request_target event executes code trusted by the base repository, it is granted access to repository secrets and a GITHUB_TOKEN that defaults to read/write permissions [6][7]. If a workflow triggered by pull_request_target checks out code from an untrusted fork without careful handling, it creates a significant security risk by exposing these elevated privileges to potentially malicious code [6][7]. Best Practices for Hardening To secure your workflows, you should: 1. Explicitly set permissions: Use the permissions key at the workflow or job level to restrict the GITHUB_TOKEN to only the necessary scopes [1][4]. It is a recommended security practice to set the default to empty (permissions: {}) and then grant only required access [9]. 2. Limit GITHUB_TOKEN scope: Use the principle of least privilege to ensure the token has only the minimum access required to perform its task [4][5]. 3. Handle pull_request_target with caution: When using pull_request_target, ensure that any code checked out from a fork is handled safely and that secrets or high-privilege tokens are not inadvertently exposed [6][7].

Citations:


Set an explicit token policy for this workflow.

This pull_request_target workflow only uses MERGE_QUEUE_TOKEN in the step that runs gh pr merge; it does not need GITHUB_TOKEN write access. Add a top-level permissions: {} block so repository or organization default permissions cannot grant unused write scopes.

Proposed fix
+permissions: {}
+
 jobs:
   enable-auto-merge:
🤖 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/auto-queue.yml around lines 18 - 19, Update the top-level
workflow configuration in auto-queue.yml by adding an explicit permissions: {}
block. Keep the existing MERGE_QUEUE_TOKEN usage in the gh pr merge step
unchanged, ensuring the pull_request_target workflow does not inherit repository
or organization default GITHUB_TOKEN permissions.

Source: Path instructions

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