From 4be0cbf4da68f56759bf6a458d1889df57650047 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Fri, 28 Oct 2022 11:52:49 +0000 Subject: [PATCH] Switch workflow to ghcr.io - Build images & build cache are pushed to ghcr.io. - Tests will make use of the images pushed to ghcr.io. - Deploy step only copies images from ghcr.io to docker.io. - Resolves strange build errors tied to buildx+intermediate builds - Results in quicker build times. --- .github/workflows/arm.yml | 4 +- .github/workflows/build_test_deploy.yml | 436 +++++------------------- .github/workflows/x64.yml | 4 +- 3 files changed, 90 insertions(+), 354 deletions(-) diff --git a/.github/workflows/arm.yml b/.github/workflows/arm.yml index 22d58cd5..7125737c 100644 --- a/.github/workflows/arm.yml +++ b/.github/workflows/arm.yml @@ -61,7 +61,7 @@ jobs: echo "RELEASE=true" >> $GITHUB_ENV echo "DEPLOY=true" >> $GITHUB_ENV echo "RELEASE=true" >> $GITHUB_ENV - - name: Derive PINNED_MAILU_VERSION for staging for master + - name: Derive PINNED_MAILU_VERSION for master if: env.BRANCH == 'master' shell: bash env: @@ -98,4 +98,4 @@ jobs: #else # pinned_version=$root_version.$(expr $patch_version + 1) #fi -#echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV \ No newline at end of file +#echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 7b7c357a..e8bb1a0a 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -58,15 +58,15 @@ on: required: true type: string deploy: - description: Deploy to docker hub. Happens for all branches but staging + description: Deploy to docker hub. Happens for all branches but staging. Use string true or false. default: true required: false - type: boolean + type: string release: - description: 'Tag and create the github release. Only happens for branch x.y (release branch)' + description: Tag and create the github release. Use string true or false. default: false required: false - type: boolean + type: string env: HCL_FILE: ./tests/build.hcl @@ -84,7 +84,7 @@ jobs: - name: Create matrix id: targets run: | - echo ::set-output name=matrix::$(docker buildx bake -f ${{env.HCL_FILE}} --print | jq -cr '.group.default.targets') + echo matrix=$(docker buildx bake -f ${{env.HCL_FILE}} --print | jq -cr '.group.default.targets') >> $GITHUB_OUTPUT - name: Show matrix run: | echo ${{ steps.targets.outputs.matrix }} @@ -107,26 +107,25 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure actions/cache@v3 action for storing build cache of base image in the ${{ runner.temp }}/cache folder - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/base - key: mailu-base-${{ inputs.architecture }}-${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }}-${{ github.run_id }} - restore-keys: | - mailu-base-${{ inputs.architecture }}-${{hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: - username: ${{ secrets.Docker_Login }} - password: ${{ secrets.Docker_Password }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 + with: + string: ${{ github.repository_owner }} - name: Build all docker images env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} + DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 @@ -136,8 +135,8 @@ jobs: load: false push: false set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/base - *.cache-to=type=local,dest=${{ runner.temp }}/cache/base,mode=max + *.cache-from=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/base:${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }} + *.cache-to=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/base:${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }},mode=max *.platform=${{ inputs.architecture }} # This job builds all the images. The build cache is stored in the github actions cache. @@ -165,33 +164,25 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure actions/cache@v3 action for storing build cache of base image in the ${{ runner.temp }}/cache folder - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/base - key: mailu-base-${{ inputs.architecture }}-${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }}-${{ github.run_id }} - restore-keys: | - mailu-base-${{ inputs.architecture }}-${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }} - - name: Configure actions/cache@v3 action for storing build cache in the ${{ runner.temp }}/cache folder - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/${{ matrix.target }} - key: ${{ matrix.target }}-${{ inputs.architecture }}-${{ github.run_id }} - restore-keys: | - ${{ github.ref }}-${{ inputs.mailu_version }}-${{ matrix.target }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: - username: ${{ secrets.Docker_Login }} - password: ${{ secrets.Docker_Password }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 + with: + string: ${{ github.repository_owner }} - name: Build all docker images env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} + DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 @@ -199,11 +190,11 @@ jobs: files: ${{env.HCL_FILE}} targets: ${{ matrix.target }} load: false - push: false + push: true set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/${{ matrix.target }} - *.cache-from=type=local,src=${{ runner.temp }}/cache/base - *.cache-to=type=local,dest=${{ runner.temp }}/cache/${{ matrix.target }},mode=max + *.cache-from=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:buildcache + *.cache-to=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:buildcache,mode=max + *.cache-from=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/base:${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }} *.platform=${{ inputs.architecture }} # This job builds all the images. The build cache is stored in the github actions cache. @@ -231,33 +222,25 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure actions/cache@v3 action for storing build cache of base image in the ${{ runner.temp }}/cache folder - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/base - key: mailu-base-${{ inputs.architecture }}-${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }}-${{ github.run_id }} - restore-keys: | - mailu-base-${{ inputs.architecture }}-${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }} - - name: Configure actions/cache@v3 action for storing build cache in the ${{ runner.temp }}/cache folder - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/${{ matrix.target }} - key: ${{ matrix.target }}-${{ inputs.architecture }}-${{ github.run_id }} - restore-keys: | - ${{ matrix.target }}-${{ inputs.architecture }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: - username: ${{ secrets.Docker_Login }} - password: ${{ secrets.Docker_Password }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 + with: + string: ${{ github.repository_owner }} - name: Build all docker images env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} + DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 @@ -267,9 +250,10 @@ jobs: load: false push: false set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/${{ matrix.target }} - *.cache-from=type=local,src=${{ runner.temp }}/cache/base - *.cache-to=type=local,dest=${{ runner.temp }}/cache/${{ matrix.target }},mode=max + *.cache-from=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:buildcache-arm + *.cache-to=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:buildcache-arm,mode=max + *.cache-from=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/base:${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }}-arm + *.cache-to=type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/base:${{ hashFiles('core/base/Dockerfile','core/base/requirements-prod.txt') }}-arm,mode=max *.platform=${{ inputs.architecture }} # This job runs all the tests. @@ -303,112 +287,22 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure /cache for image docs - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/docs - key: docs-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image setup - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/setup - key: setup-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image admin - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/admin - key: admin-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antispam - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antispam - key: antispam-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image front - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/front - key: front-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image imap - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/imap - key: imap-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image smtp - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/smtp - key: smtp-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image snappymail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/snappymail - key: snappymail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image roundcube - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/roundcube - key: roundcube-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antivirus - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antivirus - key: antivirus-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image fetchmail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/fetchmail - key: fetchmail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image resolver - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/resolver - key: resolver-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image traefik-certdumper - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/traefik-certdumper - key: traefik-certdumper-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image webdav - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/webdav - key: webdav-${{ inputs.architecture }}-${{ github.run_id }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: - username: ${{ secrets.Docker_Login }} - password: ${{ secrets.Docker_Password }} - - name: Build docker images for testing from cache - env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} - MAILU_VERSION: ${{ env.MAILU_VERSION }} - PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} - uses: docker/bake-action@v2 + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 with: - files: ${{env.HCL_FILE}} - load: true - push: false - set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/docs - *.cache-from=type=local,src=${{ runner.temp }}/cache/setup - *.cache-from=type=local,src=${{ runner.temp }}/cache/admin - *.cache-from=type=local,src=${{ runner.temp }}/cache/antispam - *.cache-from=type=local,src=${{ runner.temp }}/cache/front - *.cache-from=type=local,src=${{ runner.temp }}/cache/imap - *.cache-from=type=local,src=${{ runner.temp }}/cache/smtp - *.cache-from=type=local,src=${{ runner.temp }}/cache/snappymail - *.cache-from=type=local,src=${{ runner.temp }}/cache/roundcube - *.cache-from=type=local,src=${{ runner.temp }}/cache/antivirus - *.cache-from=type=local,src=${{ runner.temp }}/cache/fetchmail - *.cache-from=type=local,src=${{ runner.temp }}/cache/resolver - *.cache-from=type=local,src=${{ runner.temp }}/cache/traefik-certdumper - *.cache-from=type=local,src=${{ runner.temp }}/cache/webdav - *.platform=${{ inputs.architecture }} + string: ${{ github.repository_owner }} - name: Install python packages run: python3 -m pip install -r tests/requirements.txt - name: Copy all certs @@ -416,12 +310,10 @@ jobs: - name: Test ${{ matrix.target }} run: python tests/compose/test.py ${{ matrix.target }} ${{ matrix.time }} env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} + DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} -# This job deploys the docker images to the docker repository. The build.hcl file contains logic that determines what tags are pushed. -# E.g. for master only the :master and :latest tags are pushed. deploy: name: Deploy images # Deploying is not required for staging @@ -430,6 +322,10 @@ jobs: needs: - build - tests + strategy: + fail-fast: false + matrix: + target: ["setup", "docs", "fetchmail", "roundcube", "admin", "traefik-certdumper", "radicale", "clamav", "rspamd", "postfix", "dovecot", "unbound", "nginx", "snappymail"] steps: - uses: actions/checkout@v3 - name: Retrieve global variables @@ -439,76 +335,6 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure /cache for image docs - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/docs - key: docs-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image setup - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/setup - key: setup-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image admin - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/admin - key: admin-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antispam - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antispam - key: antispam-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image front - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/front - key: front-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image imap - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/imap - key: imap-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image smtp - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/smtp - key: smtp-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image snappymail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/snappymail - key: snappymail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image roundcube - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/roundcube - key: roundcube-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antivirus - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antivirus - key: antivirus-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image fetchmail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/fetchmail - key: fetchmail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image resolver - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/resolver - key: resolver-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image traefik-certdumper - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/traefik-certdumper - key: traefik-certdumper-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image webdav - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/webdav - key: webdav-${{ inputs.architecture }}-${{ github.run_id }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 @@ -519,31 +345,19 @@ jobs: with: username: ${{ secrets.Docker_Login }} password: ${{ secrets.Docker_Password }} - - name: Deploy images to docker hub. Build.hcl contains the logic for the tags that are pushed. - env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} - MAILU_VERSION: ${{ env.MAILU_VERSION }} - PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} - uses: docker/bake-action@v2 + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 with: - files: ${{env.HCL_FILE}} - push: true - set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/docs - *.cache-from=type=local,src=${{ runner.temp }}/cache/setup - *.cache-from=type=local,src=${{ runner.temp }}/cache/admin - *.cache-from=type=local,src=${{ runner.temp }}/cache/antispam - *.cache-from=type=local,src=${{ runner.temp }}/cache/front - *.cache-from=type=local,src=${{ runner.temp }}/cache/imap - *.cache-from=type=local,src=${{ runner.temp }}/cache/smtp - *.cache-from=type=local,src=${{ runner.temp }}/cache/snappymail - *.cache-from=type=local,src=${{ runner.temp }}/cache/roundcube - *.cache-from=type=local,src=${{ runner.temp }}/cache/antivirus - *.cache-from=type=local,src=${{ runner.temp }}/cache/fetchmail - *.cache-from=type=local,src=${{ runner.temp }}/cache/resolver - *.cache-from=type=local,src=${{ runner.temp }}/cache/traefik-certdumper - *.cache-from=type=local,src=${{ runner.temp }}/cache/webdav - *.platform=${{ inputs.architecture }} + string: ${{ github.repository_owner }} + - name: Push image to Docker + shell: bash + run: | + if [ '${{ env.MAILU_VERSION }}' == 'master' ]; then pinned_mailu_version='master'; else pinned_mailu_version=${{ env.PINNED_MAILU_VERSION}}; fi; + docker buildx imagetools create \ + --tag ${{ inputs.docker_org }}/${{ matrix.target }}:${{ env.MAILU_VERSION }} \ + --tag ${{ inputs.docker_org }}/${{ matrix.target }}:$pinned_mailu_version \ + ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:${{ env.MAILU_VERSION }} deploy-arm: name: Deploy images for arm @@ -552,6 +366,10 @@ jobs: runs-on: self-hosted needs: - build-arm + strategy: + fail-fast: false + matrix: + target: ["setup", "docs", "fetchmail", "roundcube", "admin", "traefik-certdumper", "radicale", "clamav", "rspamd", "postfix", "dovecot", "unbound", "nginx", "snappymail"] steps: - uses: actions/checkout@v3 - name: Retrieve global variables @@ -561,76 +379,6 @@ jobs: echo "MAILU_VERSION=${{ inputs.mailu_version }}" >> $GITHUB_ENV echo "PINNED_MAILU_VERSION=${{ inputs.pinned_mailu_version }}" >> $GITHUB_ENV echo "DOCKER_ORG=${{ inputs.docker_org }}" >> $GITHUB_ENV - - name: Configure /cache for image docs - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/docs - key: docs-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image setup - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/setup - key: setup-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image admin - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/admin - key: admin-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antispam - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antispam - key: antispam-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image front - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/front - key: front-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image imap - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/imap - key: imap-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image smtp - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/smtp - key: smtp-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image snappymail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/snappymail - key: snappymail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image roundcube - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/roundcube - key: roundcube-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image antivirus - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/antivirus - key: antivirus-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image fetchmail - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/fetchmail - key: fetchmail-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image resolver - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/resolver - key: resolver-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image traefik-certdumper - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/traefik-certdumper - key: traefik-certdumper-${{ inputs.architecture }}-${{ github.run_id }} - - name: Configure /cache for image webdav - uses: actions/cache@v3 - with: - path: ${{ runner.temp }}/cache/webdav - key: webdav-${{ inputs.architecture }}-${{ github.run_id }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - uses: crazy-max/ghaction-github-runtime@v2 @@ -641,31 +389,19 @@ jobs: with: username: ${{ secrets.Docker_Login }} password: ${{ secrets.Docker_Password }} - - name: Deploy images to docker hub. Build.hcl contains the logic for the tags that are pushed. - env: - DOCKER_ORG: ${{ env.DOCKER_ORG }} - MAILU_VERSION: ${{ env.MAILU_VERSION }} - PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} - uses: docker/bake-action@v2 + - name: Helper to convert docker org to lowercase + id: string + uses: ASzc/change-string-case-action@v2 with: - files: ${{env.HCL_FILE}} - push: true - set: | - *.cache-from=type=local,src=${{ runner.temp }}/cache/docs - *.cache-from=type=local,src=${{ runner.temp }}/cache/setup - *.cache-from=type=local,src=${{ runner.temp }}/cache/admin - *.cache-from=type=local,src=${{ runner.temp }}/cache/antispam - *.cache-from=type=local,src=${{ runner.temp }}/cache/front - *.cache-from=type=local,src=${{ runner.temp }}/cache/imap - *.cache-from=type=local,src=${{ runner.temp }}/cache/smtp - *.cache-from=type=local,src=${{ runner.temp }}/cache/snappymail - *.cache-from=type=local,src=${{ runner.temp }}/cache/roundcube - *.cache-from=type=local,src=${{ runner.temp }}/cache/antivirus - *.cache-from=type=local,src=${{ runner.temp }}/cache/fetchmail - *.cache-from=type=local,src=${{ runner.temp }}/cache/resolver - *.cache-from=type=local,src=${{ runner.temp }}/cache/traefik-certdumper - *.cache-from=type=local,src=${{ runner.temp }}/cache/webdav - *.platform=${{ inputs.architecture }} + string: ${{ github.repository_owner }} + - name: Push image to Docker + shell: bash + run: | + if [ '${{ env.MAILU_VERSION }}' == 'master-arm' ]; then pinned_mailu_version='master-arm'; else pinned_mailu_version=${{ env.PINNED_MAILU_VERSION}}; fi; + docker buildx imagetools create \ + --tag ${{ inputs.docker_org }}/${{ matrix.target }}:${{ env.MAILU_VERSION }} \ + --tag ${{ inputs.docker_org }}/${{ matrix.target }}:$pinned_mailu_version \ + ghcr.io/${{ steps.string.outputs.lowercase }}/${{ matrix.target }}:${{ env.MAILU_VERSION }} #This job creates a tagged release. A tag is created for the pinned version x.y.z. The GH release refers to this tag. tag-release: diff --git a/.github/workflows/x64.yml b/.github/workflows/x64.yml index e1691756..97b6beac 100644 --- a/.github/workflows/x64.yml +++ b/.github/workflows/x64.yml @@ -82,7 +82,7 @@ jobs: echo "PINNED_MAILU_VERSION=staging" >> $GITHUB_ENV echo "DEPLOY=false" >> $GITHUB_ENV echo "RELEASE=false" >> $GITHUB_ENV - - name: Derive PINNED_MAILU_VERSION for staging for master + - name: Derive PINNED_MAILU_VERSION for master if: env.BRANCH == 'master' shell: bash env: @@ -131,4 +131,4 @@ jobs: #else # pinned_version=$root_version.$(expr $patch_version + 1) #fi -#echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV \ No newline at end of file +#echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV