3
0
Fork 0
mirror of https://gitea.com/docker/build-push-action.git synced 2024-11-29 04:49:37 +01:00
docker-build-push/docs/advanced/share-image-jobs.md
CrazyMax 5645ea7274
Note about new inputs
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-01-18 14:57:36 +01:00

1.6 KiB

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). However, you can pass data between jobs in a workflow using the actions/upload-artifact and actions/download-artifact actions:

name: ci

on:
  push:
    branches:
      - 'main'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Build and export
        uses: docker/build-push-action@v2
        with:
          context: .
          tags: myimage:latest
          outputs: type=docker,dest=/tmp/myimage.tar
      -
        name: Upload artifact
        uses: actions/upload-artifact@v2
        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@v1
      -
        name: Download artifact
        uses: actions/download-artifact@v2
        with:
          name: myimage
          path: /tmp
      -
        name: Load image
        run: |
          docker load --input /tmp/myimage.tar
          docker image ls -a