question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Core feature request] Allow accessing step outputs

See original GitHub issue

What feature do you need? Please add a link to GitHub docs (https://docs.github.com/en/actions/using-workflows/) which describes the desired feature. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsid

Do you have an example usage? Best if a YAML snippet is pasted here, or if your project is open-source, an URL to your workflow.

- name: Build and push
  id: docker_build
  uses: docker/build-push-action@v2
  with:
    context: ./
    file: ./Dockerfile
    push: true
    tags: ${{ secrets.DOCKER_HUB_USERNAME }}/discordbot:latest
- name: Image digest
  run: echo ${{ steps.docker_build.outputs.digest }}

even better would be if we could use it somewhat like so:


fun variable(variable: String): String = "\${{ $variable }}"

val dockerBuild = uses(
    name = "Build and push",
    id = "docker_build_push",
    action = DockerBuildPush(
        context = ".",
        file = "./Dockerfile",
        push = true,
        tags = "${variable("secrets.DOCKER_HUB_USERNAME")}/discordbot:latest",
    )
)
run(
    name = "image digest",
    command ="echo ${dockerBuild.outputsVariable("digest")}",
//      command = "echo ${variable("steps.${dockerBuild.id}.outputs.digest")}",
)

but just having access to the id field would let me build the command echo ${{ steps.docker_build.outputs.digest }} myself too

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NikkyAIcommented, Feb 9, 2022

yes the unsafe access way looks good, this could either generate just the steps.docker_build.outputs.digest string… or the whole thing not sure if i might want to call more functions on things eg i might want to do call one of these functions https://docs.github.com/en/actions/learn-github-actions/expressions#functions on the output i could image format or join

1reaction
krzema12commented, Feb 2, 2022

Sure, so I’ll go with dockerBuild.outputs.digest approach.

I was thinking about making dockerBuild.outputs.digest a string that would contain the placeholder, that is ${{steps.docker_build.outputs.digest }}. Would it work for your use case with set-output? If I’m missing something, I’d appreciate a minimal example in YAML and how would you like to do it in Kotlin DSL.

@edit

Now I got your idea about accessing the outputs in an unsafe way. I’ll add API like ${dockerBuild.outputs["yourOutputName"]}. Does it look good?

and would the Action need to implement extra code to map outputs to variables ?

Yes. I’ll come back with a draft implementation and we can discuss various approaches.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core Feature Request - Pabbly Connect
When editing a flow, I want to test multiple data inputs. After changing, not all data gets refreshed. Please change this and automatic...
Read more >
Defining outputs for jobs - GitHub Docs
To use job outputs in a dependent job, you can use the needs context. For more information, see "Contexts." Example: Defining outputs for...
Read more >
Context Object - AWS Step Functions
This allows your workflows access to information about their specific execution. You can access the context object from the following fields: InputPath.
Read more >
Handle inbound or incoming HTTPS calls - Azure Logic Apps
Receive and respond to HTTPS requests sent to workflows in Azure Logic Apps.
Read more >
How to get the current branch within Github Actions?
I added a separate step for extracting branch name from $GITHUB_REF and set it to the step output - name: Extract branch name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found