https://kotlinlang.org logo
#github-workflows-kt
Title
# github-workflows-kt
p

Piotr Krzemiński

02/21/2023, 2:25 PM
@Adam S I’d like to continue the discussion on a custom script context: https://kotlinlang.slack.com/archives/C0B8MA7FA/p1676989225653899?thread_ts=1676985449.906609&cid=C0B8MA7FA could you elaborate how it could be achieved? the simplicity of the current approach is that it just works by specifying the shebang, no extra stuff is needed. I’m wondering how the API of the library would have to be changed for this to work
a

Adam S

02/21/2023, 2:27 PM
p

Piotr Krzemiński

02/21/2023, 2:27 PM
right, thanks! we concluded in a similar way
a

Adam S

02/21/2023, 2:28 PM
I'm not sure how feasible it is to implement. I remember we looked into it and while I think it's possible according to the docs, it would still be a lot of work
p

Piotr Krzemiński

02/21/2023, 2:28 PM
yep, the benefits don’t seem to outweigh the cost just yet
a

Adam S

02/21/2023, 2:30 PM
I think the IJ plugin would basically automatically add the GitHubWorkflowsKtScriptContext in Intellij
p

Piotr Krzemiński

02/21/2023, 2:30 PM
what about calling the
.<something>.kts
from outside of IntelliJ?
a

Adam S

02/21/2023, 2:31 PM
and then you could have
my-workflow.workflow.kts
no idea 🤷‍♀️
so the shebang at the moment is
kotlin.exe
or something, right?
that bundles the
.main.kts
scripting context
#!/usr/bin/env kotlin
a

Adam S

02/21/2023, 2:32 PM
so you'd need to make your own
gh-workflow.exe
that extends
kotlin.exe
and also bundles GitHubWorkflowsKtScriptContext
p

Piotr Krzemiński

02/21/2023, 2:34 PM
doesn’t sound like fun 😅
because this own executable would have to be deployed somehow
a

Adam S

02/21/2023, 2:34 PM
haha, that depends on how much free time you have
p

Piotr Krzemiński

02/21/2023, 2:34 PM
right now oscillating around 0 😂
a

Adam S

02/21/2023, 2:35 PM
I think it's not worth it for something that can basically be emulated by defining some function in the lib
Copy code
fun workflow(block: GitHubWorkflowsKtScriptContext.() -> Unit) {}
and then in the script, you've got the context
Copy code
workflow {
  ...
}
my point with mentioning a custom scripting context is that I think it'd be worth keeping a tally of things that need an IJ plugin, because maybe one day the scales will tip over!
4 Views