name: Publish Debian Container Images on: push: tags-ignore: - "invoiceninja-*" env: REGISTRY_IMAGE: invoiceninja/invoiceninja-debian jobs: build: runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} strategy: fail-fast: false matrix: platform: ["linux/amd64", "linux/arm64"] steps: - name: Checkout uses: actions/checkout@v5 - name: Prepare id: prep run: | platform=${{ matrix.platform }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV DOCKER_IMAGE=${{ env.REGISTRY_IMAGE }} VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} fi TAGS="${DOCKER_IMAGE}:${VERSION}" MAJOR="$(echo "${VERSION}" | cut -d. -f1)" MINOR="$(echo "${VERSION}" | cut -d. -f2)" TAGS="$TAGS,${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:${MAJOR}.${MINOR}" # Debug output echo "Current version: ${VERSION}" echo "Version pattern check: $([[ $VERSION =~ ^5\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && echo "matches" || echo "doesn't match")" TAGS="$TAGS,${DOCKER_IMAGE}:latest" echo "tags=${TAGS}" >> $GITHUB_OUTPUT # Updated output syntax echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "major=${MAJOR}" >> $GITHUB_OUTPUT - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Build and push by digest id: docker_build uses: docker/build-push-action@v6 with: context: debian build-args: INVOICENINJA_VERSION=${{ steps.prep.outputs.version }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} outputs: type=image,push-by-digest=true,name-canonical=true cache-from: type=gha cache-to: type=gha,mode=max - name: Export digest run: | mkdir -p ${{ runner.temp }}/digests digest="${{ steps.build.outputs.digest }}" touch "${{ runner.temp }}/digests/${digest#sha256:}" - name: Upload digest uses: actions/upload-artifact@v4 with: name: digests-${{ env.PLATFORM_PAIR }} path: ${{ runner.temp }}/digests/* if-no-files-found: error retention-days: 1 merge: runs-on: ubuntu-latest needs: - build steps: - name: Download digests uses: actions/download-artifact@v4 with: path: ${{ runner.temp }}/digests pattern: digests-* merge-multiple: true - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - name: Create manifest list and push working-directory: ${{ runner.temp }}/digests if: ${{ github.event_name != 'pull_request' }} run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Inspect image run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} Description: if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v5 with: sparse-checkout: "README.md" - name: Docker Hub Description uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} repository: ${{ env.REGISTRY_IMAGE }}