following is the example GHA workflow yaml file I'm using. Currently I'm building an pushing docker image to artifact registry. And in the next step I run pytest on the docker image. But for next step it has to pull image which was build in the last step to run pytest. Is there any way I can run pytest without pulling the docker image from registry to save time.
- name: Build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: my_registry:${{ github.run_number }}
cache-from: |
type=registry,ref=my_registry:cache
cache-to: |
type=registry,ref=my_registry:cache,mode=max
- name: Pytest
run: docker run my_registry:${{ github.run_number }} pytest
Have a look at the actions's example on how to share a docker image between jobs.
The action offers an outputs¹ argument:
List of output destinations (format:
type=local,dest=path).¹ multiple
outputsare not yet supported
You can use it to output your image to a tar file which you can load in the next step.
Example:
- name: Build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: my_registry:${{ github.run_number }}
cache-from: |
type=registry,ref=my_registry:cache
cache-to: |
type=registry,ref=my_registry:cache,mode=max
outputs: type=docker,dest=./myimage.tar
- name: Pytest
run: |
docker load --input ./myimage.tar
docker run my_registry:${{ github.run_number }} pytest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With