kgaut / github_api
Integrates your Drupal site into gitlab using the Github API.
Package info
Type:drupal-module
pkg:composer/kgaut/github_api
1.0.x-dev
2026-07-02 14:33 UTC
Requires
- php: >=7.4
- knplabs/github-api: *
This package is auto-updated.
Last update: 2026-07-02 16:28:31 UTC
README
A Drupal module that integrates your Drupal site with GitHub through the KnpLabs GitHub API client. It provides a thin, injectable service around the client so you can list repositories, read and create issues, and manage sub-issues from your own Drupal code.
Requirements
- Drupal
^8 || ^9 || ^10 || ^11 - PHP
>= 7.4 knplabs/github-api(installed automatically via Composer)
Installation
Install the module with Composer so its dependencies are pulled in:
composer require kgaut/github_api drush en github_api
Configuration
- Go to Configuration → Web services → Github API settings
(
/admin/config/services/github_api, routegithub_api.settings_form). - Generate a personal access token with the
reposcope. The settings form provides a pre-filled link to GitHub's token creation page. - Paste the token into the Token field.
- Optionally fill in My GitHub username — your GitHub login, used to auto-assign tickets (for example when creating TMA issues).
- Save the configuration.
Usage
The module exposes a github_api.api service (class
Drupal\github_api\Api). Inject it into your own services or load it from the
container:
/** @var \Drupal\github_api\Api $api */ $api = \Drupal::service('github_api.api'); // List repositories accessible to the authenticated user. $repositories = $api->listProjects(); // Read the issues of a repository. $issues = $api->listIssues('kgaut', 'github_api'); // Show a single issue. $issue = $api->showIssue('kgaut', 'github_api', 1); // Create an issue, optionally assigning it to someone. $created = $api->createIssue('kgaut', 'github_api', 'Bug title', 'Description', [ $api->getMyUsername(), ]); // Attach an existing issue as a sub-issue of a parent issue. $api->addSubIssue('kgaut', 'github_api', $parentIssueNumber, $created['id']);
Available methods
| Method | Description |
|---|---|
listProjects() |
Lists the repositories of the authenticated user. |
showProject($project_id) |
Returns information about a repository by its id. |
listIssues($owner, $repo) |
Lists all issues of a repository. |
showIssue($owner, $repo, $issue_id) |
Returns a single issue. |
createIssue($owner, $repo, $title, ...) |
Creates an issue, with optional body and assignees. |
addSubIssue($owner, $repo, $parent, $id) |
Attaches an issue as a sub-issue of a parent issue. |
getMyUsername() |
Returns the GitHub username configured in settings. |
License
GPL-2.0-or-later. See the composer.json file for details.