diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index b394709..af6dcd3 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -29,12 +29,41 @@ jobs: - name: Run tests run: uv run pytest - docker-build: + docker-push: runs-on: ubuntu-latest needs: test + if: gitea.event_name == 'push' steps: - name: Checkout uses: actions/checkout@v4 - - name: Build Docker image - run: docker build -t shopping-list-api:${{ gitea.sha }} . + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set image name (lowercase) + id: meta + run: | + IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ toLower(gitea.repository) }}" + echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" + + - name: Log in to Gitea container registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.meta.outputs.image }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push multi-arch image + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ${{ steps.meta.outputs.image }}:${{ gitea.sha }} + ${{ steps.meta.outputs.image }}:latest + cache-from: type=registry,ref=${{ steps.meta.outputs.image }}:latest + cache-to: type=registry,ref=${{ steps.meta.outputs.image }}:latest,mode=max