Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:

- name: Run Container
if: ${{ matrix.os == 'ubuntu-latest' }}
run: docker run elastic/docs-builder:ci-${{ github.event.pull_request.number }} --help
run: dotnet run --project build -c release -- runlocalcontainer


integration:
Expand Down
2 changes: 2 additions & 0 deletions build/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Build =

| [<CliPrefix(CliPrefix.None);SubCommand>] Publish
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishBinaries
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] RunLocalContainer
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishContainers
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishZip

Expand Down Expand Up @@ -67,6 +68,7 @@ with
| PristineCheck
| PublishBinaries
| PublishContainers
| RunLocalContainer
| PublishZip
| ValidateLicenses
| Compile
Expand Down
47 changes: 31 additions & 16 deletions build/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,51 @@ let private publishZip _ =
]
zip "docs-builder"
zip "docs-assembler"

let private prNumber () =
match Environment.environVarOrNone "GITHUB_REF_NAME" with
| None -> None
| Some s when s.EndsWith "/merge" -> Some (s.Split('/') |> Seq.head)
| _ -> None

let private imageTags () =
let pr = prNumber()
let exitCode = exec {
validExitCode (fun _ -> true)
exit_code_of "git" "describe" "--tags" "--exact-match" "HEAD"
}
match (exitCode, pr) with
| 0, _ -> "edge;latest"
| _, None -> "edge"
| _, Some pr -> $"ci-%s{pr}"

let private runLocalContainer _ =
let tag =
match imageTags() with
| ci when ci.StartsWith("ci-") -> ci
| _ -> "edge"
let image = $"elastic/docs-builder:%s{tag}"
exec { run "docker" ["docker"; "run"; image; "--help"] }

let private publishContainers _ =

let createImage project =
let ci = Environment.environVarOrNone "GITHUB_ACTIONS"
let pr =
match Environment.environVarOrNone "GITHUB_REF_NAME" with
| None -> None
| Some s when s.EndsWith "/merge" -> Some (s.Split('/') |> Seq.head)
| _ -> None
let imageTag =
let pr = prNumber()
let baseImageTag =
match project with
| _ -> "9.0-noble-chiseled-aot"
let labels =
let exitCode = exec {
validExitCode (fun _ -> true)
exit_code_of "git" "describe" "--tags" "--exact-match" "HEAD"
}
match (exitCode, pr) with
| 0, _ -> "edge;latest"
| _, None -> "edge"
| _, Some pr -> $"ci-%s{pr}"
let labels = imageTags()
let args =
["publish"; $"src/tooling/%s{project}/%s{project}.csproj"]
@ [
"/t:PublishContainer";
"-p"; "DebugType=none";
"-p"; $"ContainerBaseImage=mcr.microsoft.com/dotnet/nightly/runtime-deps:%s{imageTag}";
"-p"; $"ContainerBaseImage=mcr.microsoft.com/dotnet/nightly/runtime-deps:%s{baseImageTag}";
"-p"; $"ContainerImageTags=\"%s{labels};%s{Software.Version.Normalize()}\""
"-p"; $"ContainerRepository=elastic/%s{project}"
]

let noPublish = Environment.environVarOrNone "DOCKER_NO_PUBLISH"
let registry =
match (ci, pr, noPublish) with
Expand Down Expand Up @@ -172,6 +186,7 @@ let Setup (parsed:ParseResults<Build>) =
| PristineCheck -> Build.Step pristineCheck
| PublishBinaries -> Build.Step publishBinaries
| PublishContainers -> Build.Step publishContainers
| RunLocalContainer -> Build.Step runLocalContainer
| PublishZip -> Build.Step publishZip
| ValidateLicenses -> Build.Step validateLicenses

Expand Down
Loading