Skip to content

4.3 github github integration layer

xingguangcuican6666 edited this page May 17, 2026 · 1 revision

GitHub 集成层 / GitHub Integration Layer

Relevant source files

本页面详细介绍了 ABK Manager 与 GitHub API 交互的架构实现,包括身份验证、仓库管理、工作流调度及模块目录获取。

This page details the architectural implementation of ABK Manager's interaction with the GitHub API, covering authentication, repository management, workflow dispatching, and module catalog fetching.


中文

概述 / Overview

GitHub 集成层是 ABK Manager 的核心通信枢纽。它负责将 Android 端的构建请求转换为 GitHub Actions 工作流任务,并实时监控远程构建状态。该层主要由 GitHubRepository 封装业务逻辑,通过 GitHubApiServiceGitHubAuthService 进行 RESTful 调用。

核心组件 / Key Components

1. 身份验证 (OAuth Device Flow)

ABK 采用 GitHub OAuth 设备流(Device Flow),允许用户在不直接输入密码的情况下授权应用访问仓库和工作流权限。

  • 请求设备码 :通过 GitHubAuthService.requestDeviceCode 获取用户验证码。
  • 轮询令牌 :使用 pollToken 持续检查用户是否已在浏览器中完成授权。
  • 作用域 :请求 repoworkflow 权限以确保能触发构建和下载制品。

2. 仓库与 Fork 管理

为了在用户的个人账户中运行构建,应用需要确保存在一个 ABK 的 Fork。

3. 工作流调度与监控

这是应用最复杂的部分,涉及构建的触发、日志获取和制品下载。

4. 外部模块目录获取

应用支持从第三方仓库获取内核模块定义。

数据流图 / Data Flow Diagram

"GitHub 集成层数据流 / GitHub Integration Layer Data Flow"

DeepWiki client-side-rendered block omitted in static export.

Sources: app/src/main/java/com/abk/kernel/data/repository/GitHubRepository.kt#L1-L29 app/src/main/java/com/abk/kernel/data/api/GitHubApiService.kt#L8-L160 app/src/main/java/com/abk/kernel/viewmodel/MainViewModel.kt#L158-L172


English

Overview

The GitHub Integration Layer serves as the central communication hub for ABK Manager. It is responsible for translating build requests from the Android client into GitHub Actions workflow tasks and providing real-time monitoring of remote build statuses. This layer is primarily encapsulated in GitHubRepository, which performs RESTful calls via GitHubApiService and GitHubAuthService.

Core Functionality

1. OAuth Device Flow

ABK utilizes the GitHub OAuth Device Flow, allowing users to authorize the app's access to repositories and workflows without entering passwords directly into the app.

  • Device Code Request : Fetches the user verification code via GitHubAuthService.requestDeviceCode.
  • Token Polling : Uses pollToken to continuously check if the user has completed authorization in their browser.
  • Scopes : Requests repo and workflow scopes to ensure it can trigger builds and download artifacts.

2. Repository & Fork Management

To run builds within the user's personal account, the app ensures a fork of the ABK repository exists.

3. Workflow Dispatch & Monitoring

This is the most complex part of the integration, involving build triggering, log retrieval, and artifact downloading.

4. External Module Catalog Fetching

The app supports fetching kernel module definitions from third-party repositories.

Technical Mapping / Code-Entity Association

"从自然语言到代码实体的映射 / Mapping Natural Language to Code Entities"

功能 / Feature 代码类与方法 / Code Class & Method API 终点 / API Endpoint
设备授权 / Device Auth GitHubAuthService.requestDeviceCode POST /login/device/code
创建 Fork / Create Fork GitHubApiService.forkRepo POST /repos/{o}/{r}/forks
启动构建 / Start Build GitHubApiService.dispatchWorkflow POST .../dispatches
下载制品 / Download Artifact GitHubApiService.downloadArtifact GET .../artifacts/{id}/zip
解析模块 / Parse Module GitHubRepository.parseExternalModuleConf N/A (Internal Logic)

身份验证流程图 / Authentication Flow Diagram

"GitHub OAuth 设备流实现 / GitHub OAuth Device Flow Implementation"

DeepWiki client-side-rendered block omitted in static export.

Sources: app/src/main/java/com/abk/kernel/data/api/GitHubAuthService.kt#L8-L24 app/src/main/java/com/abk/kernel/data/repository/GitHubRepository.kt#L36-L58 app/src/main/java/com/abk/kernel/data/api/NetworkClient.kt#L36-L43

null

Clone this wiki locally