Skip to content

refactor(actions): leverage docker/metadata-action #28

refactor(actions): leverage docker/metadata-action

refactor(actions): leverage docker/metadata-action #28

name: Build & Publish
on:
push:
branches:
- "master"
jobs:
test:
runs-on: ubuntu-24.04
strategy:
matrix:
version:
- {
rel: 3.21,
dnsmasq: 2.90-r3,
tag: latest,
}
- {
rel: 20240923,
dnsmasq: 2.90-r3,
tag: edge,
}
steps:
- uses: actions/checkout@v4
- name: Check credentials
id: docker-credentials
run: |
echo "defined=$(test -n "${{ secrets.DOCKERHUB_USERNAME }}" && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: steps.docker-credentials.outputs.defined == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/dnsmasq
tags: |
${{ matrix.version.dnsmasq }}-alpine-${{ matrix.version.rel }}
${{ matrix.version.dnsmasq }}-alpine-${{ matrix.version.tag }}
${{ matrix.version.rel != 'edge' && format('{0}', matrix.version.dnsmasq) || '' }}
${{ matrix.version.tag }}
- name: Build and push
if: steps.docker-credentials.outputs.defined == 'true'
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
build-args: ALPINE_VERSION=${{ matrix.version.rel }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}