diff --git a/.github/workflows/image-release.yml b/.github/workflows/image-release.yml index 6a8965f..f4723e1 100644 --- a/.github/workflows/image-release.yml +++ b/.github/workflows/image-release.yml @@ -39,7 +39,14 @@ on: jobs: release: - runs-on: [self-hosted, ARM64, stable] + runs-on: ${{ matrix.builder }} + strategy: + matrix: + include: + - builder: ubuntu-latest + platform: linux/amd64 + - builder: ubuntu-24.04-arm + platform: linux/arm64 environment: DOCKER_HUB steps: - name: Checkout @@ -78,13 +85,80 @@ jobs: password: ${{ secrets.registry-password }} - name: Build and push + id: build uses: docker/build-push-action@v6 with: - platforms: ${{ inputs.platforms }} + platforms: ${{ matrix.platform }} context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} build-args: | VOLTO_VERSION=${{ inputs.volto-version }} - push: ${{ github.event_name != 'pull_request' }} + # push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + + - 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-${{ matrix.platform }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-latest + needs: + - release + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.registry-username }} + password: ${{ secrets.registry-password }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ inputs.image-name }} + flavor: | + latest=false + suffix=${{ inputs.suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=pep440,pattern={{version}},value=${{ inputs.volto-version }} + type=pep440,pattern={{major}}.{{minor}}.{{patch}},value=${{ inputs.volto-version }} + type=pep440,pattern={{major}}.{{minor}},value=${{ inputs.volto-version }} + type=pep440,pattern={{major}},value=${{ inputs.volto-version }} + type=sha + type=raw,value=latest,enable=${{ inputs.is-latest }} + type=raw,value=${{ inputs.volto-version }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ inputs.image-name }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ inputs.image-name }}:${{ steps.meta.outputs.version }}