2025-12-21 23:34:01 +01:00
2025-12-21 23:34:01 +01:00
2025-12-21 23:34:01 +01:00

🏗️ Build and Push Docker Image Action

A composite action that simplifies building and pushing Docker images using Docker Buildx. It handles setting up Buildx, logging into the registry, and performing the build and push operation with caching support.


Features

  • 🧰 Automatic Buildx Setup: Sets up Docker Buildx for multi-platform builds and advanced features.
  • 🔑 Registry Authentication: Handles login to any Docker registry.
  • 🚀 Build & Push: Builds the image and pushes it to the registry (configurable).
  • 💾 Caching: Uses registry-based caching (type=registry) to speed up builds.
  • 📝 Flexible Configuration: Supports custom Dockerfiles, build contexts, and tags.

📥 Inputs

Input Description Required Default
image_name Full image name (including registry) used for caching references Yes -
registry Docker registry URL Yes -
username Registry username Yes -
password Registry password Yes -
tags List of tags (comma separated) Yes -
dockerfile Path to the Dockerfile No Dockerfile
context Build context No .
push Whether to push the image No true

🛠️ Example Usage

- name: Build and push image 🏗️
  uses: your-org/build-push-action@main
  with:
    image_name: ${{ vars.REMOTE_REGISTRY_URL }}/${{ vars.REMOTE_REGISTRY_NAMESPACE }}/my-app
    registry: ${{ vars.REMOTE_REGISTRY_URL }}
    username: ${{ vars.REMOTE_REGISTRY_USERNAME }}
    password: ${{ secrets.REMOTE_REGISTRY_PASSWORD }}
    tags: ${{ steps.meta.outputs.tags }}
    dockerfile: Dockerfile
    context: .
    push: true

🧑‍💻 How It Works

This action performs the following steps:

  1. 🧰 Set up Docker Buildx: Initializes the Docker Buildx builder.
  2. 🔑 Login to Registry: Authenticates with the specified Docker registry.
  3. 🏗️ Build and Push:
    • Builds the Docker image using the specified context and Dockerfile.
    • Applies the provided tags.
    • Pushes the image to the registry (if push is true).
    • Uses inline caching and registry caching (cache-from) to optimize build times.

📜 License

This action is open-source software licensed under the MIT license.


Happy building! 🚀

Grand

Description
No description provided
Readme 29 KiB