Skip to content

Instantly share code, notes, and snippets.

@thinkbeforecoding
Created October 19, 2022 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkbeforecoding/3b8424f3836ef44b6affacb91eb44158 to your computer and use it in GitHub Desktop.
Save thinkbeforecoding/3b8424f3836ef44b6affacb91eb44158 to your computer and use it in GitHub Desktop.
Yzl for gitlab-ci
#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"
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