Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

A GitHub Action to create docker tags by semantic version

Notifications You must be signed in to change notification settings

weseek/ghaction-docker-tags-by-semver

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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