with kotlin 1.6.20 i can finally do this.. ``` ...
# github-workflows-kt
n
with kotlin 1.6.20 i can finally do this..
Copy code
sourceFile = __FILE__.toPath(),
    targetFile = __FILE__.resolveSibling(
        __FILE__.name.substringBeforeLast(".main.kts") + ".yml"
    ).toPath(),
sadly this does not quite work out of the box.. working on a fix.. adding a parameter
rootDirectory
(sounds clunky.. name suggestions?) which is used to generate paths relative to
rootDIrectory
so that will continues to work from whatever directory you invoke it .. TL;DR the idea run script button should work with that change.. a default setup with the scripts and yml files in
.github/workflows/
might look like so..
Copy code
sourceFile = __FILE__.toPath(),
targetFile = __FILE__.toPath().resolveSibling(
    __FILE__.name.substringBeforeLast(".main.kts") + ".yml"
),
rootDirectory = __FILE__.toPath().absolute().parent.parent.parent,
PS: i wish we could bake this logic into the library.. but
__FILE__
is a magic constant that only exists in
main.kts
scripts..
p
I haven't had a chance to play with
___FILE___
yet, but what I'm thinking about is a function that would accept
___FILE___
and the desired path, and do its magic there. PoC needed, then we'll see how it works in practice :) thanks for taking a look at it!
n
i have the changes i did in my fork on branch
main
what we need is the path to be relative to the repository root.. is the location of the yml files always in
.github/workflows/
we could make that a default i guess.. and the user would only need to provide the filename of the
yml
file (and that can also have a default)
the complicated bit is that we need to keep the paths as they are passed in at least until its written to file.. otherwise we run into the same issue as before.. using a relative path from the wrong working dir which is why we need to keep the original repo root around (but that can just have the default
.
) so it does not change api for anyone who does not care..
p
Sorry, no space to dig into this deeper right now :( please add a comment here: https://github.com/krzema12/github-actions-kotlin-dsl/issues/129 with what you have in the code, and we'll get back to it one day 👍
n
i have some poc on my branch.. so i just opened a PR https://github.com/krzema12/github-actions-kotlin-dsl/pull/188
p
Thanks, will check out after Easter