name: Docker Image
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish to Registry
uses: sergeysova/docker-publish-action@master
with:
image: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Checkout releases and use it instead of @master
branch in uses
.
image
username
password
with:
image: owner/image
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry
GitHub's Docker registry uses a different path format. See Configuring Docker for use with GitHub Package Registry
with:
image: owner/repository/image
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
dockerfile
This might be useful when you hanve multiple Dockerfiles in one repo.
with:
image: owner/image
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: project.Dockerfile
context
Use context
when you would like to change the Docker build context.
with:
image: owner/image
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
context: directory/of/the/context
workdir
Use workdir
when you would like to change the directory for building.
with:
image: owner/image
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
workdir: project/subdirectory
buildargs
Use buildargs
when you want to pass a list of environment variables as build-args. Identifiers are separated by space.
All buildargs
will be masked, so that they don't appear in the logs.
- name: Publish to Registry
uses: sergeysova/docker-publish-action@master
env:
FOO: ${{ secrets.FOO_CONTENT }}
BAR: AnotherSecretValue
with:
image: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
buildargs: FOO BAR
buildoptions
Use buildoptions
when you want to configure options for building.
- name: publish docker image
uses: sergeysova/docker-publish-action@master
with:
image: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
buildoptions: "--compress --force-rm"
buildkit
Enable buildkit to be used when building the image.
- name: publish docker image
uses: sergeysova/docker-publish-action@master
with:
image: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
buildkit: true
cache
true
| false
false
Use cache when you have big images, that you would only like to build partially (changed layers).
CAUTION: Docker builds will cache non-repoducable commands, such as installing packages. If you use this option, your packages will never update. To avoid this, run this action on a schedule with caching disabled to rebuild the cache periodically.
Example:
name: Publish to Registry
on:
push:
branches:
- master
schedule:
- cron: "0 2 * * 0" # Weekly on Sundays at 02:00
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: publish docker image
uses: sergeysova/docker-publish-action@master
with:
image: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
cache: ${{ github.event_name != 'schedule' }}
snapshot
true
| false
false
Build image also with tag 20200405-124909-5b9727
(date-time-hash)
tag_extra
Build an image with another tags. To set multiple use space.
If changes were on master, added tag latest
Example:
with:
tag_extra: foo
# multiple
tag_extra: foo bar
tag_separator
Parses git tag as two parts project name and version.
Example:
with:
tag_separator: "@"
Input | Parsed |
---|---|
[email protected] |
project name: project-name version: v1.2.3
|
highway/car@demo |
project name: highway/car version: demo
|
tag_semver
"skip"
| "fail"
Parses git tag as semver v1.2.3
or 1.2.3
or 1.2.3-something
and push docker tag 1.2.3
.
Value | Description |
---|---|
Default | Do nothing with tag |
"skip" |
If tag is not a semver, do not push tag. |
"fail" |
If tag is not a semver, fail the build. |
If used with tag_separator
parses version as semver:
Input | Version |
---|---|
[email protected] |
1.2.3 |
[email protected] |
1.2.3-alpha |
Example:
with:
tag_semver: skip
semver_higher
tag_semver
true
| false
false
Also push tags with higher version updates.
Input | Tags |
---|---|
v1.2.3 |
1.2.3 , 1.2 , 1
|
v1.2.3-alpha |
1.2.3-alpha , 1.2-alpha , 1-alpha
|
v1.2.3-beta.1-int.2 |
1.2.3-beta.1-int.2 , 1.2.3-beta.1-int , 1.2.3-beta , 1.2-beta , 1-beta
|
v1.2.3-4.5.6 |
1.2.3-4.5.6 , 1.2.3-4.5 , 1.2.3-4 , 1.2-4 , 1-4
|
Example:
with:
semver_higher: true
cache
to build only changed layers for big docker imagesprojectAppend
append project from tag with separator to image namedocker login
with --password-stdin
when applicable