From ca5dd2a5630f6ad176e674ac1b9a42e7852d4836 Mon Sep 17 00:00:00 2001 From: Tobias Hargesheimer Date: Mon, 11 Nov 2024 23:48:43 +0100 Subject: [PATCH] irc-exporter --- .../build_docker_images-ircd-exporter.yaml | 106 ++++++++++++++++++ .../build_docker_images-ircd-exportery.yaml | 93 --------------- ...erfile => ircd-exporter.scratch.Dockerfile | 2 +- 3 files changed, 107 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/build_docker_images-ircd-exporter.yaml delete mode 100644 .github/workflows/build_docker_images-ircd-exportery.yaml rename ircd-exporter.Dockerfile => ircd-exporter.scratch.Dockerfile (94%) diff --git a/.github/workflows/build_docker_images-ircd-exporter.yaml b/.github/workflows/build_docker_images-ircd-exporter.yaml new file mode 100644 index 0000000..529ef20 --- /dev/null +++ b/.github/workflows/build_docker_images-ircd-exporter.yaml @@ -0,0 +1,106 @@ +name: 'build docker images: ircd-exporter' + +on: + #push: + # branches: + # - 'main' + # - 'master' + # paths: + # - 'ircd-exporter.Dockerfile' + # - '.github/workflows/build_docker_images-ircd-exporter.yaml' + workflow_dispatch: + schedule: + - cron: '30 5 28 * *' # At 05:30 on day-of-month 28. + +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} + 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}" + + # 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 "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT" + echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$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 GIT Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.script.outputs.git_url }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to DockerHub Container Registry + 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: ./ircd-exporter.scratch.Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + build-args: | + BUILD_DATE=${{steps.script.outputs.build_date}} + VCS_REF=${{steps.script.outputs.commit_hash}} + tags: | + docker.io/${{steps.script.outputs.docker_repo}}:ircd-exporter + quay.io/${{steps.script.outputs.redhat_quay_repo}}:ircd-exporter + ${{steps.script.outputs.git_url}}/${{steps.script.outputs.git_repo}}:ircd-exporter + + #- 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 \ No newline at end of file diff --git a/.github/workflows/build_docker_images-ircd-exportery.yaml b/.github/workflows/build_docker_images-ircd-exportery.yaml deleted file mode 100644 index 5ae4907..0000000 --- a/.github/workflows/build_docker_images-ircd-exportery.yaml +++ /dev/null @@ -1,93 +0,0 @@ -name: 'build docker images: ircd-exporter' - -on: - #push: - # branches: - # - 'main' - # - 'master' - # paths: - # - 'ircd-exporter.Dockerfile' - # - '.github/workflows/build_docker_images-ircd-exporter.yaml' - workflow_dispatch: - schedule: - - cron: '30 5 28 * *' # At 05:30 on day-of-month 28. - -defaults: - run: - shell: bash - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - 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 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} - - - name: Set up QEMU - id: qemu - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - #- name: Login to GitHub Container Registry - # uses: docker/login-action@v1 - # with: - # registry: ghcr.io - # username: ${{ github.repository_owner }} - # password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to DockerHub - uses: docker/login-action@v1 - 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@v1 - # with: - # registry: quay.io - # username: ${{ secrets.REDHAT_QUAY_USERNAME }} - # password: ${{ secrets.REDHAT_QUAY_PASSWORD }} - - - name: Build - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./ircd-exporter.Dockerfile - platforms: linux/amd64 - push: true - build-args: | - BUILD_DATE=${{steps.script.outputs.build_date}} - VCS_REF=${{steps.script.outputs.commit_hash}} - tags: | - docker.io/${{steps.script.outputs.docker_repo}}:ircd-exporter - # ghcr.io/${{steps.script.outputs.github_repo}}:ircd-exporter-${{steps.script.outputs.build_date_numeric}}.${{steps.script.outputs.commit_hash}} - # ghcr.io/${{steps.script.outputs.github_repo}}:ircd-exporter - # quay.io/${{steps.script.outputs.redhat_quay_repo}}:ircd-exporter diff --git a/ircd-exporter.Dockerfile b/ircd-exporter.scratch.Dockerfile similarity index 94% rename from ircd-exporter.Dockerfile rename to ircd-exporter.scratch.Dockerfile index 40979b1..cd0633d 100644 --- a/ircd-exporter.Dockerfile +++ b/ircd-exporter.scratch.Dockerfile @@ -1,4 +1,4 @@ -# docker build --no-cache --progress=plain --build-arg GO_VERSION=1.23 -t tobi312/tools:ircd-exporter -f ircd-exporter.Dockerfile . +# docker build --no-cache --progress=plain --build-arg GO_VERSION=1.23 -t tobi312/tools:ircd-exporter -f ircd-exporter.scratch.Dockerfile . ARG GO_VERSION=1.23 FROM golang:${GO_VERSION}-alpine AS builder ARG VERSION=master