Skip to content

Commit 1b9a7bf

Browse files
authored
fix(server): correctly generate maven-metadata.xml for nested actions (#1367)
Part of #1318.
1 parent bfc2c5c commit 1b9a7bf

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.github/workflows/bindings-server.main.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import kotlin.time.TimeSource
2727
val DOCKERHUB_USERNAME by Contexts.secrets
2828
val DOCKERHUB_PASSWORD by Contexts.secrets
2929
val TRIGGER_IMAGE_PULL by Contexts.secrets
30+
val GITHUB_TOKEN by Contexts.secrets
3031

3132
@OptIn(ExperimentalKotlinLogicStep::class)
3233
workflow(
@@ -41,6 +42,9 @@ workflow(
4142
id = "end-to-end-test",
4243
name = "End-to-end test",
4344
runsOn = UbuntuLatest,
45+
env = linkedMapOf(
46+
"GITHUB_TOKEN" to expr { GITHUB_TOKEN },
47+
),
4448
) {
4549
uses(action = Checkout())
4650
uses(action = ActionsSetupGradle())
@@ -79,6 +83,15 @@ workflow(
7983
.github/workflows/test-script-consuming-jit-bindings.main.kts
8084
""".trimIndent(),
8185
)
86+
87+
run(
88+
name = "Fetch maven-metadata.xml for top-level action",
89+
command = "curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml",
90+
)
91+
run(
92+
name = "Fetch maven-metadata.xml for nested action",
93+
command = "curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml",
94+
)
8295
}
8396

8497
job(

.github/workflows/bindings-server.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
runs-on: 'ubuntu-latest'
2828
needs:
2929
- 'check_yaml_consistency'
30+
env:
31+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
3032
steps:
3133
- id: 'step-0'
3234
uses: 'actions/checkout@v4'
@@ -43,6 +45,12 @@ jobs:
4345
run: |-
4446
mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
4547
.github/workflows/test-script-consuming-jit-bindings.main.kts
48+
- id: 'step-5'
49+
name: 'Fetch maven-metadata.xml for top-level action'
50+
run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml'
51+
- id: 'step-6'
52+
name: 'Fetch maven-metadata.xml for nested action'
53+
run: 'curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml'
4654
deploy:
4755
name: 'Deploy to DockerHub'
4856
runs-on: 'ubuntu-latest'

maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ internal suspend fun buildMavenMetadataFile(
2222
.withZone(ZoneId.systemDefault())
2323
.format(Instant.now())
2424
val availableMajorVersions =
25-
fetchAvailableVersions(owner = owner, name = name, githubToken = githubToken)
25+
fetchAvailableVersions(owner = owner, name = name.substringBefore("__"), githubToken = githubToken)
2626
.filter { it.removePrefix("v").toIntOrNull() != null }
2727
val newest = availableMajorVersions.maxBy { it.removePrefix("v") }
2828
return """
2929
<?xml version="1.0" encoding="UTF-8"?>
3030
<metadata>
3131
<groupId>$owner</groupId>
32-
<artifactId>$name</artifactId>
32+
<artifactId>${name.replace("__", "/")}</artifactId>
3333
<versioning>
3434
<latest>$newest</latest>
3535
<release>$newest</release>

0 commit comments

Comments
 (0)