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:
Ronny Moreas
2023-03-20 08:14:51 +08:00
committed by GitHub
parent a817997ed8
commit d34cfaafa1
2 changed files with 19 additions and 46 deletions
+19 -11
View File
@@ -30,10 +30,13 @@ jobs:
packages: write
strategy:
matrix:
dockerfile:
- Dockerfile
- Dockerfile.debian-stable-slim
- Dockerfile.ubuntu
image:
- dockerfile: Dockerfile
suffix: ""
- dockerfile: Dockerfile.debian-stable-slim
suffix: "-debian-stable-slim"
- dockerfile: Dockerfile.ubuntu
suffix: "-ubuntu"
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -48,11 +51,16 @@ jobs:
with:
version: latest
- name: Set up Image Variables
id: vars
uses: ./.github/actions/setup-image-vars
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
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
uses: docker/login-action@v1
@@ -65,10 +73,10 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.dockerfile }}
file: ${{ matrix.image.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
tags: |
ghcr.io/${{ github.repository }}${{ steps.vars.outputs.suffix }}:${{ steps.vars.outputs.tag }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max