@@ -73,37 +73,51 @@ let private publishZip _ =
7373 ]
7474 zip " docs-builder"
7575 zip " docs-assembler"
76+
77+ let private prNumber () =
78+ match Environment.environVarOrNone " GITHUB_REF_NAME" with
79+ | None -> None
80+ | Some s when s.EndsWith " /merge" -> Some ( s.Split( '/' ) |> Seq.head)
81+ | _ -> None
82+
83+ let private imageTags () =
84+ let pr = prNumber()
85+ let exitCode = exec {
86+ validExitCode ( fun _ -> true )
87+ exit_ code_ of " git" " describe" " --tags" " --exact-match" " HEAD"
88+ }
89+ match ( exitCode, pr) with
90+ | 0 , _ -> " edge;latest"
91+ | _, None -> " edge"
92+ | _, Some pr -> $" ci-%s {pr}"
93+
94+ let private runLocalContainer _ =
95+ let tag =
96+ match imageTags() with
97+ | ci when ci.StartsWith( " ci-" ) -> ci
98+ | _ -> " edge"
99+ let image = $" elastic/docs-builder:%s {tag}"
100+ exec { run " docker" [ " docker" ; " run" ; image; " --help" ] }
76101
77102let private publishContainers _ =
78103
79104 let createImage project =
80105 let ci = Environment.environVarOrNone " GITHUB_ACTIONS"
81- let pr =
82- match Environment.environVarOrNone " GITHUB_REF_NAME" with
83- | None -> None
84- | Some s when s.EndsWith " /merge" -> Some ( s.Split( '/' ) |> Seq.head)
85- | _ -> None
86- let imageTag =
106+ let pr = prNumber()
107+ let baseImageTag =
87108 match project with
88109 | _ -> " 9.0-noble-chiseled-aot"
89- let labels =
90- let exitCode = exec {
91- validExitCode ( fun _ -> true )
92- exit_ code_ of " git" " describe" " --tags" " --exact-match" " HEAD"
93- }
94- match ( exitCode, pr) with
95- | 0 , _ -> " edge;latest"
96- | _, None -> " edge"
97- | _, Some pr -> $" ci-%s {pr}"
110+ let labels = imageTags()
98111 let args =
99112 [ " publish" ; $" src/tooling/%s {project}/%s {project}.csproj" ]
100113 @ [
101114 " /t:PublishContainer" ;
102115 " -p" ; " DebugType=none" ;
103- " -p" ; $" ContainerBaseImage=mcr.microsoft.com/dotnet/nightly/runtime-deps:%s {imageTag }" ;
116+ " -p" ; $" ContainerBaseImage=mcr.microsoft.com/dotnet/nightly/runtime-deps:%s {baseImageTag }" ;
104117 " -p" ; $" ContainerImageTags=\" %s {labels};%s {Software.Version.Normalize()}\" "
105118 " -p" ; $" ContainerRepository=elastic/%s {project}"
106119 ]
120+
107121 let noPublish = Environment.environVarOrNone " DOCKER_NO_PUBLISH"
108122 let registry =
109123 match ( ci, pr, noPublish) with
@@ -172,6 +186,7 @@ let Setup (parsed:ParseResults<Build>) =
172186 | PristineCheck -> Build.Step pristineCheck
173187 | PublishBinaries -> Build.Step publishBinaries
174188 | PublishContainers -> Build.Step publishContainers
189+ | RunLocalContainer -> Build.Step runLocalContainer
175190 | PublishZip -> Build.Step publishZip
176191 | ValidateLicenses -> Build.Step validateLicenses
177192
0 commit comments