diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e8689e1..0ae7263 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -63,46 +63,48 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} build: name: Build and push image - runs-on: ${{ matrix.runner }} + runs-on: ${{ matrix.arch.runner }} strategy: matrix: - runner: [ubuntu-latest, ubuntu-arm-latest] + arch: + - runner: ubuntu-latest + platform: linux/amd64 + - runner: ubuntu-arm-latest + platform: linux/arm64 permissions: packages: write needs: tests steps: - uses: actions/checkout@v4 + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Generate metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Login to the Container Registry uses: docker/login-action@v3 with: registry: brosner.dev username: brosner password: ${{ secrets.CI_TOKEN }} - - name: Generate metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=sha - labels: | - org.opencontainers.image.title=teufa - org.opencontainers.image.description=teufa container image - org.opencontainers.image.source=https://brosner.dev/brosner/teufa - org.opencontainers.image.licenses=MIT - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - name: Setup docker buildx uses: docker/setup-buildx-action@v3 - name: Build image + id: build uses: docker/build-push-action@v6 - if: gitea.ref == 'refs/heads/main' with: - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} target: prod - platforms: ${{ matrix.runner == 'ubuntu-latest' && 'linux/amd64' || 'linux/arm64' }} - push: true + platforms: ${{ matrix.arch.platform }} + 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:}"