From 5dd5adf6f20a12e8a571a64c345eb42341e980ca Mon Sep 17 00:00:00 2001 From: Tobias Hargesheimer Date: Sun, 1 Dec 2024 21:48:38 +0100 Subject: [PATCH] cleanup --- .../build_docker_images-c-mqtt-forwarder.yaml | 36 +++++++++---------- .../build_docker_images-mqtt-forwarder.yaml | 27 +++++++------- c-mqtt-forwarder.alpine.Dockerfile | 2 +- mqtt-forwarder.scratch.Dockerfile | 4 +-- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build_docker_images-c-mqtt-forwarder.yaml b/.github/workflows/build_docker_images-c-mqtt-forwarder.yaml index 6ad4693..e59a999 100644 --- a/.github/workflows/build_docker_images-c-mqtt-forwarder.yaml +++ b/.github/workflows/build_docker_images-c-mqtt-forwarder.yaml @@ -29,26 +29,23 @@ jobs: BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}" COMMIT_HASH=${GITHUB_SHA::8} - GIT_URL=$(echo "${GITHUB_SERVER_URL}" | awk -F/ '{print $3}' | sed 's/\/*$//') - GIT_URL=$(echo "$GIT_URL" | sed 's/github\.com/ghcr\.io/g') # GIT_URL switch to ghcr.io registry for GitHub - GIT_REPO=${GITHUB_REPOSITORY,,} - GIT_REPO_SHORT=${GIT_REPO#*/} - GIT_REPO_SHORT=${GIT_REPO_SHORT#"docker-"} - DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GIT_REPO_SHORT} - REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GIT_REPO_SHORT} - - echo "ENVs: BUILD_DATE=${BUILD_DATE}, BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}, COMMIT_HASH=${COMMIT_HASH}, GIT_URL=${GIT_URL}, GIT_REPO=${GIT_REPO}" + 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 "git_url=${GIT_URL}" >> "$GITHUB_OUTPUT" - echo "git_repo=${GIT_REPO}" >> "$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" # c-mqtt-forwarder + #C_MQTT_FORWARDER_VERSION=$(git ls-remote --tags "https://git.ypbind.de/repository/c-mqtt-forwarder.git" | awk -F/ '{print $NF}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1) + #C_MQTT_FORWARDER_VERSION=$(curl -s "https://git.ypbind.de/cgit/c-mqtt-forwarder/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) C_MQTT_FORWARDER_VERSION="1.0.0" echo "c_mqtt_forwarder_version=${C_MQTT_FORWARDER_VERSION}" >> "$GITHUB_OUTPUT" @@ -61,24 +58,24 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3 - - name: Login to GIT Container Registry - uses: docker/login-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 with: - registry: ${{ steps.script.outputs.git_url }} + registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to DockerHub Container Registry - uses: docker/login-action@v3 + - name: Login to DockerHub + uses: docker/login-action@v2 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 + uses: docker/login-action@v2 with: registry: quay.io username: ${{ secrets.REDHAT_QUAY_USERNAME }} @@ -98,8 +95,9 @@ jobs: VERSION=${{steps.script.outputs.c_mqtt_forwarder_version}} tags: | docker.io/${{steps.script.outputs.docker_repo}}:c-mqtt-forwarder + docker.io/${{steps.script.outputs.docker_repo}}:c-mqtt-forwarder-${{steps.script.outputs.c_mqtt_forwarder_version}} quay.io/${{steps.script.outputs.redhat_quay_repo}}:c-mqtt-forwarder - ${{steps.script.outputs.git_url}}/${{steps.script.outputs.git_repo}}:c-mqtt-forwarder + ghcr.io/${{steps.script.outputs.github_repo}}:c-mqtt-forwarder #- name: Docker Hub Description # uses: peter-evans/dockerhub-description@v4 diff --git a/.github/workflows/build_docker_images-mqtt-forwarder.yaml b/.github/workflows/build_docker_images-mqtt-forwarder.yaml index ed4d9fd..cd72cca 100644 --- a/.github/workflows/build_docker_images-mqtt-forwarder.yaml +++ b/.github/workflows/build_docker_images-mqtt-forwarder.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Shell-Script id: script @@ -35,28 +35,30 @@ jobs: DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPO_SHORT} REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GITHUB_REPO_SHORT} - # Set output parameters to github action. - echo ::set-output name=build_date::${BUILD_DATE} - echo ::set-output name=build_date_numeric::${BUILD_DATE_NUMERIC} - echo ::set-output name=commit_hash::${COMMIT_HASH} - echo ::set-output name=github_repo::${GITHUB_REPO} - echo ::set-output name=docker_repo::${DOCKER_REPO} - echo ::set-output name=redhat_quay_repo::${REDHAT_QUAY_REPO} + # 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" # mqtt-forwarder + #MQTT_FORWARDER_VERSION=$(git ls-remote --tags "https://git.ypbind.de/repository/mqtt-forwarder.git" | awk -F/ '{print $NF}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1) + #MQTT_FORWARDER_VERSION=$(curl -s "https://git.ypbind.de/cgit/mqtt-forwarder/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) MQTT_FORWARDER_VERSION="1.1.1" echo "mqtt_forwarder_version=${MQTT_FORWARDER_VERSION}" >> "$GITHUB_OUTPUT" - name: Set up QEMU id: qemu - uses: docker/setup-qemu-action@v2 + 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@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -80,7 +82,7 @@ jobs: password: ${{ secrets.REDHAT_QUAY_PASSWORD }} - name: Build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: builder: ${{ steps.buildx.outputs.name }} context: . @@ -93,11 +95,12 @@ jobs: VERSION=${{steps.script.outputs.mqtt_forwarder_version}} tags: | docker.io/${{steps.script.outputs.docker_repo}}:mqtt-forwarder + docker.io/${{steps.script.outputs.docker_repo}}:mqtt-forwarder-${{steps.script.outputs.mqtt_forwarder_version}} quay.io/${{steps.script.outputs.redhat_quay_repo}}:mqtt-forwarder ghcr.io/${{steps.script.outputs.github_repo}}:mqtt-forwarder #- name: Docker Hub Description - # uses: peter-evans/dockerhub-description@v3 + # uses: peter-evans/dockerhub-description@v4 # with: # username: ${{ secrets.DOCKER_USERNAME }} # password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/c-mqtt-forwarder.alpine.Dockerfile b/c-mqtt-forwarder.alpine.Dockerfile index bc1f152..1d64db0 100644 --- a/c-mqtt-forwarder.alpine.Dockerfile +++ b/c-mqtt-forwarder.alpine.Dockerfile @@ -110,7 +110,7 @@ COPY <