github-workflows-kt icon indicating copy to clipboard operation
github-workflows-kt copied to clipboard

[Core feature request] More sophisticated `uses` strings

Open Vampire opened this issue 2 years ago • 2 comments

What feature do you need? From https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-public-action you can see that uses can be more than just {owner}/{repo}@{ref}. It can also be {owner}/{repo}/{path}@{ref}, a local path within the current worktree, or a docker image.

In my current case I'd need the local path variant.

Do you have an example usage?

- id: "execute_action"
  uses: "./"
  with:
    "distribution": "${{ matrix.distribution.user-id }}"
  continue-on-error: true
- run: "if '${{ steps.execute_action.outcome }}' NEQ 'failure' exit 1\n"
  shell: "cmd"

Vampire avatar Jun 17 '22 14:06 Vampire

Is there any way to manually work-around this except for generating the YAML and then doing a string replace in the result? I didn't find a way to customize this, as an extension function on Action is used to generate the uses string so cannot be overridden and specifying an own uses in _customArguments unfortunately leads to duplicate key instead of overridden as mentioned in #292.

My current workaround is

val executeAction = CustomAction(
    actionOwner = "localAction",
    actionName = "localAction",
    actionVersion = "localAction",
)

workflow(...) {
    job(...) {
        uses(
            name = "Execute action",
            action = executeAction
        )
    }
}.apply {
    writeToFile()
    __FILE__.resolveSibling(targetFileName).apply {
        readText()
            .replace(executeAction.fullName, "./")
            .also(::writeText)
    }
}

Vampire avatar Jun 17 '22 22:06 Vampire

This missing feature can now be achieved using _customArguments - you can now owerrive built-in attributes without problems. Proper support still to be implemented :)

krzema12 avatar Aug 15 '22 08:08 krzema12