Ashlar.Bricks.GitHub
0.4.0
See the version list below for details.
dotnet add package Ashlar.Bricks.GitHub --version 0.4.0
NuGet\Install-Package Ashlar.Bricks.GitHub -Version 0.4.0
<PackageReference Include="Ashlar.Bricks.GitHub" Version="0.4.0" />
<PackageVersion Include="Ashlar.Bricks.GitHub" Version="0.4.0" />
<PackageReference Include="Ashlar.Bricks.GitHub" />
paket add Ashlar.Bricks.GitHub --version 0.4.0
#r "nuget: Ashlar.Bricks.GitHub, 0.4.0"
#:package Ashlar.Bricks.GitHub@0.4.0
#addin nuget:?package=Ashlar.Bricks.GitHub&version=0.4.0
#tool nuget:?package=Ashlar.Bricks.GitHub&version=0.4.0
Ashlar.Bricks.GitHub
GitHub integration bricks for Ashlar - analyze PRs, check CI status, and work with GitHub data.
Bricks
PrStatusBrick
Analyzes GitHub Pull Request status including reviews, checks, and merge blockers.
Inputs:
prUrl(string, required): GitHub Pull Request URLgithubToken(string, optional): GitHub Personal Access Token for higher rate limits
Outputs:
state(string): PR state (open, closed, merged)mergeable(boolean): Whether PR is mergeableblockers(string[]): List of merge blockerschecks(object): CI check status summaryreviews(object): Review status summary
Example:
var input = new BrickInput();
input.Set("prUrl", "https://github.com/owner/repo/pull/123");
var output = await prStatusBrick.ExecuteAsync(input, ImplementationType.Deterministic, context);
var blockers = output.Get<List<string>>("blockers");
Console.WriteLine($"Blockers: {string.Join(", ", blockers)}");
CiStatusBrick
Analyzes GitHub Actions CI/CD workflow runs and check status for a commit or branch.
Inputs:
owner(string, required): Repository ownerrepo(string, required): Repository nameref(string, required): Git reference (branch, tag, or SHA)githubToken(string, optional): GitHub Personal Access Token for higher rate limits
Outputs:
status(string): Overall CI status (success, failure, pending, skipped)totalRuns(int): Total workflow runssuccessCount(int): Number of successful runsfailureCount(int): Number of failed runspendingCount(int): Number of pending runsruns(object[]): Detailed workflow run informationchecks(object[]): Check run details
Example:
var input = new BrickInput();
input.Set("owner", "IanFrelinger");
input.Set("repo", "Ashlar");
input.Set("ref", "master");
var output = await ciStatusBrick.ExecuteAsync(input, ImplementationType.Deterministic, context);
var status = output.Get<string>("status");
var failureCount = output.Get<int>("failureCount");
Console.WriteLine($"CI Status: {status}, Failures: {failureCount}");
GitHubBlockersBrick
Answers "what is blocking this pull request or release?". Each blocker comes with a link to its evidence, and anything that could not be read is listed as an unknown with the reason, never read as "passed".
Inputs:
url(string, required):https://github.com/<owner>/<repo>/pull/<n>orhttps://github.com/<owner>/<repo>/releases/tag/<tag>. Any other host is refused withArgumentExceptionbefore a request is made.githubToken(string, optional)
Outputs:
verdict(string):blocked,ready,unknown(no blocker found, but something that could hide one was not read),mergedorclosedblockers(object[]):reasonandevidence(a URL: the check run, the review, the pull request, the tag list)unknowns(object[]):whatandwhynotes(object[]): non-blocking observations, such as a failing check that is not requiredevidence(string[]): every URL the answer relies onanswer(string): the whole answer as Markdown
Check-run names, commit-status contexts and descriptions, reviewer logins, branch and tag names come from GitHub,
and a fork's workflow or any integration with status access chooses some of them. Each is quoted as one inline code
span in blockers, notes and answer (one line, at most 100 characters, a backtick becomes '), and an evidence
URL from GitHub is kept only when it is an absolute http(s) URL. So the text arrives as data, not as headings,
links, images or instructions to whatever reads the answer.
What it checks. For a pull request: draft state, merge conflicts, a branch behind a base that requires up-to-date branches, reviewers whose latest review requests changes, required approvals, and failing, pending or never-reported required checks (check runs and commit statuses). For a release: the tag exists, a published (not draft) release exists for it, and CI on the tagged commit.
Known limits.
- Branch protection's own endpoints need admin rights. Without them, the brick reads the same requirements from
sources that need none: the protection summary on
GET /repos/{o}/{r}/branches/{base}, the active rulesets onGET /repos/{o}/{r}/rules/branches/{base}, and GraphQL'sisRequiredper check andreviewDecisionfor the pull request. A failing check none of them requires is a note, not a blocker; a required check with no run is a blocker. - GraphQL needs a token. Read anonymously, GitHub's review decision is not available, so an approval rule that only classic branch protection states stays an unknown (a ruleset's approval count is still read).
- Only if both public required-check lists fail to read does GitHub's
mergeable_statedecide whether a failing check blocks:clean,unstableandhas_hooksmean GitHub would allow the merge, so failures are notes; otherwise every failing or pending check is listed as a blocker. - A
blockedstate nothing else explains (for example a rule type the brick does not read) is reported as a blocker naming that gap. - Draft releases are found only among the 30 newest releases, and only with a token that has push access.
Network access
Every request goes to api.github.com through the Ashlar egress guard (EgressHttp.Wrap, inventory row EG-HTTP-08
in docs/EgressInventory.md), so a deployment profile that refuses external egress refuses these bricks too, with
EgressRefusedException.
Installation
Ashlar.Bricks.GitHub ships from the first release after 0.3.0; 0.3.0 on nuget.org does not contain it.
Pin it at the same version as the other Ashlar.* packages:
<PackageReference Include="Ashlar.Bricks.GitHub" Version="$(AshlarConsumerPackageVersion)" />
The bricks live in the Ashlar.Bricks.GitHub namespace.
Authentication
GitHub API has rate limits:
- Unauthenticated: 60 requests/hour
- Authenticated: 5000 requests/hour
Provide a githubToken input for higher rate limits:
input.Set("githubToken", Environment.GetEnvironmentVariable("GITHUB_TOKEN"));
Dependencies
- Octokit - Official GitHub API client for .NET
- Ashlar.Core.Domain
- Ashlar.Abstractions (the egress guard)
Consumer-Driven Design
This package was created based on real consumer needs identified during PR Blocker Assistant validation. It demonstrates the TryGet() pattern added after Ashlar 0.3.0:
// Optional parameter handling with TryGet
input.TryGet<string>("githubToken", out var token);
var client = GitHubClientFactory.Create(token); // internal: anonymous when the token is null or empty
Future Additions
Potential bricks for future releases:
IssueAnalyzerBrick: GitHub issue analysis and classificationReleaseCheckerBrick: Changelog generation (release blockers areGitHubBlockersBrick)CodeReviewAssistantBrick: Automated code review assistanceRepoMetricsBrick: Repository health metrics and statistics
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ashlar.Abstractions (>= 0.4.0)
- Ashlar.Core.Domain (>= 0.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Octokit (>= 13.0.1)
-
net8.0
- Ashlar.Abstractions (>= 0.4.0)
- Ashlar.Core.Domain (>= 0.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Octokit (>= 13.0.1)
- System.Text.Encodings.Web (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.