Giter Site home page Giter Site logo

throw-if-null / docker-semver-github-action Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 39 KB

GitHub action that build and pushes your images using SemVer tagging.

License: MIT License

Dockerfile 3.80% Shell 96.20%
docker github-action github-actions-docker semver-tag

docker-semver-github-action's Introduction

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.

docker-semver-github-action's People

Contributors

mirzamerdovic avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

danielschulz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.