@@ -4,9 +4,7 @@ import io.github.typesafegithub.workflows.domain.Job
4
4
import io.github.typesafegithub.workflows.domain.KotlinLogicStep
5
5
import io.github.typesafegithub.workflows.domain.Mode
6
6
import io.github.typesafegithub.workflows.domain.Permission
7
- import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
8
7
import io.github.typesafegithub.workflows.domain.Workflow
9
- import io.github.typesafegithub.workflows.domain.actions.CustomAction
10
8
import io.github.typesafegithub.workflows.domain.contexts.Contexts
11
9
import io.github.typesafegithub.workflows.domain.contexts.GithubContext
12
10
import io.github.typesafegithub.workflows.dsl.toBuilder
@@ -103,54 +101,13 @@ public fun Workflow.generateYaml(
103
101
104
102
val jobsWithConsistencyCheck =
105
103
if (consistencyCheckJobConfig is ConsistencyCheckJobConfig .Configuration ) {
106
- check(gitRootDir != null && sourceFile != null ) {
107
- " consistency check requires a valid sourceFile and Git root directory"
108
- }
109
-
110
- val targetFilePath =
111
- gitRootDir
112
- .resolve(" .github" )
113
- .resolve(" workflows" )
114
- .resolve(targetFileName)
115
- .relativeToAbsolute(gitRootDir)
116
- .invariantSeparatorsPathString
117
-
118
104
val consistencyCheckJob =
119
- this .toBuilder().job(
120
- id = " check_yaml_consistency" ,
121
- name = " Check YAML consistency" ,
122
- runsOn = UbuntuLatest ,
123
- condition = consistencyCheckJobConfig.condition,
124
- env = consistencyCheckJobConfig.env,
125
- ) {
126
- uses(
127
- name = " Check out" ,
128
- // Since this action is used in a simple way, and we actually don't want to update the version
129
- // because it causes YAML regeneration, let's not use the type-safe binding here. It will also
130
- // let us avoid depending on a Maven-based action binding once bundled bindings are deprecated.
131
- action =
132
- CustomAction (
133
- actionOwner = " actions" ,
134
- actionName = " checkout" ,
135
- actionVersion = " v4" ,
136
- ),
137
- )
138
-
139
- consistencyCheckJobConfig.additionalSteps?.also { block ->
140
- block()
141
- }
142
-
143
- run (
144
- name = " Execute script" ,
145
- command =
146
- " rm '$targetFilePath ' " +
147
- " && '$sourceFilePath '" ,
148
- )
149
- run (
150
- name = " Consistency check" ,
151
- command = " git diff --exit-code '$targetFilePath '" ,
152
- )
153
- }
105
+ this .toBuilder().consistencyCheckJob(
106
+ sourceFilePath = sourceFilePath,
107
+ targetFileName = targetFileName,
108
+ gitRootDir = gitRootDir,
109
+ consistencyCheckJobConfig = consistencyCheckJobConfig,
110
+ )
154
111
listOf (consistencyCheckJob) +
155
112
jobs.map {
156
113
it.copy(needs = it.needs + consistencyCheckJob)
0 commit comments