From 7d518c24dc82ae7b1575f5ab49e0e5c1fbd7434d Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Tue, 28 Oct 2025 14:20:35 +0100 Subject: [PATCH] align workflows with debian --- .github/workflows/build-image-debian.yaml | 34 +++-- .github/workflows/publish-image.yaml | 157 ++++++++++++++++------ 2 files changed, 140 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build-image-debian.yaml b/.github/workflows/build-image-debian.yaml index f0e7fe1..ab1980e 100644 --- a/.github/workflows/build-image-debian.yaml +++ b/.github/workflows/build-image-debian.yaml @@ -1,36 +1,48 @@ -name: Build Debian Octane Container Image +name: Build Octane Container Image on: pull_request: paths: + - ".github/**" - "debian/**" push: paths: + - ".github/**" - "debian/**" - branches: - - master + +env: + REGISTRY_IMAGE: invoiceninja/invoiceninja-octane jobs: - docker: - runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + build: + runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} strategy: fail-fast: false matrix: - platform: ["linux/amd64", "linux/arm64"] + platform: + - linux/amd64 + - linux/arm64 steps: - name: Checkout uses: actions/checkout@v5 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Build - id: docker_build + id: build uses: docker/build-push-action@v6 with: - context: debian - load: true - tags: invoiceninja/invoiceninja-octane:test + context: debian + platforms: ${{ matrix.platform }} + tags: ${{ env.REGISTRY_IMAGE }} + outputs: type=image,push-by-digest=true,name-canonical=true cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml index bdfecbd..dc0aeb7 100644 --- a/.github/workflows/publish-image.yaml +++ b/.github/workflows/publish-image.yaml @@ -1,21 +1,49 @@ -name: Publish Debian Container Images +name: Publish Octane Container Images on: push: tags-ignore: - "invoiceninja-*" +env: + REGISTRY_IMAGE: invoiceninja/invoiceninja-octane + jobs: - docker: - runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + major: ${{ steps.version.outputs.major }} + minor: ${{ steps.version.outputs.minor }} + steps: + - id: version + run: | + + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + fi + MAJOR="$(echo "${VERSION}" | cut -d. -f1)" + MINOR="$(echo "${VERSION}" | cut -d. -f2)" + + # 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")" + + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "major=${MAJOR}" >> $GITHUB_OUTPUT + echo "minor=${MINOR}" >> $GITHUB_OUTPUT + + build: + runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} + needs: + - version strategy: fail-fast: false matrix: - platform: ["linux/amd64", "linux/arm64"] - include: - - image: invoiceninja/invoiceninja-octane - context: debian - + platform: + - linux/amd64 + - linux/arm64 steps: - name: Checkout uses: actions/checkout@v5 @@ -23,53 +51,102 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=${{ matrix.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}" + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - # 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: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} - name: Login to DockerHub - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build and push - id: docker_build + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: - context: ${{ matrix.context }} - build-args: INVOICENINJA_VERSION=${{ steps.prep.outputs.version }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} + context: debian + build-args: INVOICENINJA_VERSION=${{ needs.version.outputs.version }} + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ env.REGISTRY_IMAGE }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + - 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: + - version + - 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_PASSWORD }} + + - 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: | + ${{ needs.version.outputs.version }} + ${{ needs.version.outputs.major }} + ${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }} + latest + + - 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 + if: ${{ github.event_name != 'pull_request' }} + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} Description: + if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest + needs: + - merge steps: - name: Checkout uses: actions/checkout@v5 @@ -81,4 +158,4 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - repository: invoiceninja/invoiceninja-octane + repository: ${{ env.REGISTRY_IMAGE }}