Reputation: 1398
I want to reference the imageid from the docker build using docker/build-push-action@v2 action in my next github action step when deploying to kubernetes using a Helm chart. For now I just want to echo it out in the next part of my github action step.
This is the github documentation link for build-push-action
The following is a snippet of my github action worfklow:
- name: Build and push Docker images
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Print my docker imageid in a separate step
run: echo "imageid"
The following is the output from the docker build-push-action:
#15 pushing layer 54b5e2b53cf2 4.9s done
#15 DONE 4.9s
ImageID
sha256:043e18541***e07db034bd94c5423cbd8f6ea8f045c5c8ccdd97b9254c4b5f11
Digest
sha256:043e18541***e07db034bd94c5423cbd8f6ea8f045c5c8ccdd97b9254c4b5f11
Metadata
{
"containerimage.digest": "sha256:043e18541***e07db034bd94c5423cbd8f6ea8f045c5c8ccdd97b9254c4b5f11"
}
Upvotes: 2
Views: 1926
Reputation: 39470
You can reference the imageId
as described in the output section of the doc. Just add an id at your current job just for reference, as example:
- name: Build and push Docker images
id: docker_build
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Print my docker imageid in a separate step
run: echo "imageid ${{ steps.docker_build.outputs.imageid }}"
Upvotes: 2