This generates several variables that can be used when creating docker images.
jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: Illarion-eV/Illarion-Docker-Version@v1
id: docker-vars
with:
registry-secret: ${{ secrets.GITHUB_TOKEN }}image-name- The base name of the image, including the registry but excluding any tags. It defaults to "ghcr.io" for the registry and the repository owner and name for the image name.latest-on-tags- Set totrueorfalse, this option allows to set if builds of tags should get thelatesttag. This default totrue.latest-on-branches- A regular expression that needs to match the name of the branch that is currently build, to have the action set thelatesttag. This default to an empty string, meaning thelatesttag is not set for any branch.registry-secret- This variable may be populated with the secret that should be used to authenticate with the registry. This action doesn't perform any authentication, it's just use to set a variable determining if the secret is available.
version- The version information for the image. This value is meant to populate theorg.opencontainers.image.versionlabel.tags- A comma separated list of the image name along with all the tags that are genenerated for the image. This is meant to be provided to thetagsparameter of thedocker/build-push-action@v2.created- The date this image was created. This is meant to populate theorg.opencontainers.image.createdlabel.docker-secret- The same value that was provided in theregistry-secretinput.has-docker-secret- A boolean value that is settruein case the inputregistry-secretis not empty.
jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: Illarion-eV/Illarion-Docker-Version@v1
id: docker-vars
with:
registry-secret: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub
if: ${{ steps.docker-vars.outputs.has-docker-secret }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ steps.docker-vars.outputs.docker-secret }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: ${{ steps.docker-vars.outputs.has-docker-secret }}
tags: ${{ steps.docker-vars.outputs.tags }}
labels: |
org.opencontainers.image.version=${{ steps.docker-vars.outputs.version }}
org.opencontainers.image.created=${{ steps.docker-vars.outputs.created }}