-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
85 lines (75 loc) · 3.37 KB
/
build.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Setup(context => new BuildData(
context.HasArgument("preview"),
MakeAbsolute(Directory("./artifacts")),
MakeAbsolute(File("./src/BRI.TestWeb/BRI.TestWeb.csproj")),
MakeAbsolute(Directory("./src/BRI.TestWeb/layout")),
System.Environment.GetEnvironmentVariable("AZURE_CONTAINER_REGISTRY")
));
Task("Clean")
.Does<BuildData>(
static (context, data) => context.CleanDirectories(data.DirectoryPathsToClean)
);
Task("Inventory-Registry")
.IsDependentOn("Clean")
.Does<BuildData>(
static (context, data) => context.DotNetTool(
"tool",
new DotNetToolSettings {
ArgumentCustomization = args => args
.Append("run")
.Append("--")
.Append("bri")
.Append("inventory")
.AppendQuotedSecret(data.AzureContainerRegistry)
.AppendQuoted(data.InputPath.FullPath),
WorkingDirectory = data.ArtifactsPath
}
)
);
Task("Prepare-Statiq-Web")
.IsDependentOn("Inventory-Registry")
.Does<BuildData>(
static (context, data) => context.CopyDirectory(
data.LayoutPath,
data.StatiqInputPath
)
);
Task("Generate-Statiq-Web")
.IsDependentOn("Prepare-Statiq-Web")
.Does<BuildData>(
static (context, data) => context.DotNetRun(
data.ProjectPath.FullPath,
new DotNetRunSettings {
Configuration = "Release",
WorkingDirectory = data.ArtifactsPath,
ArgumentCustomization = args => args
.Append(data.Preview ? "-- preview --virtual-dir WCOM.Bicep" : "--")
.AppendSwitchQuoted("--root", data.ArtifactsPath.FullPath)
.AppendSwitchQuoted("--input", data.StatiqInputPath.FullPath)
.AppendSwitchQuoted("--output", data.OutputPath.FullPath)
}
)
);
Task("Default")
.IsDependentOn("Generate-Statiq-Web");
Task("GitHub-Actions")
.IsDependentOn("Default");
RunTarget(Argument("target", "Default"));
public record BuildData(
bool Preview,
DirectoryPath ArtifactsPath,
FilePath ProjectPath,
DirectoryPath LayoutPath,
string AzureContainerRegistry
)
{
private const string Input = "input";
public DirectoryPath InputPath { get; } = ArtifactsPath.Combine(Input);
public DirectoryPath StatiqInputPath => InputPath; //{ get; } = ArtifactsPath.Combine("input").Combine(AzureContainerRegistry);
public DirectoryPath OutputPath { get; } = ArtifactsPath.Combine("output");
public DirectoryPath[] DirectoryPathsToClean { get; } = new []{
ArtifactsPath,
ArtifactsPath.Combine(Input),
ArtifactsPath.Combine("output")
};
}