Skip to content

Commit

Permalink
ci: Add workaround for Docker always printing logs as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnatamo committed Jul 27, 2024
1 parent a81950c commit 12a9ea3
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .build/Build.Docker.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
using Nuke.Common;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.Docker;

using Serilog;

using static Nuke.Common.Tools.Docker.DockerTasks;

partial class Build : NukeBuild
{
private string DockerTag => $"ghcr.io/maxnatamo/fetcharr:{GitVersion.SemVer}";
private string DockerImage => $"ghcr.io/maxnatamo/fetcharr";

private string DockerTag => GitVersion.SemVer;

private string DockerImageTag => $"{DockerImage}:{DockerTag}";

Target BuildImage => _ => _
.DependsOn(Test)
.DependsOn(Format)
.Executes(() =>
DockerBuild(x => x
DockerBuildxBuild(x => x
.SetPath(".")
.SetFile("Dockerfile")
.SetTag(this.DockerTag)
.SetTag(this.DockerImageTag)
.AddCacheFrom("type=gha")
.AddCacheTo("type=gha,mode=max")
.AddLabel("org.opencontainers.image.source=https://github.com/maxnatamo/fetcharr")
.AddLabel("org.opencontainers.image.url=https://github.com/maxnatamo/fetcharr")
.AddLabel("org.opencontainers.image.description=Automatically sync Plex watchlist to your Sonarr and Radarr instances.")
.AddLabel("org.opencontainers.image.licenses=MIT")));
.AddLabel("org.opencontainers.image.licenses=MIT")
.SetProcessLogger((outputType, output) =>
{
// Workaround for all Docker messages being logged as errors.
// Source: https://github.com/nuke-build/nuke/issues/1201
if (outputType == OutputType.Std)
{
Log.Error(output);
}
else
{
Log.Information(output);
}
})));

Target PushImage => _ => _
.DependsOn(BuildImage)
.Requires(() => this.GithubToken)
.Executes(() =>
DockerImagePush(x => x
.SetName(this.DockerTag)));
.SetName(this.DockerImageTag)));
}

0 comments on commit 12a9ea3

Please sign in to comment.