chore(ci): use `docker/metadata-action` (#756)
* chore(ci): use `docker/metadata-action` - Replace custom `setup-image-vars` action by `docker/metadata-action` - Automatically add latest tag on semver tag Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): add image tag on PR Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): cleanup trailing spaces Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): remove `setup-image-vars` action Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> --------- Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be>
This commit is contained in:
parent
a817997ed8
commit
d34cfaafa1
|
|
@ -1,35 +0,0 @@
|
||||||
name: "Setup Image Variables"
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
dockerfile:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
tag:
|
|
||||||
description: "The tag if run against a tag, otherwise 'canary'"
|
|
||||||
value: ${{ steps.vars.outputs.tag }}
|
|
||||||
suffix:
|
|
||||||
description: "The suffix for the image package name (if any)"
|
|
||||||
value: ${{ steps.vars.outputs.suffix }}
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Get reference and suffix
|
|
||||||
id: vars
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
DOCKERFILE: ${{ inputs.dockerfile }}
|
|
||||||
run: |
|
|
||||||
TAG=${GITHUB_REF##*/}
|
|
||||||
if [[ $GITHUB_REF == refs/heads/main ]]; then
|
|
||||||
TAG=canary
|
|
||||||
elif [[ $GITHUB_REF == refs/pull/*/merge ]]; then
|
|
||||||
TAG=pullrequest # this 'tag' is just used for caching
|
|
||||||
fi
|
|
||||||
echo ::set-output name=tag::${TAG:-canary}
|
|
||||||
SUFFIX=${DOCKERFILE##Dockerfile}
|
|
||||||
if [[ "${SUFFIX}" == "."* ]]; then
|
|
||||||
SUFFIX=${SUFFIX//./-} # convert dots into dashes
|
|
||||||
fi
|
|
||||||
echo ::set-output name=suffix::${SUFFIX}
|
|
||||||
|
|
@ -30,10 +30,13 @@ jobs:
|
||||||
packages: write
|
packages: write
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
dockerfile:
|
image:
|
||||||
- Dockerfile
|
- dockerfile: Dockerfile
|
||||||
- Dockerfile.debian-stable-slim
|
suffix: ""
|
||||||
- Dockerfile.ubuntu
|
- dockerfile: Dockerfile.debian-stable-slim
|
||||||
|
suffix: "-debian-stable-slim"
|
||||||
|
- dockerfile: Dockerfile.ubuntu
|
||||||
|
suffix: "-ubuntu"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
@ -48,11 +51,16 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Set up Image Variables
|
- name: Docker meta
|
||||||
id: vars
|
id: meta
|
||||||
uses: ./.github/actions/setup-image-vars
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
dockerfile: ${{ matrix.dockerfile }}
|
images: ghcr.io/${{ github.repository }}${{ matrix.image.suffix }}
|
||||||
|
flavor: latest=true
|
||||||
|
tags: |
|
||||||
|
type=raw,value=canary,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{raw}}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
|
|
@ -65,10 +73,10 @@ jobs:
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ${{ matrix.dockerfile }}
|
file: ${{ matrix.image.dockerfile }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
|
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
|
||||||
tags: |
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
ghcr.io/${{ github.repository }}${{ steps.vars.outputs.suffix }}:${{ steps.vars.outputs.tag }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue