Skip to content

Commit 1ca03b1

Browse files
authored
feat(ci): refactor bindings server pipeline for deployment (#1352)
Part of #1318.
1 parent f2f7fc8 commit 1ca03b1

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

.github/workflows/end-to-end-tests.main.kts renamed to .github/workflows/bindings-server.main.kts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
88
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
99
import io.github.typesafegithub.workflows.domain.triggers.Push
1010
import io.github.typesafegithub.workflows.dsl.expressions.Contexts
11+
import io.github.typesafegithub.workflows.dsl.expressions.expr
1112
import io.github.typesafegithub.workflows.dsl.workflow
1213
import io.github.typesafegithub.workflows.yaml.writeToFile
1314
import java.net.URI
@@ -22,16 +23,16 @@ val GRADLE_ENCRYPTION_KEY by Contexts.secrets
2223

2324
@OptIn(ExperimentalKotlinLogicStep::class)
2425
workflow(
25-
name = "End-to-end tests",
26+
name = "Bindings server",
2627
on = listOf(
2728
Push(branches = listOf("main")),
2829
PullRequest(),
2930
),
3031
sourceFile = __FILE__.toPath(),
3132
) {
32-
job(
33-
id = "test-jit-server",
34-
name = "Test Just-In-Time bindings server",
33+
val endToEndTest = job(
34+
id = "end-to-end-test",
35+
name = "End-to-end test",
3536
runsOn = UbuntuLatest,
3637
) {
3738
// Using bundled bindings to avoid generating them here.
@@ -73,4 +74,17 @@ workflow(
7374
""".trimIndent(),
7475
)
7576
}
77+
78+
job(
79+
id = "deploy",
80+
name = "Deploy to DockerHub",
81+
runsOn = UbuntuLatest,
82+
`if` = expr { "${github.event_name} == 'push'" },
83+
needs = listOf(endToEndTest),
84+
_customArguments = mapOf(
85+
"environment" to "DockerHub",
86+
)
87+
) {
88+
run(command = "echo TODO")
89+
}
7690
}.writeToFile()
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# This file was generated using Kotlin DSL (.github/workflows/end-to-end-tests.main.kts).
1+
# This file was generated using Kotlin DSL (.github/workflows/bindings-server.main.kts).
22
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
33
# Generated with https://github.com/typesafegithub/github-workflows-kt
44

5-
name: 'End-to-end tests'
5+
name: 'Bindings server'
66
on:
77
push:
88
branches:
@@ -18,12 +18,12 @@ jobs:
1818
uses: 'actions/checkout@v4'
1919
- id: 'step-1'
2020
name: 'Execute script'
21-
run: 'rm ''.github/workflows/end-to-end-tests.yaml'' && ''.github/workflows/end-to-end-tests.main.kts'''
21+
run: 'rm ''.github/workflows/bindings-server.yaml'' && ''.github/workflows/bindings-server.main.kts'''
2222
- id: 'step-2'
2323
name: 'Consistency check'
24-
run: 'git diff --exit-code ''.github/workflows/end-to-end-tests.yaml'''
25-
test-jit-server:
26-
name: 'Test Just-In-Time bindings server'
24+
run: 'git diff --exit-code ''.github/workflows/bindings-server.yaml'''
25+
end-to-end-test:
26+
name: 'End-to-end test'
2727
runs-on: 'ubuntu-latest'
2828
needs:
2929
- 'check_yaml_consistency'
@@ -37,9 +37,20 @@ jobs:
3737
run: './gradlew :jit-binding-server:run &'
3838
- id: 'step-3'
3939
name: 'Wait for the server to respond'
40-
run: 'GHWKT_RUN_STEP=''test-jit-server:step-3'' ''.github/workflows/end-to-end-tests.main.kts'''
40+
run: 'GHWKT_RUN_STEP=''end-to-end-test:step-3'' ''.github/workflows/bindings-server.main.kts'''
4141
- id: 'step-4'
4242
name: 'Execute the script using the bindings from the server'
4343
run: |-
4444
mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
4545
.github/workflows/test-script-consuming-jit-bindings.main.kts
46+
deploy:
47+
name: 'Deploy to DockerHub'
48+
runs-on: 'ubuntu-latest'
49+
needs:
50+
- 'end-to-end-test'
51+
- 'check_yaml_consistency'
52+
if: '${{ github.event_name == ''push'' }}'
53+
environment: 'DockerHub'
54+
steps:
55+
- id: 'step-0'
56+
run: 'echo TODO'

0 commit comments

Comments
 (0)