Skip to content

CNTRLPLANE-3641: ci: replace COMMUNITY_FORK_TOKEN PAT with GitHub App token - #8776

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
bryan-cox:add-new-gha-jobs
Jun 18, 2026
Merged

CNTRLPLANE-3641: ci: replace COMMUNITY_FORK_TOKEN PAT with GitHub App token#8776
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
bryan-cox:add-new-gha-jobs

Conversation

@bryan-cox

@bryan-cox bryan-cox commented Jun 18, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Adds two new Claude-powered GHA workflows (/restructure-commits and /rebase), extracts a reusable workflow to eliminate duplication, and replaces the long-lived COMMUNITY_FORK_TOKEN PAT with short-lived GitHub App tokens.

New workflows:

  • /restructure-commits — reorganizes PR commits by HyperShift component
  • /rebase — rebases the PR branch onto latest main and force pushes

Reusable workflow (reusable-claude-on-pr.yaml):

  • Extracts the common setup shared by all three Claude-on-PR workflows (token handling, checkout, GCP auth, Claude install, tool deps) into a single reusable workflow
  • Each caller workflow is ~25 lines — just the trigger condition and Claude prompt
  • Adding a new Claude-powered PR command is now trivial: copy a caller and change the inputs

Security improvements:

  • Replaces COMMUNITY_FORK_TOKEN PAT with short-lived tokens from the hypershift-jira-solve-ci GitHub App via actions/create-github-app-token (SHA-pinned)
  • Pushes to community fork PRs are now attributed to hypershift-jira-solve-ci[bot] instead of a personal account
  • Fixed template injection in token selection step (PR repo name passed via env var)

Bug fixes:

  • Added "Move GCP credentials out of workspace" step to prevent verify-git-clean hook failures (same fix as CNTRLPLANE-3640)
  • Added explicit "force push without asking for confirmation" to Claude prompts to prevent interactive prompt hangs in CI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-3641

Special notes for your reviewer:

  • JIRA_SOLVE_CI_APP_ID and JIRA_SOLVE_CI_PRIVATE_KEY secrets have been added to repo settings
  • The hypershift-jira-solve-ci app is already installed on hypershift-community with write access
  • issue_comment workflows run from the default branch (main), so new workflows can't be tested on this PR
  • The COMMUNITY_FORK_TOKEN secret can be removed from repo settings after this merges and is verified working

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 18, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 18, 2026

Copy link
Copy Markdown

@bryan-cox: This pull request references CNTRLPLANE-3641 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:

What this PR does / why we need it:

Replaces the long-lived COMMUNITY_FORK_TOKEN PAT with short-lived tokens generated from the hypershift-jira-solve-ci GitHub App for all three Claude-powered GHA workflows:

  • address-review-comments.yaml
  • restructure-commits.yaml
  • rebase.yaml

This also adds the new restructure-commits and rebase workflows, and fixes the template injection issue in address-review-comments.yaml (PR repo name now passed via env var instead of direct interpolation).

Why: The PAT belongs to a team member's personal account. Using a GitHub App token instead:

  • Attributes pushes to hypershift-jira-solve-ci[bot] instead of a personal account
  • Generates short-lived tokens (1 hour expiry) instead of long-lived credentials
  • Removes dependency on a specific person's account
  • Better security posture

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-3641

Special notes for your reviewer:

  • The JIRA_SOLVE_CI_APP_ID and JIRA_SOLVE_CI_PRIVATE_KEY secrets have been added to the openshift/hypershift repo settings
  • The hypershift-jira-solve-ci app is already installed on the hypershift-community org with write access
  • issue_comment workflows run from the default branch (main), so new workflows can't be tested on this PR
  • The COMMUNITY_FORK_TOKEN secret can be removed from repo settings after this merges and is verified working

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new reusable GitHub Actions workflow (reusable-claude-on-pr.yaml) is introduced to consolidate PR handling and Claude execution logic. It defines inputs for command name, status message, Claude prompt, max turns, and allowed tools; fetches PR metadata; conditionally generates a GitHub App token for the hypershift-community/hypershift repository; checks out the PR head; authenticates to GCP via Workload Identity Federation; installs Claude and dependencies; and executes Claude with the provided configuration. Three existing workflows (address-review-comments.yaml, rebase.yaml, restructure-commits.yaml) are refactored to remove their inline step implementations and instead invoke the reusable workflow with command-specific parameters, while inheriting secrets.

