3.6 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			3.6 KiB
		
	
	
	
	
	
	
	
Upgrade notes
v1 to v2
- Input 
pathis now calledcontextfor consistency with other Docker build tools pathdefaults to current git repository so checkout action is not required in a workflow- Rename 
dockerfileinput tofilefor consistency with other Docker build tools - Rename 
always_pullinput topullfor consistency with other Docker build tools - Add 
builderinput to be able to choose a builder instance through our setup-buildx action - Add 
platformsinput to support multi-platform builds - Add 
allowinput - Add 
loadinput - Add 
outputsinput - Add 
cache-frominput (cache_fromsremoved) - Add 
cache-toinput - Rename 
build_argsinput tobuild-argsfor consistency with other Docker build tools - Add 
secretsinput - Review 
tagsinput - Remove 
repositoryinput. See Simple workflow for migration - Remove 
username,passwordandregistryinputs. Login support moved to docker/login-action repo - Remove 
tag_with_sha,tag_with_ref,add_git_labelsinputs. See Tags with ref and Git labels for migration - Handle Git context
 - Add 
digestoutput 
Simple workflow
# v1
steps:
  -
    name: Checkout
    uses: actions/checkout@v2
  -
    name: Build and push Docker images
    uses: docker/build-push-action@v1
    with:
      username: ${{ secrets.DOCKER_USERNAME }}
      password: ${{ secrets.DOCKER_PASSWORD }}
      repository: myorg/myrepository
      always_pull: true
      build_args: arg1=value1,arg2=value2
      cache_froms: myorg/myrepository:latest
      tags: latest
# v2
steps:
  -
    name: Checkout
    uses: actions/checkout@v2
  -
    name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v1
  -
    name: Login to DockerHub
    uses: docker/login-action@v1
    with:
      username: ${{ secrets.DOCKER_USERNAME }}
      password: ${{ secrets.DOCKER_PASSWORD }}
  -
    name: Build and push
    uses: docker/build-push-action@v2
    with:
      context: .
      pull: true
      push: true
      build-args: |
        arg1=value1
        arg2=value2
      cache-from: type=registry,ref=myorg/myrepository:latest
      cache-to: type=inline
      tags: myorg/myrepository:latest
Tags with ref and Git labels
# v1
steps:
  -
    name: Checkout
    uses: actions/checkout@v2
  -
    name: Build and push Docker images
    uses: docker/build-push-action@v1
    with:
      username: ${{ secrets.DOCKER_USERNAME }}
      password: ${{ secrets.DOCKER_PASSWORD }}
      repository: myorg/myrepository
      push: ${{ github.event_name != 'pull_request' }}
      tag_with_ref: true
      tag_with_sha: true
      add_git_labels: true
# v2
steps:
  -
    name: Checkout
    uses: actions/checkout@v2
  -
    name: Docker meta
    id: meta
    uses: docker/metadata-action@v3
    with:
      images: |
        myorg/myrepository
      tags: |
        type=ref,event=branch
        type=ref,event=pr
        type=semver,pattern={{version}}
        type=sha
  -
    name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v1
  -
    name: Login to DockerHub
    if: github.event_name != 'pull_request'
    uses: docker/login-action@v1 
    with:
      username: ${{ secrets.DOCKER_USERNAME }}
      password: ${{ secrets.DOCKER_PASSWORD }}
  -
    name: Build and push
    uses: docker/build-push-action@v2
    with:
      context: .
      push: ${{ github.event_name != 'pull_request' }}
      tags: ${{ steps.meta.outputs.tags }}
      labels: ${{ steps.meta.outputs.labels }}