GitHub Action used to build, tag and publish docker image to your docker registry
50K+
Publish Docker Action is used to build, tag and publish docker image to your docker registry.
This simple example will use Dockerfile in your workspace to build image, attach the latest
tag and push to docker default registry (docker.io). Repository name is your GitHub repository
name by default.
- uses: jerray/publish-docker-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Use file and path arguments to set docker build file or build context if they are not placed
in the default workspace direcotry.
Registry and repository name can be changed with registry and repository arguments. For example:
- uses: jerray/publish-docker-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: docker.pkg.github.com
repository: jerray/publish-docker-action
You can use static tag list by specify tags arguments. Tag names must be separated by comma.
- uses: jerray/publish-docker-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: docker.pkg.github.com
repository: jerray/publish-docker-action
tags: latest,newest,master
Example above will build image and create three tags, and push all of them to the registry.
jerray/publish-docker-action:latestjerray/publish-docker-action:newestjerray/publish-docker-action:masterThis action can generate image tag automatically base on the different refs type.
If the refs refers to a branch, it uses the branch name as docker image name (master branch is renamed to latest).
If the refs refers to a pull request, it attaches a pr- prefix to branch name as
docker image tag. To allow pull request build, you must set with.allow_pull_request to true.
When refs refers to a tag, it checks if the tag name is valid semantic version. If not, it uses
tag name as docker image tag directly. Else it generates three tags based on the version number,
each followed with pre-release information if there is any. For example:
1.0.0 is mapped to 1, 1.0, 1.0.0v1.0.0 is the same as above (prefix v is allowed)v1.0.0-rc1 is mapped to 1-rc1, 1.0-rc1, 1.0.0-rc120190921-actions is not a valid semantic version string, so docker image tag is just the same- uses: jerray/publish-docker-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: docker.pkg.github.com
repository: jerray/publish-docker-action
auto_tag: true
Auto tagging will override with.tags list.
Cache image can be used to build image. Just provide with.cache argument.
Content type
Image
Digest
Size
64.4 MB
Last updated
over 6 years ago
docker pull jerray/publish-docker-action