This workflow is named Docker Build and Publish
. It is designed to build and publish Docker images.
This workflow is triggered when it is called from another workflow.
context
: Path to the build context. Default is.
.dockerfile
: Path to the Dockerfile to build. Default isDockerfile
.image-name
: Name of the image to build. This is a required input.
DOCKER_HUB_USERNAME
: Required for the workflow.DOCKER_HUB_PASSWORD
: Required for the workflow.
build-publish
: Builds and publishes the Docker image. The image is tagged withlatest
and the version from the Maven project. The image is built forlinux/amd64
andlinux/arm64
platforms.
This workflow is designed to be called from another workflow. It is not intended to be used on its own.
name: Docker Build and Publish
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
jobs:
build-publish:
uses: mekomsolutions/shared-github-workflow/.github/workflows/docker-build-publish.yml@main
with:
context: . # Optional default value: .
dockerfile: Dockerfile # Optional default value: Dockerfile
image-name: my-image # Required
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
Replace my-image
with the name of the Docker image you want to build and publish. You also need to set the DOCKER_HUB_USERNAME
and DOCKER_HUB_PASSWORD
secrets in your repository settings.
For more information about reusable workflows, see the official GitHub documentation: https://docs.github.com/en/actions/using-workflows/reusing-workflows.