github-workflows-kt
github-workflows-kt copied to clipboard
Allow running arbitrary Kotlin code
See PoC at https://github.com/krzema12/github-actions-kotlin-dsl/blob/136-runKotlin-PoC/.github/workflows/script-with-server.main.kts
See discussion at https://kotlinlang.slack.com/archives/C02UUATR7RC/p1648387696252109?thread_ts=1648387696.252109&cid=C02UUATR7RC
How about
run(
// language=kotlin
command = """
println("Hello from action logic! (works already)")
""".trimIndent(),
_customArguments = mapOf(
"shell" to StringCustomValue("kotlin -howtorun .main.kts {0}")
)
)
?
@Vampire it's not ideal - no compile time verification of the Kotlin code, no syntax highlighting outside of IntelliJ. But yeah, what you showed is already something, even better if #286 is done. We could also have
runKotlin(
// language=kotlin
"println("Hello from action logic! (works already)")"
)
where runKotlin
would have shell = "kotlin -howtorun .main.kts {0}"
built-in + try to validate Kotlin code in workflow compile time. I'd go this way as first iteration and see how it works in practice.
Maybe runMainKts
to make it clear it runs as *.main.kts
and you can for example use @Depends
and so on.
Why not just running a normal kotlin script?
Le ven. 17 juin 2022 à 20:09, Piotr Krzemiński @.***> a écrit :
@Vampire https://github.com/Vampire it's not ideal - no compile time verification of the Kotlin code, no syntax highlighting outside of IntelliJ. But yeah, what you showed is already something, even better if #286 https://github.com/krzema12/github-actions-kotlin-dsl/issues/286 is done. We could also have
runKotlin( // language=kotlin "println("Hello from action logic! (works already)")" )
where runKotlin would have shell = "kotlin -howtorun .main.kts {0}" built-in + try to validate Kotlin code in workflow compile time. I'd go this way as first iteration and see how it works in practice.
— Reply to this email directly, view it on GitHub https://github.com/krzema12/github-actions-kotlin-dsl/issues/136#issuecomment-1159120301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQFSGFCDSVFMCWPAFPKI3VPS5NXANCNFSM5Q672EUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Experimenting with a much simpler approach, WIP on https://github.com/typesafegithub/github-workflows-kt/tree/136-allow-putting-Kotlin-logic-in-lambda
The experimental implementation is on its way, let's gather feedback. https://kotlinlang.slack.com/archives/C02UUATR7RC/p1704404385924819 https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1704465156657579?thread_ts=1704465156.657579&cid=C0BJ0GTE2