OTA-646: Add GitHub App authentication support to stabilization bot - #10082
OTA-646: Add GitHub App authentication support to stabilization bot#10082shahsahil264 wants to merge 4 commits into
Conversation
Add --github-app-id and --github-app-private-key-file flags as an alternative to --github-token for authenticating with GitHub. This enables the stabilization bot to run as a GitHub App instead of a regular user account, which is required for Prow's trusted_apps config to work (it checks for the [bot] suffix). Backwards compatible — existing --github-token / GITHUB_TOKEN continues to work. When both are provided, GitHub App auth takes precedence. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sahil Shah <sahshah@redhat.com>
|
@shahsahil264: This pull request references OTA-646 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 story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shahsahil264 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
- Validate github_app_id and github_app_private_key together to avoid falling through to github.Github(None) when only one is provided - Use integration.get_access_token() public API instead of private attribute access via _Github__requester._Requester__auth.token - Add push_token param to sanitize() to redact app installation tokens in error messages - Rename shadowed 'owner' variable to 'upstream_owner' / 'push_owner' Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sahil Shah <sahshah@redhat.com>
- Sanitize push tokens in error messages: promote() now catches push exceptions and redacts both github_token and access_token before re-raising, so app installation tokens don't leak to logs/Slack - Single token creation: use get_access_token() and github.Github() instead of get_github_for_installation() + get_access_token() which created two separate tokens per promote() call - Validate private key file exists before reading, with clear error Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sahil Shah <sahshah@redhat.com>
- Move int() cast to argparse type=int per Trevor's suggestion - Remove os.path.exists check — let open() raise naturally Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sahil Shah <sahshah@redhat.com>
|
@shahsahil264: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Adds GitHub App authentication as an alternative to PAT-based auth in
hack/stabilization-changes.py. This is the code change needed to migrateopenshift-ota-botfrom a regular GitHub user account to a GitHub App, which fixes the Prowtrusted_appsissue (Prow requires the[bot]suffix that only GitHub Apps have).Changes
--github-app-idand--github-app-private-key-file(withGITHUB_APP_IDandGITHUB_APP_PRIVATE_KEY_FILEenv var fallbacks)AppAuth+GithubIntegrationfor API calls andx-access-token:<installation_token>for git push--github-token/GITHUB_TOKENcontinues to workTesting
openshift-ota-bot-dev, App ID: 4368317)x-access-token+ PR creation via APIopenshift-ota-bot-dev[bot](the[bot]suffix Prow needs)Remaining work (separate tickets)
openshift-engorgopenshift/cincinnati-graph-datatrusted_appsworks with[bot]suffixBug
https://redhat.atlassian.net/browse/OTA-646