Piotr Krzemiński
03/27/2022, 1:28 PMrunKotlin {
println("Hello from action logic!")
File("output-first.txt").writeText("Written from first Kotlin logic")
}
Piotr Krzemiński
03/27/2022, 1:28 PMPiotr Krzemiński
03/27/2022, 1:29 PMPiotr Krzemiński
03/27/2022, 1:30 PMPiotr Krzemiński
03/27/2022, 1:31 PMPiotr Krzemiński
03/27/2022, 1:33 PMBig Chungus
03/27/2022, 1:36 PMBig Chungus
03/27/2022, 1:36 PMBig Chungus
03/27/2022, 1:37 PMBig Chungus
03/27/2022, 1:38 PMBig Chungus
03/27/2022, 1:38 PMPiotr Krzemiński
03/27/2022, 1:40 PMPiotr Krzemiński
03/27/2022, 1:40 PMPiotr Krzemiński
03/27/2022, 1:41 PMBig Chungus
03/27/2022, 1:42 PMPiotr Krzemiński
03/27/2022, 1:42 PMBig Chungus
03/27/2022, 1:43 PMPiotr Krzemiński
03/27/2022, 1:43 PMBig Chungus
03/27/2022, 1:44 PMBig Chungus
03/27/2022, 1:44 PMPiotr Krzemiński
03/27/2022, 1:47 PMBig Chungus
03/27/2022, 1:47 PMBig Chungus
03/27/2022, 1:57 PMkotlinScript(
someActionProp = "xxx",
jvmVersion = "1.1"
dependencies = arrayOf("some.group:artefact:1.1.1") // <- vararg
) {
// language=kotlin
"""
println("Hello world")
"""
}
Which would then generate the script by prepending dependency annotations to returned string.
@file:Dependency("some.group:artefact:1.1.1")
println("Hello world")
Alternatively, optional properties could be moved into the lambda
kotlinScript {
someActionProp = "xxx",
jvmVersion = "1.1"
dependencies {
+"some.group:artefact:1.1.1"
}
repositories {
mavenCentral()
maven("<https://url.com>") {
username="xxx"
password="${{ GH_SECRET }}"
}
}
// language=kotlin
"""
println("Hello world")
"""
}
Big Chungus
03/27/2022, 2:10 PMPiotr Krzemiński
03/27/2022, 2:29 PMBig Chungus
03/27/2022, 2:30 PMBig Chungus
03/27/2022, 2:49 PMclass Sandbox {
private fun kotlinScript(script: () -> /* language=kotlin */ String) {
}
@Test
fun main() {
kotlinScript {
"""
fun main() {
}
""".trimIndent()
}
}
}
Big Chungus
03/27/2022, 2:50 PMPiotr Krzemiński
03/27/2022, 4:51 PMNikky
03/27/2022, 9:09 PMrun(name= "execute kts", command = "./$pathToScript")
Nikky
03/27/2022, 9:09 PMNikky
03/27/2022, 9:12 PM.main.kts
file in a specific defined location
then you just have to include the actions and add them to the workflow/jobPiotr Krzemiński
03/28/2022, 6:20 AMi would probably prefer to keep my gh-action generating and code to execute seperated anyways.. and this lets me use executable script files i can test by hand and suchinteresting point of view 🙂 well, it's already supported and the boilerplate is minimal. However, this whole idea started with a different mindset. Best if you don't have to know that there's some YAML under the hood, and just write your workflow instead. Then this separation - action generating code and logic code - would be artificial, hence my attempts to have them in a single place in a type-safe way
Piotr Krzemiński
03/28/2022, 6:47 AM