Created
October 19, 2022 21:52
-
-
Save thinkbeforecoding/3b8424f3836ef44b6affacb91eb44158 to your computer and use it in GitHub Desktop.
Yzl for gitlab-ci
This file contains hidden or 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
#r "nuget: Yzl" | |
open Yzl.Core | |
let stages = Yzl.seq "stages" << Yzl.liftMany | |
let stage = Yzl.str "stage" | |
let job (name: string) = Yzl.map name | |
let tags = Yzl.seq "tags" << Yzl.liftMany | |
let image = Yzl.str "image" | |
let script = Yzl.seq "script" << Yzl.liftMany | |
let variables vs = "variables" .= [for k,v in vs -> k .= v] | |
module Stage = | |
let build = "build" | |
let test = "test" | |
let deploy = "deploy" | |
let build m = | |
job $"build {m}" [ | |
image "mcr.microsoft.com/dotnet/sdk:6.0" | |
stage Stage.build | |
tags [ m ] | |
script [ | |
"""echo "hello" """ | |
"dotnet --version" ] | |
variables [ | |
"DEPLOY_ENVIRONMENT", "staging" | |
"DEPLOY_PATH", @"C:\path" ] | |
"needs".= [ | |
[ "project" .= "group/project" | |
"job" .= "build" | |
"artifacts" .= true ] ] ] | |
let machines = | |
[ "server-1" | |
"server-2" | |
"server-3" ] | |
[ stages [ Stage.build; Stage.test; Stage.deploy ] | |
for m in machines do | |
build m ] | |
|> Yzl.render |> printf "%s" |
This file contains hidden or 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
stages: | |
- build | |
- test | |
- deploy | |
build server-1: | |
image: mcr.microsoft.com/dotnet/sdk:6.0 | |
stage: build | |
tags: | |
- server-1 | |
script: | |
- echo "hello" | |
- dotnet --version | |
variables: | |
DEPLOY_ENVIRONMENT: staging | |
DEPLOY_PATH: C:\path | |
needs: | |
- project: group/project | |
job: build | |
artifacts: true | |
build server-2: | |
image: mcr.microsoft.com/dotnet/sdk:6.0 | |
stage: build | |
tags: | |
- server-2 | |
script: | |
- echo "hello" | |
- dotnet --version | |
variables: | |
DEPLOY_ENVIRONMENT: staging | |
DEPLOY_PATH: C:\path | |
needs: | |
- project: group/project | |
job: build | |
artifacts: true | |
build server-3: | |
image: mcr.microsoft.com/dotnet/sdk:6.0 | |
stage: build | |
tags: | |
- server-3 | |
script: | |
- echo "hello" | |
- dotnet --version | |
variables: | |
DEPLOY_ENVIRONMENT: staging | |
DEPLOY_PATH: C:\path | |
needs: | |
- project: group/project | |
job: build | |
artifacts: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment