Capture output from Docker Build-Push step

I need to capture some output from a Docker build-push step, and use that output in future steps. My Dockerfile calls a PowerShell script. Somewhere inside this PowerShell script, I need to “send” some output back to my GitHub Actions workflow.

What is the best way to accomplish this?

  1. I have already tried setting the GITHUB_ENV environment variable inside the container build, which didn’t work. In the PowerShell build script, I tried:
  1. I have also tried using the special syntax to set a workflow output, using the GitHub Actions Toolkit. That also did not work.
::set-output name=MODULE_VERSION::xxxxxxxxxx
  1. I looked into using the /github/workspace directory, but that is only mounted for container runs, not container builds using docker-build-push-action.

Bottom line is, how do I get some simple string data from inside the container image build, and expose that to my GitHub Actions workflow?

The answer is unfortunately “you don’t”, at least not when using a pre-made action for the build. I’m not familiar with the docker-build-push-action, but if it doesn’t expose that information you can’t get it (except maybe by downloading and analyzing the job logs after).

Can you get the required information from the container image after it’s been built? In your posts I see you’re trying to get a MODULE_VERSION, maybe you could do something like this (assuming the information is in a file somewhere, you could also call tool --version or something):

docker run --rm --entrypoint /bin/cat your-container /module/version/info