Sequence Diagram

sequenceDiagram
  participant Caller as Calling Workflow
  participant Reusable as reusable-claude-on-pr.yaml
  participant GitHub as GitHub API
  participant GCP as GCP
  participant Claude as Claude CLI
  
  Caller->>Reusable: Invoke with command-name, prompt, max-turns, allowed-tools
  Reusable->>GitHub: Post status comment with message and run link
  Reusable->>GitHub: Fetch PR head ref and repository
  Reusable->>GitHub: Conditionally create GitHub App token
  Reusable->>GitHub: Checkout PR head using selected token
  Reusable->>GCP: Authenticate via OIDC/WIF
  Reusable->>Claude: Install Claude Code and dependencies
  Reusable->>Claude: Install required plugins
  Reusable->>Claude: Execute claude with prompt and configuration
  Claude-->>Reusable: Return execution result
  Reusable-->>Caller: Complete job
Loading

Possibly related PRs

  • openshift/hypershift#8770: Updates the same rebase.yaml and restructure-commits.yaml workflows' authentication and refactoring logic, directly overlapping with this PR's consolidation effort.
  • openshift/hypershift#8771: Updates the restructure-commits Claude prompt to instruct pushing with git push --force-with-lease without confirmation, the same prompt change present in this PR.

Suggested reviewers

  • cblecker
  • jparrill

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Stable And Deterministic Test Names ❌ Error Found unstable Ginkgo test name in test/envtest/generator.go:230: It(fmt.Sprintf("should install all CRDs for feature set %q", featureSet)...) uses dynamic 'featureSet' variable instead of static s... Replace fmt.Sprintf with dynamic featureSet with a static test name like "should install all CRDs for a feature set" and move dynamic values to test body/assertions only.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing COMMUNITY_FORK_TOKEN PAT with GitHub App token across multiple CI workflows.
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.
Test Structure And Quality ✅ Passed This PR modifies only GitHub Actions workflow YAML files (.github/workflows/), not Ginkgo test code. The check for "Test Structure and Quality" is designed for Go test files and is not applicable t...
Topology-Aware Scheduling Compatibility ✅ Passed This PR modifies only GitHub Actions workflows (.github/workflows/*.yaml), which are CI/CD automation files unrelated to Kubernetes deployment manifests or controllers. The check explicitly applies...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add any Ginkgo e2e tests; it only modifies GitHub Actions workflow YAML files. The check for IPv6/disconnected network compatibility is not applicable.
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or unsafe secret comparisons found. PR uses standard GitHub Actions token generation and...
Container-Privileges ✅ Passed PR only modifies GitHub Actions workflow files (.github/workflows/), not K8s/container manifests. Container-privileges check is not applicable to CI workflow configurations.
No-Sensitive-Data-In-Logs ✅ Passed No logging of sensitive data found. Secrets are properly handled: GitHub automatically masks secret values in logs, tokens/credentials are never echoed or printed, GCP credentials are moved out of...
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 18, 2026
@openshift-ci
openshift-ci Bot requested review from Nirshal and sjenning June 18, 2026 14:55
@bryan-cox

Copy link
Copy Markdown
Member Author

/area ai
/area ci-tooling

@openshift-ci openshift-ci Bot added area/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. area/ci-tooling Indicates the PR includes changes for CI or tooling and removed do-not-merge/needs-area labels Jun 18, 2026
@bryan-cox
bryan-cox force-pushed the add-new-gha-jobs branch 2 times, most recently from 3b125a0 to 2531ed1 Compare June 18, 2026 14:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/address-review-comments.yaml:
- Around line 55-63: The actions/create-github-app-token action is referenced
using a tag (v2) instead of being pinned to a full commit SHA, which violates
the CI/CD security policy. Replace the `uses` field in the Generate community
fork token step from `actions/create-github-app-token@v2` to
`actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349` to
pin it to the specific commit SHA.

In @.github/workflows/rebase.yaml:
- Around line 55-63: The actions/create-github-app-token action in the "Generate
community fork token" step is referenced by tag (v2) instead of a pinned full
commit SHA, which is a security best practice. Replace the `@v2` tag reference in
the uses field with the full commit SHA of that action version to ensure the
exact version is always used and prevent unexpected changes.

In @.github/workflows/restructure-commits.yaml:
- Around line 55-63: The `actions/create-github-app-token` action is referenced
using the tag `@v2` instead of a pinned commit SHA. Replace the `@v2` tag in the
`uses` line of the `app-token` step with the full commit SHA for the stable
version of this action to follow security best practices and ensure consistent
behavior across workflow runs.
🪄 Autofix (Beta)

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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 641e9282-5ed6-406b-b167-9a91450d9eb8

📥 Commits

Reviewing files that changed from the base of the PR and between e841911 and 73acc9b.

📒 Files selected for processing (3)
  • .github/workflows/address-review-comments.yaml
  • .github/workflows/rebase.yaml
  • .github/workflows/restructure-commits.yaml

Comment thread .github/workflows/address-review-comments.yaml Outdated
Comment thread .github/workflows/rebase.yaml Outdated
Comment thread .github/workflows/restructure-commits.yaml Outdated
@bryan-cox

Copy link
Copy Markdown
Member Author

/verified later @bryan-cox

@openshift-ci-robot openshift-ci-robot added verified-later verified Signifies that the PR passed pre-merge verification criteria labels Jun 18, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: This PR has been marked to be verified later by @bryan-cox.

Details

In response to this:

/verified later @bryan-cox

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.

Add two new GitHub Actions workflows triggered by PR comments:
- /restructure-commits: invokes the repo's restructure-commits
  command via Claude to reorganize branch commits by component
- /rebase: uses Claude to rebase the PR onto latest main, resolve
  any conflicts, and force push

Both follow the same pattern as the address-review-comments workflow
with concurrency grouping, fork token handling, and GCP WIF auth.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot removed verified Signifies that the PR passed pre-merge verification criteria verified-later labels Jun 18, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 18, 2026

Copy link
Copy Markdown

@bryan-cox: This pull request references CNTRLPLANE-3641 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:

What this PR does / why we need it:

Adds two new Claude-powered GHA workflows (/restructure-commits and /rebase) and replaces the long-lived COMMUNITY_FORK_TOKEN PAT with short-lived tokens generated from the hypershift-jira-solve-ci GitHub App across all three Claude workflows:

  • address-review-comments.yaml
  • restructure-commits.yaml (new)
  • rebase.yaml (new)

Changes:

  • New workflows: /restructure-commits reorganizes PR commits by HyperShift component; /rebase rebases the PR branch onto latest main
  • App token: Uses actions/create-github-app-token (SHA-pinned) to mint short-lived tokens for community fork PRs instead of a personal PAT
  • GCP credentials: Added "Move GCP credentials out of workspace" step to new workflows to prevent verify-git-clean hook failures (same fix as CNTRLPLANE-3640)
  • Template injection fix: address-review-comments.yaml now passes PR repo name via env var instead of direct ${{ }} interpolation in bash
  • CI force-push: Both new workflows include explicit "force push without asking for confirmation" in the Claude prompt to avoid interactive prompts in CI

Why replace the PAT:

  • Attributes pushes to hypershift-jira-solve-ci[bot] instead of a personal account
  • Generates short-lived tokens (1 hour expiry) instead of long-lived credentials
  • Removes dependency on a specific person's account
  • Better security posture

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-3641

Special notes for your reviewer:

  • JIRA_SOLVE_CI_APP_ID and JIRA_SOLVE_CI_PRIVATE_KEY secrets have been added to repo settings
  • The hypershift-jira-solve-ci app is already installed on hypershift-community with write access
  • issue_comment workflows run from the default branch (main), so new workflows can't be tested on this PR
  • The COMMUNITY_FORK_TOKEN secret can be removed from repo settings after this merges and is verified working

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • New Features

  • Added a reusable CI workflow to run Claude against pull requests with configurable command name, status text, prompt content, max turns, and allowed tools.

  • Chores

  • Refactored the address review, rebase, and restructure-commits comment-triggered workflows to delegate execution to the new reusable workflow.

  • Centralized PR ref handling, repository checkout, Claude Code/tool installation, and cloud authentication for consistent behavior.

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.

@bryan-cox

Copy link
Copy Markdown
Member Author

/verified later @bryan-cox

@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: This PR has been marked to be verified later by @bryan-cox.

Details

In response to this:

/verified later @bryan-cox

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-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 18, 2026
@Nirshal

Nirshal commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification

No second-stage tests were triggered for this PR.

This can happen when:

  • The changed files don't match any pipeline_run_if_changed patterns
  • All files match pipeline_skip_if_only_changed patterns
  • No pipeline-controlled jobs are defined for the main branch

Use /test ? to see all available tests.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
.github/workflows/reusable-claude-on-pr.yaml (2)

98-101: 💤 Low value

Consider adding integrity verification for the install script.

The curl | bash pattern executes remote code without verification. While this is a first-party Anthropic script over HTTPS, adding a checksum verification step would provide defense in depth against supply chain attacks.

 - name: Install Claude Code
   run: |
-    curl -fsSL https://claude.ai/install.sh | bash
+    curl -fsSL https://claude.ai/install.sh -o /tmp/install.sh
+    # Optionally verify checksum here if Anthropic publishes one
+    bash /tmp/install.sh
     echo "$HOME/.local/bin" >> $GITHUB_PATH
🤖 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/reusable-claude-on-pr.yaml around lines 98 - 101, The
"Install Claude Code" step executes a remote script directly via curl piped to
bash without any integrity verification. Modify this step to download the
install script to a temporary file, verify its checksum against a known good
value (such as SHA256), and only proceed with execution if the checksum matches.
This adds a verification layer against potential supply chain attacks on the
remote script download.

65-73: 💤 Low value

GitHub App token inherits full installation permissions.

The static analysis tool correctly notes that the generated token receives all permissions configured on the hypershift-jira-solve-ci GitHub App installation. This is acceptable given the PR's goal of replacing a long-lived PAT, but verify the app is configured with only the minimum permissions needed (contents:write, pull-requests:write).

🤖 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/reusable-claude-on-pr.yaml around lines 65 - 73, The
GitHub App token generated by the actions/create-github-app-token action in the
"Generate community fork token" step will inherit all permissions configured on
the hypershift-jira-solve-ci GitHub App installation. Verify that this GitHub
App is configured with only the minimum required permissions of contents:write
and pull-requests:write. If the app currently has additional permissions beyond
these, remove them to adhere to the principle of least privilege for the token
used in this workflow.

Source: Linters/SAST tools

🤖 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.

Nitpick comments:
In @.github/workflows/reusable-claude-on-pr.yaml:
- Around line 98-101: The "Install Claude Code" step executes a remote script
directly via curl piped to bash without any integrity verification. Modify this
step to download the install script to a temporary file, verify its checksum
against a known good value (such as SHA256), and only proceed with execution if
the checksum matches. This adds a verification layer against potential supply
chain attacks on the remote script download.
- Around line 65-73: The GitHub App token generated by the
actions/create-github-app-token action in the "Generate community fork token"
step will inherit all permissions configured on the hypershift-jira-solve-ci
GitHub App installation. Verify that this GitHub App is configured with only the
minimum required permissions of contents:write and pull-requests:write. If the
app currently has additional permissions beyond these, remove them to adhere to
the principle of least privilege for the token used in this workflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4dd77916-f04c-47cf-82bd-789406d48927

📥 Commits

Reviewing files that changed from the base of the PR and between 2531ed1 and 512b78a.

📒 Files selected for processing (4)
  • .github/workflows/address-review-comments.yaml
  • .github/workflows/rebase.yaml
  • .github/workflows/restructure-commits.yaml
  • .github/workflows/reusable-claude-on-pr.yaml

@openshift-merge-bot
openshift-merge-bot Bot merged commit eeae009 into openshift:main Jun 18, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. area/ci-tooling Indicates the PR includes changes for CI or tooling jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria verified-later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants