You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
One Click Docker
v1.1.0
There are official Github Actions for Docker related tasks: https://github.com/actions/docker. However it's too slow to have multiple actions that pull & run multiple docker images for those actions one by one. Especially when you are doing simple "build & push" most of the time.
This Github Action does a fixed list of actions:
- (optional) filter the branch for action
- login to your Docker Registry
- build your docker image
- tag the image with
latest
,sha
of the commit,ref
of the commit, or your own tag - push all tags of the image to your registry
Such that you don't have to run 5 different actions, which require the same environment setup (basically Docker) to be repeated again and again.
Arguments passed to the action will be passed to the docker build process. If the argument is left empty, then the docker build process run with the default mode
Below are the required Secrets / Env:
DOCKER_USERNAME
- the username used to log in to your Docker registry.DOCKER_PASSWORD
- the password used to log in to your Docker registry.
Below are the optional Secrets / Env:
BRANCH_FILTER
- the branch to allow the action, default to allow all branchesDOCKER_REGISTRY_URL
- the registry to login & push image to, default to be Docker HubDOCKER_NAMESPACE
- the namespace on the registry, default to be your Github usernameDOCKER_IMAGE_NAME
- the name of the docker image to be built, default to be the namge of the Github repositoryDOCKER_IMAGE_TAG
- the tag of the docker image to be pushed, default to be 3 tags (latest
,sha
of the commit,ref
of the commit)
Below are some additional optional env:
DOCKER_TAG_APPEND
- if this value is set, the defaultref
tag will be appended with this value (e.g.DOCKER_TAG_APPEND=asia-business
for a git master branch push will produce this docker image tag:master_asia-business
)
- simple use case: build image with default tags and push to Docker Hub, where your account name is the same as Github
action "build-and-push-to-docker-hub" {
uses = "pangzineng/Github-Action-One-Click-Docker@master"
secrets = [
"DOCKER_USERNAME",
"DOCKER_PASSWORD"
]
}
- advance use case: custom build path, custom tag and custom private registry with custom namespace
action "build-and-push-to-my-registry" {
uses = "pangzineng/Github-Action-One-Click-Docker@master"
args = "-f my.Dockerfile ./my/custom/folder/"
secrets = [
"DOCKER_USERNAME",
"DOCKER_PASSWORD",
"DOCKER_REGISTRY_URL",
"DOCKER_NAMESPACE"
]
env = {
BRANCH_FILTER = "prod/release"
DOCKER_IMAGE_NAME = "my-image-name"
DOCKER_IMAGE_TAG = "my-image-tag"
}
}