This workflow shows how to use a GitHub Action job output as a variable for another job container image. It will build a simple Docker image, tag it with the commit short SHA, push it to Docker Hub, then run a job in it.
In job.<job_id>.container.image
, the env
context is not available, but we can use outputs.
If your docker metadata action returns multiple tags, I don't know how this would behave.
Instead of using ${{ needs.build.outputs.image_tag }}
, you can use anything, for example:
job:
job1:
outputs:
my_output: ${{ steps.vars.outputs.sha_short }}
steps:
- id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT