From a11bae097c725aace1a3c737d65115231e749f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 4 Sep 2024 17:23:07 +0200 Subject: [PATCH] Push Dockerfile to registry using go-makefile-maker --- .github/renovate.json | 1 + .../workflows/container-registry-ghcr.yaml | 46 +++++++++++++++++++ Makefile | 31 +++++++++++++ Makefile.maker.yaml | 16 +++++++ 4 files changed, 94 insertions(+) create mode 100644 .github/workflows/container-registry-ghcr.yaml create mode 100644 Makefile.maker.yaml diff --git a/.github/renovate.json b/.github/renovate.json index 742f9ee..c8dc8a4 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,4 +1,5 @@ { + "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "config:recommended", "default:pinDigestsDisabled", diff --git a/.github/workflows/container-registry-ghcr.yaml b/.github/workflows/container-registry-ghcr.yaml new file mode 100644 index 0000000..b225e02 --- /dev/null +++ b/.github/workflows/container-registry-ghcr.yaml @@ -0,0 +1,46 @@ +################################################################################ +# This file is AUTOGENERATED with # +# Edit Makefile.maker.yaml instead. # +################################################################################ + +name: Container Registry GHCR +"on": + push: + tags: + - '*' +permissions: + contents: read + packages: write +jobs: + build-and-push-image: + name: Push container to ghcr.io + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + # https://github.com/docker/metadata-action#typeedge + type=edge + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/Makefile b/Makefile index a12940f..a8bac9a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +################################################################################ +# This file is AUTOGENERATED with # +# Edit Makefile.maker.yaml instead. # +################################################################################ + MAKEFLAGS=--warn-undefined-variables # /bin/sh is dash on Debian which does not support all features of ash/bash # to fix that we use /bin/bash only on Debian to not break Alpine @@ -7,9 +12,17 @@ ifneq (,$(wildcard /etc/os-release)) # check file existence endif endif +default: FORCE + @echo 'There is nothing to build, use `make check` for running the test suite or `make help` for a list of available targets.' + prepare-static-check: FORCE @if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi +# to get around weird Makefile syntax restrictions, we need variables containing nothing, a space and comma +null := +space := $(null) $(null) +comma := , + license-headers: FORCE prepare-static-check @printf "\e[1;36m>> addlicense\e[0m\n" @addlicense -c "SAP SE" -- $(shell find -name *.rs) @@ -21,4 +34,22 @@ check-license-headers: FORCE prepare-static-check clean: FORCE git clean -dxf build +vars: FORCE +help: FORCE + @printf "\n" + @printf "\e[1mUsage:\e[0m\n" + @printf " make \e[36m\e[0m\n" + @printf "\n" + @printf "\e[1mGeneral\e[0m\n" + @printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n" + @printf " \e[36mhelp\e[0m Display this help.\n" + @printf "\n" + @printf "\e[1mPrepare\e[0m\n" + @printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n" + @printf "\n" + @printf "\e[1mDevelopment\e[0m\n" + @printf " \e[36mlicense-headers\e[0m Add license headers to all non-vendored source code files.\n" + @printf " \e[36mcheck-license-headers\e[0m Check license headers in all non-vendored .go files.\n" + @printf " \e[36mclean\e[0m Run git clean.\n" + .PHONY: FORCE diff --git a/Makefile.maker.yaml b/Makefile.maker.yaml new file mode 100644 index 0000000..6ea0d9a --- /dev/null +++ b/Makefile.maker.yaml @@ -0,0 +1,16 @@ +# Configuration file for + +metadata: + url: https://github.com/sapcc/pear-reviewer + +githubWorkflow: + global: + defaultBranch: master + pushContainerToGhcr: + enabled: true + tagStrategy: [ edge ] + +renovate: + enabled: true + assignees: + - SuperSandro2000