Publish Docker Action builds, creates tags and pushes docker image to your docker registry.
This simple example uses 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 in the default workspace.
You can set docker registry with registry argument. Change docker repository name with respository argument.
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-actionYou can use static tag list by providing tags argument. Concat multiple tag names with commas.
- 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,masterThis example builds the image, creates three tags, and pushes all of them to the registry.
jerray/publish-docker-action:latestjerray/publish-docker-action:newestjerray/publish-docker-action:master
Set with.auto_tag: true to allow action generate docker image tags automatically.
- 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: trueGenerated tags vary with refs types:
- branch: uses the branch name as docker tag name (
masterbranch is renamed tolatest). - pull request: attaches a
pr-prefix to branch name asdocker image tag. To allow pull request build, you must setwith.allow_pull_requesttotrue. - tag: checks if the tag name is valid semantic version format (prefix
vis allowed). If not, it uses git tag name as docker image tag directly. Else it generates three tags based on the version number, each followed with pre-release information.
Examples:
| Git | Docker Tag |
|---|---|
branch master |
latest |
branch 2019/09/28-new-feature |
2019-09-28-new-feature (/ is replaced to -) |
pull request master |
pr-master |
tag 1.0.0 |
1, 1.0, 1.0.0 |
tag v1.0.0 |
1, 1.0, 1.0.0 |
tag v1.0.0-rc1 |
1-rc1, 1.0-rc1, 1.0.0-rc1 |
tag 20190921-actions |
20190921-actions (not semantic version) |
Auto tagging will override with.tags list.
Provide with.cache argument to build from cache.
Use with.build_args to provide docker build-time variables. Multiple variables 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
build_args: HTTP_PROXY=http://127.0.0.1,USER=nginxPlease use the latest released version rather than master.