Skip to content

DSMR: Build Docker images #188

DSMR: Build Docker images

DSMR: Build Docker images #188

Workflow file for this run

name: "DSMR: Build Docker images"
on:
# push:
# branches:
# - develop
# - main
# paths-ignore:
# - "**.md"
# pull_request:
# branches:
# - develop
# - main
# types:
# - closed
# paths-ignore:
# - "**.md"
workflow_dispatch:
concurrency:
group: docker-build
cancel-in-progress: true
env:
DOCKER_TARGET_REPO: xirixiz/dsmr-reader-docker
DOCKERFILE: Dockerfile
DOCKER_TARGET_RELEASE: 2024.04.01
jobs:
################################################
## JOB: BUILD_RELEASE
################################################
build_release:
runs-on: ubuntu-latest
steps:
################################################
## GENERAL
################################################
- name: "πŸš€ GitHub - Checkout repository"
uses: actions/checkout@v4
- name: "πŸš€ GitHub - Get Branch / Tag Name"
id: get_branch
run: |
export RELEASE_NAME=$(if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; \
then echo ${GITHUB_REF/refs\/tags\//}; \
else echo ${GITHUB_REF/refs\/heads\//}; fi)
echo "${RELEASE_NAME}"
echo "NAME=${RELEASE_NAME}" >>$GITHUB_OUTPUT
- name: "πŸš€ GitHub - Get Tag"
id: get_tag
run: |
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.name }}" = "main" ]; \
then echo "${{ matrix.DOCKER_TAG_SUFFIX }}"; \
else echo "${{ matrix.DOCKER_TAG_SUFFIX }}-${{ steps.get_branch.outputs.name }}"; \
fi;)
echo "${TARGET_IMAGE_TAG}"
echo "NAME=${TARGET_IMAGE_TAG}" >>$GITHUB_OUTPUT
################################################
## QEMU
################################################
- name: "βš™οΈ QEMU - Set up QEMU"
uses: docker/setup-qemu-action@v3
################################################
## DSMR
################################################
- name: "βš™οΈ DSMR - Determine version"
id: dsmr_version
shell: bash
run: |
URL='https://api.github.com/repos/dsmrreader/dsmr-reader/releases/latest'
VERSION=$(curl -SskLf "${URL}" | jq -r '.tag_name')
DOWNLOAD_URL=$(curl -SskLf "${URL}" | jq -r '.tarball_url')
# VERSION="5.0.0"
VERSION=${VERSION#"v"}
echo "version=${VERSION}" >>$GITHUB_OUTPUT
################################################
## Docker
################################################
- name: "βš™οΈ Docker - Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "πŸ”“ Docker - Login"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: "πŸ”“ Docker - Login to GHCR"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "βš™οΈ Docker - Set up metadata"
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=raw,value=${{ steps.dsmr_version.outputs.version }}-${{ env.DOCKER_TARGET_RELEASE }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=development,enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
images: |
${{ env.DOCKER_TARGET_REPO }}
ghcr.io/${{ env.DOCKER_TARGET_REPO }}
- name: "πŸš€ Docker - Build"
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |-
DSMR_VERSION=${{ steps.dsmr_version.outputs.version }}
DOCKER_TARGET_RELEASE=${{ env.DOCKER_TARGET_RELEASE }}