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 totrue
orfalse
, this option allows to set if builds of tags should get thelatest
tag. 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 thelatest
tag. This default to an empty string, meaning thelatest
tag 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.version
label.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 thetags
parameter of thedocker/build-push-action@v2
.created
- The date this image was created. This is meant to populate theorg.opencontainers.image.created
label.docker-secret
- The same value that was provided in theregistry-secret
input.has-docker-secret
- A boolean value that is settrue
in case the inputregistry-secret
is 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 }}