Permalink
Cannot retrieve contributors at this time
58 lines (53 sloc)
1.58 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
build-push-action/docs/advanced/share-image-jobs.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Share built image between jobs | |
As each job is isolated in its own runner you cannot use your built image between jobs (except for [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners)). | |
However, you can [pass data between jobs in a workflow](https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow) | |
using the [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact) | |
actions: | |
```yaml | |
name: ci | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Build and export | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
tags: myimage:latest | |
outputs: type=docker,dest=/tmp/myimage.tar | |
- | |
name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: myimage | |
path: /tmp/myimage.tar | |
use: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: myimage | |
path: /tmp | |
- | |
name: Load image | |
run: | | |
docker load --input /tmp/myimage.tar | |
docker image ls -a | |
``` |