Skip to content

Commit

Permalink
Use GitHub App token instead of personal one
Browse files Browse the repository at this point in the history
  • Loading branch information
maccelf committed Apr 18, 2024
1 parent ea237f0 commit e2ec2f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions alws/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Settings(BaseSettings):
sentry_traces_sample_rate: float = 0.2

github_integration_enabled: bool = False
github_app_id: Optional[str] = None
path_to_github_app_pem: Optional[str] = None
github_installation_id: Optional[str] = None
github_token: Optional[str] = None
github_organization_name: str = 'AlmaLinux'
github_project_number: Optional[int] = None
Expand Down
22 changes: 19 additions & 3 deletions alws/utils/github_integration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,26 @@ async def get_github_client() -> IntegrationsGHGraphQLClient:
github_client = None
github_token = settings.github_token
if not github_token:
raise ValueError(
'Config for GitHub integration is incomplete, '
'please check the settings'
app_id = settings.github_app_id
pem = settings.path_to_github_app_pem
installation_id = settings.github_installation_id
if not all([
app_id,
pem,
installation_id,
]):
raise ValueError(
'Config for GitHub integration is incomplete, '
'please check the settings'
)
github_token = (
await IntegrationsGHGraphQLClient.generate_token_for_gh_app(
gh_app_id=app_id,
path_to_gh_app_pem=pem,
installation_id=installation_id,
)
)

github_client = IntegrationsGHGraphQLClient(
github_token,
settings.github_organization_name,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ uvicorn==0.29.0
websockets==12.0
git+https://github.com/AlmaLinux/immudb-wrapper.git@0.1.2#egg=immudb_wrapper
git+https://github.com/AlmaLinux/errata2osv.git@0.0.3#egg=errata2osv
git+https://github.com/AlmaLinux/albs-github-integration.git@0.3.0#egg=albs_github
git+https://github.com/AlmaLinux/albs-github-integration.git@0.4.0#egg=albs_github

0 comments on commit e2ec2f1

Please sign in to comment.