Skip to content

Commit

Permalink
ci: refactor to less nestiness level
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 10, 2025
1 parent ff44e6e commit fee8c10
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 127 deletions.
57 changes: 29 additions & 28 deletions kcls/wf_docker_production.k
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,34 @@ _workflow = gw.Workflow {
name = "Build docker image and save to latest"
uses = "darklab8/fl-darkstat/.github/workflows/deploy-docker-staging.yml@master"
}
job = {
name = _workflow_name
needs = ["build"]
steps = [
ghc.CheckoutRepo
ghc.GetVersionFromTag
ghc.DockerLogin
ghc.InstallDarklabSshKey
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = "staging"
new_tag = ghc.GetVersionOutput
pull = True
push = True
})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "production"
push = True
})
docker.DeploySwarm(docker.DeploySwarmOpts {
image_name = c._image_name
service_name = "darkstat-production"
tag = "production"
})
]
}
job = _production_deploy_job
}
}
_production_deploy_job: gw.Job = {
name = _workflow_name
needs = ["build"]
steps = [
ghc.CheckoutRepo
ghc.GetVersionFromTag
ghc.DockerLogin
ghc.InstallDarklabSshKey
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = "staging"
new_tag = ghc.GetVersionOutput
pull = True
push = True
})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "production"
push = True
})
docker.DeploySwarm(docker.DeploySwarmOpts {
image_name = c._image_name
service_name = "darkstat-production"
tag = "production"
})
]
}
61 changes: 31 additions & 30 deletions kcls/wf_docker_staging.k
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,36 @@ _workflow = gw.Workflow {
}
env = ghc.DockerHostEnv
jobs = {
job = {
name = _workflow_name
steps = [
ghc.CheckoutRepoWithCommits
go.InstallGo {}
tf.InstallTaskfile {}
autogit.InstallAutogit {}
autogit.GetVersionStep
ghc.DockerLogin
ghc.InstallDarklabSshKey
docker.Build(docker.BuildOpts {image_name = c._image_name})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "staging"
push = True
})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "latest"
push = True
})
docker.DeploySwarm(docker.DeploySwarmOpts {
image_name = c._image_name
service_name = "darkstat-staging"
tag = "staging"
})
]
}
job = _docker_staging_job
}
}
_docker_staging_job: gw.Job = {
name = _workflow_name
steps = [
ghc.CheckoutRepoWithCommits
go.InstallGo {}
tf.InstallTaskfile {}
autogit.InstallAutogit {}
autogit.GetVersionStep
ghc.DockerLogin
ghc.InstallDarklabSshKey
docker.Build(docker.BuildOpts {image_name = c._image_name})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "staging"
push = True
})
docker.Retag(docker.RetagOpts {
image_name = c._image_name
old_tag = ghc.GetVersionOutput
new_tag = "latest"
push = True
})
docker.DeploySwarm(docker.DeploySwarmOpts {
image_name = c._image_name
service_name = "darkstat-staging"
tag = "staging"
})
]
}
75 changes: 38 additions & 37 deletions kcls/wf_pages_production.k
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,43 @@ _workflow = gw.Workflow {
push.tags = ["*"]
}
jobs = {
job = {
name = "Github Pages Production"
steps = [
autogit.InstallAutogit {}
ghc.CheckoutRepoWithCommits
go.InstallGo {}
tf.InstallTaskfile {}
templ.InstallTempl {}
templ.GenerateTempl {}
c.TaskfileBuildVersion
ga.Step {
name: "Build Binaries"
run: "task build:bins"
}
autogit.GetChangelogStep {}
ghc.UploadBinariesStep(ghc.UploadBinariesStepOpts {
body = autogit.GetChangelogOutput
files = [
"dist/darkstat-linux-amd64"
"dist/darkstat-linux-arm64"
"dist/darkstat-macos-amd64"
"dist/darkstat-macos-arm64"
"dist/darkstat-windows-amd64.exe"
"dist/darkstat-windows-arm64.exe"
]
})
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-vanilla"
}) {name = "Repository Dispatch for Vanilla"}
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-discovery"
}) {name = "Repository Dispatch for Discovery"}
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-flsr"
}) {name = "Repository Dispatch for FLSR"}
]
}
job = _pages_production_job
}
}
_pages_production_job: gw.Job = {
name = "Github Pages Production"
steps = [
autogit.InstallAutogit {}
ghc.CheckoutRepoWithCommits
go.InstallGo {}
tf.InstallTaskfile {}
templ.InstallTempl {}
templ.GenerateTempl {}
c.TaskfileBuildVersion
ga.Step {
name: "Build Binaries"
run: "task build:bins"
}
autogit.GetChangelogStep {}
ghc.UploadBinariesStep(ghc.UploadBinariesStepOpts {
body = autogit.GetChangelogOutput
files = [
"dist/darkstat-linux-amd64"
"dist/darkstat-linux-arm64"
"dist/darkstat-macos-amd64"
"dist/darkstat-macos-arm64"
"dist/darkstat-windows-amd64.exe"
"dist/darkstat-windows-arm64.exe"
]
})
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-vanilla"
}) {name = "Repository Dispatch for Vanilla"}
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-discovery"
}) {name = "Repository Dispatch for Discovery"}
ghc.TriggerWorkflowDispatch(ghc.TriggerWorkflowDispatchOpts {
repository = "darklab8/fl-data-flsr"
}) {name = "Repository Dispatch for FLSR"}
]
}
35 changes: 18 additions & 17 deletions kcls/wf_pages_staging.k
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ _workflow = gw.Workflow {
workflow_dispatch: {}
}
jobs = {
job = {
name = "Github Pages Staging"
permissions: ghc.PagesPermissions {}
environment: dict(ghc.PagesEnvironment {})
steps = [
ghc.CheckoutRepo
cf.NewCheckoutFreelancerOpts(cf.CheckoutArgs {
freelancer_mod = cf._mod_discovery
freelancer_folder = c._freelancer_folder
})
] + c.DarkstatBuildAssetsSteps(c.BuildArgs {
site_root = "/fl-darkstat/"
freelancer_folder = c._freelancer_folder
heading = '<span style="font-weight:1000;">DEV ENV</span> <a href="https://github.com/darklab8/fl-darkstat">fl-darkstat</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>'
relay_host = "https://darkrelay-staging.dd84ai.com"
}) + ghc.PagesToDeploySteps()
}
job = _pages_staging_job
}
}
_pages_staging_job: gw.Job = {
name = "Github Pages Staging"
permissions: ghc.PagesPermissions {}
environment: dict(ghc.PagesEnvironment {})
steps = [
ghc.CheckoutRepo
cf.NewCheckoutFreelancerOpts(cf.CheckoutArgs {
freelancer_mod = cf._mod_discovery
freelancer_folder = c._freelancer_folder
})
] + c.DarkstatBuildAssetsSteps(c.BuildArgs {
site_root = "/fl-darkstat/"
freelancer_folder = c._freelancer_folder
heading = '<span style="font-weight:1000;">DEV ENV</span> <a href="https://github.com/darklab8/fl-darkstat">fl-darkstat</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>'
relay_host = "https://darkrelay-staging.dd84ai.com"
}) + ghc.PagesToDeploySteps()
}
31 changes: 16 additions & 15 deletions kcls/wf_test_build.k
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ _workflow = gw.Workflow {
schedule: [{cron = "0 9 * * *"}]
}
jobs = {
job = {
name = "Test build"
steps = [
ghc.CheckoutRepo
cf.NewCheckoutFreelancerOpts(cf.CheckoutArgs {
freelancer_mod = cf._mod_discovery
freelancer_folder = c._freelancer_folder
})
] + c.DarkstatBuildAssetsSteps(c.BuildArgs {
site_root = "/fl-darkstat/"
freelancer_folder = c._freelancer_folder
heading = '<span style="font-weight:1000;">DEV ENV</span> <a href="https://github.com/darklab8/fl-darkstat">fl-darkstat</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>'
relay_host = "https://darkrelay-staging.dd84ai.com"
})
}
job = _test_job
}
}
_test_job: gw.Job = {
name = "Test build"
steps = [
ghc.CheckoutRepo
cf.NewCheckoutFreelancerOpts(cf.CheckoutArgs {
freelancer_mod = cf._mod_discovery
freelancer_folder = c._freelancer_folder
})
] + c.DarkstatBuildAssetsSteps(c.BuildArgs {
site_root = "/fl-darkstat/"
freelancer_folder = c._freelancer_folder
heading = '<span style="font-weight:1000;">DEV ENV</span> <a href="https://github.com/darklab8/fl-darkstat">fl-darkstat</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>'
relay_host = "https://darkrelay-staging.dd84ai.com"
})
}

0 comments on commit fee8c10

Please sign in to comment.