Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core feature request] Access workflow inputs in Kotlin-based step #1685

Open
krzema12 opened this issue Oct 13, 2024 · 1 comment
Open

[Core feature request] Access workflow inputs in Kotlin-based step #1685

krzema12 opened this issue Oct 13, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@krzema12
Copy link
Member

What feature do you need?
https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#inputs-context

The access could be even type-unsafe for now (just strings).

Do you have an example usage?

run {
    println(inputs["myInput"])
}

Is there a workaround for not having this feature? If yes, please describe it.

I'm currently doing something pretty ugly:

            val githubContextJson = System.getenv("GHWKT_GITHUB_CONTEXT_JSON")!!
            val version: String = Json.parseToJsonElement(githubContextJson)
                .jsonObject["event"]
                ?.jsonObject?.get("inputs")
                ?.jsonObject?.get("version")
                ?.jsonPrimitive?.contentOrNull
                ?: error("Version couldn't be extracted from input")
@krzema12 krzema12 added the enhancement New feature or request label Oct 13, 2024
@krzema12
Copy link
Member Author

krzema12 commented Dec 18, 2024

Add tests for deserializing GitHub context:

private fun loadContextsFromEnvVars(getenv: (String) -> String?): Contexts {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant