https://github.com/remal-gradle-plugins/github-repository-info
A Gradle plugin that provides functionality to access GitHub repository information directly from the build environment.
https://github.com/remal-gradle-plugins/github-repository-info
github gradle gradle-plugin plugin
Last synced: about 2 months ago
JSON representation
A Gradle plugin that provides functionality to access GitHub repository information directly from the build environment.
- Host: GitHub
- URL: https://github.com/remal-gradle-plugins/github-repository-info
- Owner: remal-gradle-plugins
- License: mit
- Created: 2025-10-19T20:54:26.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-04-29T13:28:08.000Z (2 months ago)
- Last Synced: 2026-04-29T15:34:01.068Z (2 months ago)
- Topics: github, gradle, gradle-plugin, plugin
- Language: Java
- Homepage:
- Size: 463 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
**Tested on Java LTS versions from 11 to 26.**
**Tested on Gradle versions from 8.0 to 9.5.0.**
# `name.remal.github-repository-info` plugin
[](https://docs.gradle.org/current/userguide/configuration_cache.html)
```groovy
plugins {
id 'name.remal.github-repository-info' version '1.0.2'
}
```
This Gradle plugin that provides functionality to access GitHub repository information
directly from the build environment.
It can be useful for projects that need to load some GitHub repository information dynamically.
This is how you can add Maven POM license using this plugin:
```groovy
apply plugin: 'maven-publish'
publishing.publications.withType(MavenPublication).configureEach {
pom {
licenses {
license {
name = githubRepositoryInfo.licenseFile.map { it.license.name }
url = githubRepositoryInfo.licenseFile.map { it.htmlUrl }
}
}
}
}
```
All the information is loaded lazily and cached during the build.
## `githubRepositoryInfo` extension
This plugin creates `githubRepositoryInfo` extension that provides the following
[read-only](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/HasConfigurableValue.html#disallowChanges())
[properties](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html).
* `githubRepositoryInfo.repository` - provides information about the repository itself ([example](https://api.github.com/repos/remal-gradle-plugins/github-repository-info))
* `githubRepositoryInfo.licenseFile` - provides information about the repository license file ([example](https://api.github.com/repos/remal-gradle-plugins/github-repository-info/license))
* `githubRepositoryInfo.contributors` - provides a list of repository contributors ([example](https://api.github.com/repos/remal-gradle-plugins/github-repository-info/contributors))
* `githubRepositoryInfo.languages` - provides a map of programming languages used in the repository with their byte size ([example](https://api.github.com/repos/remal-gradle-plugins/github-repository-info/languages))
All these properties load data lazily
and **cache the result** in `./build/tmp/.cache/name.remal.github-repository-info` directory.
To get updated data, you need to delete this cache directory.
Also, you can get or configure general GitHub connection settings via the following `Property` properties.
These properties are automatically configured from GitHub Actions environment variables or remote URL in the `.git/config` file.
* `githubRepositoryInfo.githubApiUrl` - GitHub API URL (default: `https://api.github.com`).
* `githubRepositoryInfo.repositoryFullName` - repository full name (e.g., `owner/repo`).
* `githubRepositoryInfo.githubApiToken` - GitHub API authentication token.
See the [Configuration](#configuration) section.
* `githubRepositoryInfo.githubServerUrl` - GitHub URL (default: `https://github.com`).
Not used by this plugin directly, but can be useful for constructing links.
## Configuration
**For public GitHub repositories, the plugin should work without any additional configuration.**
However, for **private** repositories or to **increase the rate limits**, you need to provide a GitHub token.
To configure a GitHub token for GitHub Actions,
set `GITHUB_TOKEN` environment variable for your GitHub Actions job:
```yaml
- name: Run Gradle build
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: ./gradlew build
```
`GITHUB_ACTIONS_TOKEN` environment variable can be used instead of `GITHUB_TOKEN`.
To configure a GitHub token for local development,
add `name.remal.github-repository-info.api-token` property to your `~/.gradle/gradle.properties` file:
```properties
name.remal.github-repository-info.api-token =
```
This file is in [the Gradle User Home directory](https://docs.gradle.org/current/userguide/directory_layout.html#dir:gradle_user_home),
so it won't be committed.