From d89fb4725592760d7e1c186495fab8abc0d21e10 Mon Sep 17 00:00:00 2001 From: Tomas David Date: Wed, 27 May 2026 16:57:05 +0200 Subject: [PATCH 1/2] OCPERT-368: Replace GitHub token with Github app for ERT dashboard rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- tools/auto_release_test_dashboard.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/auto_release_test_dashboard.py b/tools/auto_release_test_dashboard.py index 192a24b851c0..f883f9735ea1 100644 --- a/tools/auto_release_test_dashboard.py +++ b/tools/auto_release_test_dashboard.py @@ -3,7 +3,8 @@ import pandas as pd import streamlit as st -from github import Github, Auth + +from oar.core.github_app import GitHubApp # Define the github access variables repository_owner = 'openshift' @@ -11,15 +12,16 @@ directory_path = '_releases' branch_name = 'record' -# Read the GitHub token from a system environment variable -github_token = os.environ.get('GITHUB_TOKEN') -if not github_token: - st.warning("Oops, ENV VAR GITHUB_TOKEN NOT FOUND") +# Read the GitHub App credentials from environment variables +github_app_id = os.environ.get('GITHUB_APP_WRITER_ID') +github_app_private_key = os.environ.get('GITHUB_APP_WRITER_PRIVATE_KEY') +if not github_app_id or not github_app_private_key: + st.warning("Oops, ENV VAR GITHUB_APP_WRITER_ID or GITHUB_APP_WRITER_PRIVATE_KEY NOT FOUND") st.stop() - -# Create a GitHub instance with the token -gh = Github(auth=Auth.Token(github_token)) +# Create a GitHub instance with the App installation token +gh = GitHubApp(github_app_id, github_app_private_key).client_for_repo( + repository_owner, repository_name) # Get the repository object repo = gh.get_repo(f'{repository_owner}/{repository_name}') From 767d90e10f1afa0c015c744f3b54e635dd1af935 Mon Sep 17 00:00:00 2001 From: Tomas David Date: Thu, 28 May 2026 11:49:46 +0200 Subject: [PATCH 2/2] Fix error handling rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- tools/auto_release_test_dashboard.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/auto_release_test_dashboard.py b/tools/auto_release_test_dashboard.py index f883f9735ea1..c65740bfab61 100644 --- a/tools/auto_release_test_dashboard.py +++ b/tools/auto_release_test_dashboard.py @@ -1,4 +1,5 @@ import json +import logging import os import pandas as pd @@ -6,6 +7,8 @@ from oar.core.github_app import GitHubApp +logger = logging.getLogger(__name__) + # Define the github access variables repository_owner = 'openshift' repository_name = 'release-tests' @@ -20,8 +23,17 @@ st.stop() # Create a GitHub instance with the App installation token -gh = GitHubApp(github_app_id, github_app_private_key).client_for_repo( - repository_owner, repository_name) +try: + gh = GitHubApp(github_app_id, github_app_private_key).client_for_repo( + repository_owner, repository_name) +except Exception: + logger.exception("Failed to initialize GitHub App client") + st.error( + "Failed to initialize GitHub App client. " + "Please check `GITHUB_APP_WRITER_ID` and `GITHUB_APP_WRITER_PRIVATE_KEY` " + "and verify the app is installed on `openshift/release-tests`." + ) + st.stop() # Get the repository object repo = gh.get_repo(f'{repository_owner}/{repository_name}')