GitHub Action used to build, tag and publish docker image to your docker registry.
https://github.com/marketplace/actions/publish-docker-action
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 repository 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-actionThis will build and push the tag docker.pkg.github.com/jerray/publish-docker-action:latest.
You 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.
docker.pkg.github.com/jerray/publish-docker-action:latestdocker.pkg.github.com/jerray/publish-docker-action:newestdocker.pkg.github.com/jerray/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.
Additionally, there's an output value tag you can use in your next steps.
- id: build
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
- id: deploy
env:
NEW_VERSION: ${{ steps.build.outputs.tag }}
run: |
docker pull $NEW_VERSIONProvide 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=nginxProvide with.target argument to set --target flag for docker build.
Please use the latest released version rather than master.
from https://github.com/jerray/publish-docker-action
No comments:
Post a Comment