Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Latest commit

 

History

History
87 lines (70 loc) · 3.91 KB

README.md

File metadata and controls

87 lines (70 loc) · 3.91 KB

Info

Actions Status Actions Status Docker Pulls

This Action for Docker uses the SemVer version for image tagging.
That means that if you are pushing an image: docker push myimage:1.4.2
It will be tagged as latest and pushed, but also images:

  • myimage:1.4
  • myimage:1 will be tagged as latest and pushed.

This way when you specify in your Docker file:
FROM myimage:latest
you will pull version 1.4.2, but if you specify:
FROM myimage:1.4 or
FROM myimage:1
you will also pull the version 1.4.2

Now lets image that there is an image with version 1.3.6 and also 1.4.0 if you specify:
FROM myimage:1.3
it will pull the 1.3.6 (assuming that next version is 1.4.x) and if you specify:
FROM myimage:1.4.0
it will pul the version 1.4.0 although there is a more recent release (1.4.2).

This might not be useful to everyone but it does suite my needs.

Usage

name: Docker SemVer
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Publish to Registry
      uses: mirzamerdovic/docker-semver-github-action@master
      with:
        name: myDocker/repository
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        semver: 1.2.5

Arguments

Required:
name is the name of the image you would like to push
username the login username for the registry
password the login password for the registry

Optional:
semver: the tag name e.g. 1.2.3 (if ommited latest will be used as tag) dockerfile: when you would like to explicitly build a Dockerfile workdir if you need to change the work directory context when you would like to change the Docker build context. buildargs when you want to pass a list of environment variables as build-args. Identifiers are separated by comma.

Output

tag is the tag, which was pushed

Automatic versions via VERSION file

Action also supports a way of automatic version using the VERSION file.

VERSION file is a simple text file that contains the version number for example:
1.4.12

The action will try to extract the file from built image, so if you want to use it you will need to add it as a part of your repository and your Dockerfile.
Let's imagine that you have a VERSION file in the same folder as the Dockerfile. In the Dockerfile you'd need to add a line:
ADD VERSION .
so the VERSION file gets copied.

If you have done all this the action will extract the VERSION file and read the version value that will be used as a tag for your image.
If you think that all this is bollocks your build will still work without adding the VERSION file.

What's missing?

  • I have no support for properly tagging images built from branches or PRs one would expect to be able to just specify 1.4.5 and when you are pushing an image from a branch to get a tag: 1.4.5-mybranch same goes for PR Current workaround for that is that you specify the suffix yourself.
  • More tests

Credits

I need to say a big thank you to elghor who made Publish-Docker-Github-Action that I forked and built this one from. He also has some other useful actions that you might one to check out.