@ -6,8 +6,8 @@ on:
# Tags are explicitly ignored on push. We still want branches to be processed, but they won't if
# the `branches` property is missing. See more detail here:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
tags-ignore : [ '*' ]
branches : [ '*' ]
tags-ignore : [ "*" ]
branches : [ "*" ]
paths:
- docker/**
- .github/workflows/docker.yml
@ -18,7 +18,7 @@ on:
- .github/workflows/docker.yml
release:
types : [ published ]
types : [ published ]
workflow_dispatch:
inputs:
@ -33,7 +33,7 @@ on:
type : boolean
env:
SHOULD_PUBLISH : ${{ github.event_name == 'release' || inputs.should_publish == 'true' }}
SHOULD_PUBLISH : ${{ github.event_name == 'release' || inputs.should_publish == 'true' || github.event.push.ref == 'refs/heads/master' }}
VERSION : ${{ github.event.release.tag_name || inputs.release_tag }}
jobs:
@ -43,34 +43,47 @@ jobs:
steps:
- name : Checkout
uses : actions/checkout@v 2
uses : actions/checkout@v 3
- name : Set up QEMU
uses : docker/setup-qemu-action@v 1
uses : docker/setup-qemu-action@v 2
- name : Set up Buildx
uses : docker/setup-buildx-action@v 1
uses : docker/setup-buildx-action@v 2
- name : Extract Image Metadata
- name : Check if tag is a version number
id : check_version
run : |
regex="[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"
if [[ '${{ env.VERSION }}' =~ $regex ]]; then
echo ::set-output name=match::true
else
echo ::set-output name=match::false
fi
- name : Set Version Tags
id : meta
uses : docker/metadata-action@v3
uses : docker/metadata-action@v4
env:
SEMVER : type=semver,enable=${{ steps.check_version.outputs.match }},value=${{ env.VERSION }}
with:
images : ghcr.io/${{ github.repository }}
tags : |
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ env.VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
type=semver,pattern={{major}},value=${{ env.VERSION }}
type=edge,branch=master
${{ env.SEMVER }},pattern={{major}}.{{minor}}.{{patch}}
${{ env.SEMVER }},pattern={{major}}.{{minor}}
${{ env.SEMVER }},pattern={{major}}
- name : Login to GHCR
if : env.SHOULD_PUBLISH
uses : docker/login-action@v 1
uses : docker/login-action@v 2
with:
registry : ghcr.io
username : ${{ github.actor }}
password : ${{ secrets.GITHUB_TOKEN }}
- name : Build & Push Image
uses : docker/build-push-action@v 2
uses : docker/build-push-action@v 3
with:
context : ./docker
push : ${{ env.SHOULD_PUBLISH }}