"Custom shell" (kotlin) should allow custom file name extension (`.main.kts`)
@ruvceskistefan is already working on this.
Since Mar 18, 2022.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe the enhancement
Actions allows to define a custom shell in worflow runs.
Kotlin has support for scripting.
I've tried to make use of Kotlin for runninng a script in Actions.
The issue is that kotlin expects a file name ending in .main.kts, but the runner creates a file without extensions for "shells" that are not hardcoded in https://github.com/actions/runner/blob/a2e32170fd83851569804fa7b27d2cae235a5225/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs#L38
File name construction: https://github.com/actions/runner/blob/a2e32170fd83851569804fa7b27d2cae235a5225/src/Runner.Worker/Handlers/ScriptHandler.cs#L233
I would need some way to provide a map of kotlin to .main.kts to ScriptHandlerHelpers.GetScriptFileExtension()
Code Snippet
Consider this example workflow:
name: CI
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: fwilhe2/setup-kotlin@main
- run: |
#!/usr/bin/env kotlin
println("hello")
shell: kotlin {0}
I would expect to be able to run the given script in kotlin (the cli compiler is installed on the runner via fwilhe2/setup-kotlin).
Additional information
Result of the given workflow script:

This is because kotlin requires the main.kts suffix to know this should be run as a script.
Compare to running the script locally with the right or the wrong filename
~$ cat foo.main.kts
#!/usr/bin/env kotlin
println("hello")
~$ kotlin foo.main.kts
hello
~$ mv foo.main.kts foo
~$ kotlin foo
error: could not find or load main class foo
Did I overlook something? Is this already possible? If not, I'd be glad if some option to make this would be provided, as it would make the "custom shell" feature much more interesting.
Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.