-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add workaround for Docker always printing logs as errors
- Loading branch information
Showing
1 changed file
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} |