Create annotations in GitHub Actions
To report issues as annotations to a GitHub Actions build, the GitHub Actions addin needs to be imported. For this example the JetBrains InspectCode issue provider is additionally used for reading issues:
build.cake
#addin nuget:?package=Cake.Issues&version=5.2.0
#addin nuget:?package=Cake.Issues.InspectCode&version=5.2.0
#addin nuget:?package=Cake.Issues.PullRequests&version=5.2.0
#addin nuget:?package=Cake.Issues.PullRequests.GitHubActions&version=5.2.0
Note
In addition to the GitHub Actions pull request system the Cake.Issues
and Cake.Issues.PullRequests
core addins need to be added.
Build.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
<PackageReference Include="Cake.Frosting.Issues.InspectCode" Version="5.2.0" />
<PackageReference Include="Cake.Frosting.Issues.PullRequests.GitHubActions" Version="5.2.0" />
</ItemGroup>
</Project>
This example shows how to report issues as annotations to GitHubActions build using the GitHubActionsBuilds alias:
Program.cs
using Cake.Common.IO;
using Cake.Frosting;
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.Run(args);
}
}
[TaskName("Report-IssuesToAppVeyor")]
public sealed class ReportIssuesToAppVeyorTask : FrostingTask<FrostingContext>
{
public override void Run(FrostingContext context)
{
var repoRootPath = context.MakeAbsolute(context.Directory("./"));
context.ReportIssuesToPullRequest(
context.InspectCodeIssuesFromFilePath(
@"C:\build\inspectcode.log"),
context.GitHubActionsBuilds(),
repoRootPath);
}
}
The output will show up in the build log grouped by issue provider / run:
Additionally the issues show up as annotations:
Having issues available as annotations also means that they will be shown in pull requests on the related file / position: