Skip to content

build docker images: prometheus-mqtt-transport #21

build docker images: prometheus-mqtt-transport

build docker images: prometheus-mqtt-transport #21

name: 'build docker images: prometheus-mqtt-transport'
on:
#push:
# branches:
# - 'main'
# - 'master'
# paths:
# - 'prometheus-mqtt-transport.debian.Dockerfile'
# - '.github/workflows/build_docker_images-prometheus-mqtt-transport.yaml'
workflow_dispatch:
schedule:
- cron: '30 6 25 * *' # At 06:30 on day-of-month 25.
defaults:
run:
shell: bash
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Shell-Script
id: script
run: |
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}"
COMMIT_HASH=${GITHUB_SHA::8}
GITHUB_REPO=${GITHUB_REPOSITORY,,}
GITHUB_REPO_SHORT=${GITHUB_REPO#*/}
GITHUB_REPO_SHORT=${GITHUB_REPO_SHORT#"docker-"}
DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPO_SHORT}
REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GITHUB_REPO_SHORT}
# Set output parameters to action.
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT"
echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT"
echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT"
echo "github_repo=${GITHUB_REPO}" >> "$GITHUB_OUTPUT"
echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT"
echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT"
# prometheus-mqtt-transport
#PROMETHEUS_MQTT_TRANSPORT_VERSION=$(git ls-remote --tags "https://git.ypbind.de/repository/prometheus-mqtt-transport.git" | awk -F/ '{print $NF}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1)
#PROMETHEUS_MQTT_TRANSPORT_VERSION=$(curl -s "https://git.ypbind.de/cgit/prometheus-mqtt-transport/refs/" | grep -oE '/tag/\?h=[0-9]+\.[0-9]+\.[0-9]+' | sed -E 's|.*/tag/\?h=([0-9]+\.[0-9]+\.[0-9]+)|\1|' | sort -V | tail -n1)
PROMETHEUS_MQTT_TRANSPORT_VERSION="1.0.0"
echo "prometheus_mqtt_transport_version=${PROMETHEUS_MQTT_TRANSPORT_VERSION}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to RED HAT Quay.io Container Registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.REDHAT_QUAY_USERNAME }}
password: ${{ secrets.REDHAT_QUAY_PASSWORD }}
- name: Build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./prometheus-mqtt-transport.debian.Dockerfile
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
push: true
build-args: |
BUILD_DATE=${{steps.script.outputs.build_date}}
VCS_REF=${{steps.script.outputs.commit_hash}}
VERSION=${{steps.script.outputs.prometheus_mqtt_transport_version}}
tags: |
docker.io/${{steps.script.outputs.docker_repo}}:prometheus-mqtt-transport
docker.io/${{steps.script.outputs.docker_repo}}:prometheus-mqtt-transport-${{steps.script.outputs.prometheus_mqtt_transport_version}}
quay.io/${{steps.script.outputs.redhat_quay_repo}}:prometheus-mqtt-transport
ghcr.io/${{steps.script.outputs.github_repo}}:prometheus-mqtt-transport
#- name: Docker Hub Description
# uses: peter-evans/dockerhub-description@v4
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# repository: ${{steps.script.outputs.docker_repo}}
# short-description: ${{ github.event.repository.description }}
# readme-filepath: README.md