Composite action to build and push docker image into docker registry in the expected format of on-premises k8s-deploy.
- name: Build and push docker image
uses: MP-ES/build-push-action@v1
with:
# Server address of Docker registry. If not set then will default to Docker Hub
# DEFAULT: hub.docker.com
registry: registry.domain.com
# Username used to log against the Docker registry
username: ${{ secrets.USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.PASSWORD }}
# List of build-time variables
build-args: |
arg1=value1
arg2=value2
# Relative path under $GITHUB_WORKSPACE to place the repository checkout code
checkout-path: "."
# Build's context is the set of files located in the specified PATH or URL
context: "."
# Path to the Dockerfile
file: "Dockerfile"
# The name of docker image, generally the same as the project name
image: "service name"
# Control if the image have to be pushed to the registry
# DEFAULT: true
push: "true"
If you have a Dockerfile in the root path with no build args and want to build and push the docker image to a private registry you can write something such as:
- name: Build and push docker image
uses: MP-ES/build-push-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
image: "service name"
Following outputs are available:
Name | Type | Description |
---|---|---|
tag |
String | Tag assigned to docker image |
digest |
String | Image content-addressable identifier also called a digest |
metadata |
JSON | Build result metadata |