Skip to content
tag

GitHub Action

Docker Tags by SemVer

v1.0.5 Latest version

Docker Tags by SemVer

tag

Docker Tags by SemVer

Create Docker tags by Semantic Version

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Tags by SemVer

uses: weseek/ghaction-docker-tags-by-semver@v1.0.5

Learn more about this action in weseek/ghaction-docker-tags-by-semver

Choose a version

DEPRECATED: It is recommended to use docker/build-push-action with docker/metadata-action

Docker tags by SemVer Action

Actions status

This action create multiple docker tags by specified Semantic Version with docker tag command.

However, this action does NOT execute both docker login and docker build. Do it yourself if needed.

Usage

steps:
- uses: weseek/ghaction-docker-tags-by-semver@v1
  with:
    source: 'myimage'
    target: myorg/myimage
    semver: '1.2.3'

exec following command:

docker tag myimage myorg/myimage:1.2.3
docker tag myimage myorg/myimage:1.2
docker tag myimage myorg/myimage:1

Parameters

parameter required default value description
source ✔️ ID or name of the source docker image
docker docs
target ✔️ Name of the target docker image without tag
docker docs
semver ✔️ Semantic Version to create docker tags
suffix Suffix string to add to tag
additional-tags Comma-separated string of tags to append
publish Publish images or not

Examples

Login, Build and Push

steps:

- name: Login to docker.io registry
  run: |
    echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username ${{ secrets. DOCKER_REGISTRY_USERNAME }} --password-stdin

- name: Build image
  run: |
    docker build -t myimage .

- uses: weseek/ghaction-docker-tags-by-semver@v1
  with:
    source: 'myimage'
    target: myorg/myimage
    semver: '1.2.3'
    publish: true

exec following command:

echo ... | docker login --username ... --password-stdin

docker build -t myimage .

docker tag myimage myorg/myimage:1.2.3
docker push myorg/myimage:1.2.3
docker tag myimage myorg/myimage:1.2
docker push myorg/myimage:1.2
docker tag myimage myorg/myimage:1
docker push myorg/myimage:1

With Suffix

steps:
- uses: weseek/ghaction-docker-tags-by-semver@v1
  with:
    source: 'myimage'
    target: myorg/myimage
    semver: '1.2.3'
    suffix: '-nocdn'

exec following command:

docker tag myimage myorg/myimage:1.2.3-nocdn
docker tag myimage myorg/myimage:1.2-nocdn
docker tag myimage myorg/myimage:1-nocdn

Append additional tags

steps:
- uses: weseek/ghaction-docker-tags-by-semver@v1
  with:
    source: 'myimage'
    target: myorg/myimage
    semver: '1.2.3'
    suffix: '-nocdn'
    additional-tags: 'latest,lts'

exec following command:

docker tag myimage myorg/myimage:1.2.3-nocdn
docker tag myimage myorg/myimage:1.2-nocdn
docker tag myimage myorg/myimage:1-nocdn
docker tag myimage myorg/myimage:latest-nocdn
docker tag myimage myorg/myimage:lts-nocdn

Release Candidate

If semver ends with -RC, tag with timestamp is created automatically.

steps:
- uses: weseek/ghaction-docker-tags-by-semver@v1
  with:
    source: 'myimage'
    target: myorg/myimage
    semver: '1.2.4-RC'

exec following command:

docker tag myimage myorg/myimage:1.2.4-RC
docker tag myimage myorg/myimage:1.2.4-RC.20200703090000

License

The scripts and documentation in this project are released under the MIT License