Skip to content
name: Build and push Docker image to GHCR
on:
workflow_dispatch:
release:
branches: [ master ]
types: [ published ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
build_and_push_image:
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
latest
labels: |
org.opencontainers.image.vendor="Rumen Nikiforov"
org.opencontainers.image.url="https://github.com/nikiforov-soft/ble-to-mqtt"
org.opencontainers.image.title="BLE to MQTT bridge"
org.opencontainers.image.description="Send all Bluetooth Low Energy events to MQTT topic"
org.opencontainers.image.documentation="https://github.com/nikiforov-soft/ble-to-mqtt"
- name: Build and push image to GHCR
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
VERSION=${{ env.VERSION }}
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}