Skip to content

Latest commit

 

History

History

build-image

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Build and push Docker image GitHub Action

This GitHub Action builds a Docker image and pushes it to a registry. It also sets up the base image, tags the image with various references, and uses Buildx to build multi-arch images if enabled.

Inputs

Name Description Required Default Value
repo Repository name. Defaults to git repository name. No
registry Registry name. No
platforms Build multi-arch image. No
build-args Extra arguments to pass to Docker. No
context Build context. No .
dockerfile Dockerfile path. No Dockerfile
push Push image to registry. No false
cache Cache image layers if buildx enabled. No true

Outputs

Name Description Example
image Docker image docker.pkg.github.com/repo/image
uri Docker image docker.pkg.github.com/repo/image:123abc
repo Repository name repo
branch Branch name main

Usage

name: CI/CD Pipeline

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:

    - name: Checkout code
      uses: actions/checkout@v3

    - name: Duplo Setup
      uses: duplocloud/actions/setup@main

    - name: Build and Push Docker Image
      uses: duplocloud/actions/build-image@main
      with:
        repo: my-repo
        registry: my-registry
        platforms: linux/amd64,linux/arm64
        build-args: >
          --build-arg MY_VAR=value
        context: ./app
        dockerfile: Dockerfile.dev
        push: true
        cache: true

References