name: Build Android Builder Image

on:
  push:
    branches: [master]
    paths:
      - 'docker/android-builder.Dockerfile'
      - '.gitea/workflows/builder-image.yml'

env:
  IMAGE: git.aleshym.co/funman300/android-builder

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Log in to Gitea registry
        uses: docker/login-action@v3
        with:
          registry: git.aleshym.co
          username: ${{ gitea.actor }}
          password: ${{ secrets.CI_TOKEN }}

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with:
          driver-opts: network=host

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          file: docker/android-builder.Dockerfile
          push: true
          tags: ${{ env.IMAGE }}:latest
          cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
          cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
